Skip to content

Commit c900e2f

Browse files
committed
[css2] Now adds an anchor to the H1 as well (to keep the pubrules checker
happy), but doesn't use it in the ToC. --HG-- extra : convert_revision : svn%3A73dc7c4b-06e6-40f3-b4f7-9ed1dbc14bfc/trunk%401927
1 parent b763d7c commit c900e2f

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

css2/bin/addhanch

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# The files are rwritten.
44
# Arnaud Le Hors - lehors@w3.org
55
# Modifications by Bert Bos <bert@w3.org>
6-
# $Id: addhanch,v 2.2 1998-04-06 23:51:21 ijacobs Exp $
6+
# $Id: addhanch,v 2.3 2002-08-02 18:12:19 bbos Exp $
77

88
use DB_File;
99
use Getopt::Std;
@@ -89,16 +89,14 @@ sub addanchor {
8989
my $file = $chapter[$chapno];
9090

9191
# Generate the anchor
92-
if ($lvl == 1) { # if H1, just go to the top of the page
93-
$anchor = "";
94-
$anchor1 = "";
95-
} elsif ($content =~ /<a\s+[^>]*?name\s*=\s*(?:([^\s\">]+)|\"([^\"]+)\"|\'([^\']+)\')/io) { # Reuse first anchor in header.
92+
if ($content =~ /<a\s+[^>]*?name\s*=\s*(?:([^\s\">]+)|\"([^\"]+)\"|\'([^\']+)\')/io) { # Reuse first anchor in header.
9693
$anchor = "$1$2$3"; # Only one of $1, $2, $3 will match.
9794
$anchor1 = "#$anchor";
9895
} else {
9996
$anchor = "q$seqno"; # Use simple sequence number
10097
$anchor1 = "#$anchor";
10198
}
99+
$anchor1 = "" if ($lvl == 1); # if H1, just go to the top of the page
102100

103101
# Increment the count, reset higher level counts
104102
$counts[$lvl]++;
@@ -120,8 +118,8 @@ sub addanchor {
120118
$anchors{$dbkey} = $dbentry;
121119

122120
# Construct the new heading
123-
if ($lvl == 1 || $content =~ /<a\s+[^>]*?name\s*=/sio) {
124-
# Don't add anchors if H1, or if there is already an anchor
121+
if ($content =~ /<a\s+[^>]*?name\s*=/sio) {
122+
# Don't add anchors if there is already an anchor
125123
return "$stag$num $content$etag";
126124
} elsif ($content =~ /<a\b/sio) {
127125
# There is an A tag, insert anchor before it

0 commit comments

Comments
 (0)