File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22# sub TOC builder
33#
44# Arnaud Le Hors - lehors@w3.org
5- # $Id: mksubtoc,v 1.5 1997-12-09 15:16:00 ian Exp $
5+ # $Id: mksubtoc,v 1.6 1997-12-11 00:13:45 ijacobs Exp $
66
77$startlvl = 0;
88$maxlvl = 0;
@@ -93,9 +93,11 @@ while (/$file;(.*?);([0-9]*);([1-9A-Z].*?);(.*?)\n/sig) {
9393 $anchor = $4 ;
9494 if ($h > $startlvl && ($maxlvl == 0 || $h <= $maxlvl )) {
9595 ol($h );
96- # If there's an anchor, reuse it.
96+ # If there's an anchor, it has a name attr (by mktoc).
97+ # Reuse it (and rename name -> href everywhere)
9798 if ($t =~ / <a[^>]+>/si ) {
98- $t =~ s / name=\" ?.*?$anchor\" ?/ href=\" #$anchor \" / isg ;
99+ $t =~ s / name\s *=\s *\" [^#]*?(#[^"]*?)\" / href=\"\1\" / isg ;
100+ $t =~ s / name\s *=\s *[^#]*?(#[^\s >]*?)/ href=\"\1\" / isg ;
99101 print OUTPUT " <li>$t \n " ;
100102 } else {
101103 if ($h > 1) {
Original file line number Diff line number Diff line change 55# 1. Some header - and its related comment
66#
77# Arnaud Le Hors - lehors@w3.org
8- # $Id: mktoc,v 1.13 1997-12-09 00:08 :46 ijacobs Exp $
8+ # $Id: mktoc,v 1.14 1997-12-11 00:13 :46 ijacobs Exp $
99
1010if (($_ = $ARGV [0], /^-l /) && $ARGV [0]) {
1111 shift ;
@@ -163,9 +163,11 @@ LOOP: foreach $file (@ARGV) {
163163 $hasanchor = t;
164164 # let's reuse it
165165 $anch = $& ;
166- if ($anch =~ / name=(?:\" ([^\" ]+)\" |([^ \n\t >]+))/sig ) {
166+ if ($anch =~ / name\s *=\s *(?:\" ([^\" ]+)\" |([^\s >]+))/sig ) {
167+ # Only one of two will match.
167168 $anchor = " $1$2 " ;
168- $txt =~ s / name=\" ?$anchor\" ?/ href=\" $hfil #$anchor \" / isg ;
169+ $txt =~ s / name\s *=\s *\" $anchor\" / href=\" $hfil #$anchor \" / isg ;
170+ $txt =~ s / name\s *=\s *$anchor\s / href=\" $hfil #$anchor \"\s / isg ;
169171 }
170172 } else {
171173 $anchor = " h-$num " ;
Original file line number Diff line number Diff line change 22# sub TOC builder
33#
44# Arnaud Le Hors - lehors@w3.org
5- # $Id: mksubtoc,v 1.5 1997-12-09 15:16:00 ian Exp $
5+ # $Id: mksubtoc,v 1.6 1997-12-11 00:13:45 ijacobs Exp $
66
77$startlvl = 0;
88$maxlvl = 0;
@@ -93,9 +93,11 @@ while (/$file;(.*?);([0-9]*);([1-9A-Z].*?);(.*?)\n/sig) {
9393 $anchor = $4 ;
9494 if ($h > $startlvl && ($maxlvl == 0 || $h <= $maxlvl )) {
9595 ol($h );
96- # If there's an anchor, reuse it.
96+ # If there's an anchor, it has a name attr (by mktoc).
97+ # Reuse it (and rename name -> href everywhere)
9798 if ($t =~ / <a[^>]+>/si ) {
98- $t =~ s / name=\" ?.*?$anchor\" ?/ href=\" #$anchor \" / isg ;
99+ $t =~ s / name\s *=\s *\" [^#]*?(#[^"]*?)\" / href=\"\1\" / isg ;
100+ $t =~ s / name\s *=\s *[^#]*?(#[^\s >]*?)/ href=\"\1\" / isg ;
99101 print OUTPUT " <li>$t \n " ;
100102 } else {
101103 if ($h > 1) {
Original file line number Diff line number Diff line change 55# 1. Some header - and its related comment
66#
77# Arnaud Le Hors - lehors@w3.org
8- # $Id: mktoc,v 1.13 1997-12-09 00:08 :46 ijacobs Exp $
8+ # $Id: mktoc,v 1.14 1997-12-11 00:13 :46 ijacobs Exp $
99
1010if (($_ = $ARGV [0], /^-l /) && $ARGV [0]) {
1111 shift ;
@@ -163,9 +163,11 @@ LOOP: foreach $file (@ARGV) {
163163 $hasanchor = t;
164164 # let's reuse it
165165 $anch = $& ;
166- if ($anch =~ / name=(?:\" ([^\" ]+)\" |([^ \n\t >]+))/sig ) {
166+ if ($anch =~ / name\s *=\s *(?:\" ([^\" ]+)\" |([^\s >]+))/sig ) {
167+ # Only one of two will match.
167168 $anchor = " $1$2 " ;
168- $txt =~ s / name=\" ?$anchor\" ?/ href=\" $hfil #$anchor \" / isg ;
169+ $txt =~ s / name\s *=\s *\" $anchor\" / href=\" $hfil #$anchor \" / isg ;
170+ $txt =~ s / name\s *=\s *$anchor\s / href=\" $hfil #$anchor \"\s / isg ;
169171 }
170172 } else {
171173 $anchor = " h-$num " ;
You can’t perform that action at this time.
0 commit comments