summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>1998-02-18 13:53:48 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>1998-02-18 13:53:48 (GMT)
commitdaa2d5d4ea6f634bae970d9065f8a239b13312ab (patch)
tree19ab2136b35e1683a653d570d0ee549c0cc4d69a /Doc/tools
parent16a0bc278e34ca5b1b1717f21b9e6a4c4b2059f9 (diff)
downloadcpython-daa2d5d4ea6f634bae970d9065f8a239b13312ab.zip
cpython-daa2d5d4ea6f634bae970d9065f8a239b13312ab.tar.gz
cpython-daa2d5d4ea6f634bae970d9065f8a239b13312ab.tar.bz2
Patch HREFs in html files, replacing nodeXXX.html with label.html.
Diffstat (limited to 'Doc/tools')
-rwxr-xr-xDoc/tools/node2label.pl38
1 files changed, 38 insertions, 0 deletions
diff --git a/Doc/tools/node2label.pl b/Doc/tools/node2label.pl
new file mode 100755
index 0000000..8a77cbf
--- /dev/null
+++ b/Doc/tools/node2label.pl
@@ -0,0 +1,38 @@
+#!/depot/gnu/plat/bin/perl -i~
+
+# read the labels, then reverse the mappings
+require "labels.pl";
+
+%nodes = ();
+foreach $label (keys %external_labels) {
+ $nodes{$external_labels{$label}} = $label;
+}
+
+# collect labels that have been used
+%newnames = ();
+
+while (<>) {
+ # don't want to do one s/// per line per node
+ # so look for lines with hrefs, then do s/// on nodes present
+ if (/HREF=\"([^\#\"]*)html[\#\"]/) {
+ @parts = split(/HREF\=\"/);
+ shift @parts;
+ for $node (@parts) {
+ $node =~ s/[\#\"].*$//g;
+ chop($node);
+ if (defined($nodes{$node})) {
+ $label = $nodes{$node};
+ if (s/HREF=\"$node([\#\"])/HREF=\"$label.html$1/g) {
+ s/HREF=\"$label.html#SECTION\d+/HREF=\"$label.html/g;
+ $newnames{$node} = "$label.html";
+ }
+ }
+ }
+ }
+ print;
+}
+
+foreach $oldname (keys %newnames) {
+# or mv
+ system("ln -s $oldname $newnames{$oldname}");
+}