Mercurial > cpython-lru_cache-weakref
annotate Doc/tools/node2label.pl @ 8831:00a6bb65ff29 legacy-trunk
Getting rid of this ancient stuff.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 05 Aug 1998 21:10:09 +0000 |
| parents | 587d0178f8d3 |
| children | 8acc72a81319 |
| rev | line source |
|---|---|
|
7721
f093fcfd5625
Use "/usr/bin/env perl" for the #! line, and change the -i option to:
Fred Drake <fdrake@acm.org>
parents:
7491
diff
changeset
|
1 #! /usr/bin/env perl |
|
f093fcfd5625
Use "/usr/bin/env perl" for the #! line, and change the -i option to:
Fred Drake <fdrake@acm.org>
parents:
7491
diff
changeset
|
2 |
|
f093fcfd5625
Use "/usr/bin/env perl" for the #! line, and change the -i option to:
Fred Drake <fdrake@acm.org>
parents:
7491
diff
changeset
|
3 use English; |
|
f093fcfd5625
Use "/usr/bin/env perl" for the #! line, and change the -i option to:
Fred Drake <fdrake@acm.org>
parents:
7491
diff
changeset
|
4 $INPLACE_EDIT = ''; |
|
7352
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
5 |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
6 # read the labels, then reverse the mappings |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
7 require "labels.pl"; |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
8 |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
9 %nodes = (); |
|
7491
7f28997b2c10
Adjusted to work with the newer version of LaTeX2HTML as well.
Fred Drake <fdrake@acm.org>
parents:
7366
diff
changeset
|
10 my $key; |
|
7366
717c3daca08e
assure a consistent assignment for nodes with multiple labels
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
7355
diff
changeset
|
11 # sort so that we get a consistent assignment for nodes with multiple labels |
|
717c3daca08e
assure a consistent assignment for nodes with multiple labels
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
7355
diff
changeset
|
12 foreach $label (sort keys %external_labels) { |
|
7491
7f28997b2c10
Adjusted to work with the newer version of LaTeX2HTML as well.
Fred Drake <fdrake@acm.org>
parents:
7366
diff
changeset
|
13 $key = $external_labels{$label}; |
|
7f28997b2c10
Adjusted to work with the newer version of LaTeX2HTML as well.
Fred Drake <fdrake@acm.org>
parents:
7366
diff
changeset
|
14 $key =~ s|^/||; |
|
7f28997b2c10
Adjusted to work with the newer version of LaTeX2HTML as well.
Fred Drake <fdrake@acm.org>
parents:
7366
diff
changeset
|
15 $nodes{$key} = $label; |
|
7352
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
16 } |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
17 |
|
7766
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
18 # This adds the "internal" labels added for indexing. These labels will not |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
19 # be used for file names. |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
20 require "intlabels.pl"; |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
21 foreach $label (keys %internal_labels) { |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
22 $key = $internal_labels{$label}; |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
23 $key =~ s|^/||; |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
24 if (defined($nodes{$key})) { |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
25 $nodes{$label} = $nodes{$key}; |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
26 } |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
27 } |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
28 |
|
7352
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
29 # collect labels that have been used |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
30 %newnames = (); |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
31 |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
32 while (<>) { |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
33 # don't want to do one s/// per line per node |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
34 # so look for lines with hrefs, then do s/// on nodes present |
|
7766
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
35 if (/(HREF|href)=\"([^\#\"]*)html[\#\"]/) { |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
36 @parts = split(/(HREF|href)\=\"/); |
|
7352
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
37 shift @parts; |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
38 for $node (@parts) { |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
39 $node =~ s/[\#\"].*$//g; |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
40 chop($node); |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
41 if (defined($nodes{$node})) { |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
42 $label = $nodes{$node}; |
|
7766
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
43 if (s/(HREF|href)=\"$node([\#\"])/$1=\"$label.html$2/g) { |
|
587d0178f8d3
Add support for mapping internal labels used from the index.
Fred Drake <fdrake@acm.org>
parents:
7721
diff
changeset
|
44 s/(HREF|href)=\"$label.html#(l2h-)?SECTION\d+/$1=\"$label.html/g; |
|
7352
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
45 $newnames{$node} = "$label.html"; |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
46 } |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
47 } |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
48 } |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
49 } |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
50 print; |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
51 } |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
52 |
|
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
53 foreach $oldname (keys %newnames) { |
| 7355 | 54 # or ln -s |
| 55 system("mv $oldname $newnames{$oldname}"); | |
|
7352
0d31c7d9697d
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
56 } |
