diff options
author | Fred Drake <fdrake@acm.org> | 1997-12-17 03:08:27 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1997-12-17 03:08:27 (GMT) |
commit | 819b789f3632e6cc727147b2ec89a3d9a0590d91 (patch) | |
tree | 25630ab2f6d34cbf2c4851b6cbff73d4de2d71ba | |
parent | 84818d7aada07f9c3d5e39f492ebb6f3158737d7 (diff) | |
download | cpython-819b789f3632e6cc727147b2ec89a3d9a0590d91.zip cpython-819b789f3632e6cc727147b2ec89a3d9a0590d91.tar.gz cpython-819b789f3632e6cc727147b2ec89a3d9a0590d91.tar.bz2 |
gen_index_id(): New function. Construct an index key such that the sort
is stable and the form is only defined in one place, since we do
some fancy footwork with the keys to separate the defining instance
of a module reference from other references in the HTML index.
make_index_entry(): Override the standard definition to use get_index_id().
make_str_index_entry(): Moved to myformat.perl; only needed there.
index_key_eq(): Override the standard definition. Add key transforms to
remove extra junk from the end of the keys; it was only there to
maintain ordering.
clean_key(): Remove key transform no longer needed at this stage, because
keeping it makes the sort unstable.
add_idx(): Add key transforms to undo the mess we do to separate a module's
defining and reference entries. Don't make the text bold.
-rw-r--r-- | Doc/.latex2html-init | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/Doc/.latex2html-init b/Doc/.latex2html-init index 774f3a7..749e822 100644 --- a/Doc/.latex2html-init +++ b/Doc/.latex2html-init @@ -139,24 +139,26 @@ sub bot_navigation_panel { } -# similar to make_index_entry(), but includes the string in the result -# instead of the dummy filler. -# -sub make_str_index_entry { +sub gen_index_id { + # this is used to ensure common index key generation and a stable sort + local($str,$extra) = @_; + sprintf("%s###%s%010d", $str, $extra, ++$global{'max_id'}); +} + +sub make_index_entry { local($br_id,$str) = @_; - # If TITLE is not yet available (i.e the \index command is in the title - # of the current section), use $ref_before. + # If TITLE is not yet available (i.e the \index command is in the title of the + # current section), use $ref_before. $TITLE = $ref_before unless $TITLE; # Save the reference - local($nstr) = "$str###" . ++$global{'max_id'}; # Make unique - $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id"); - "<a name=\"$br_id\">$str<\/a>"; + $str = gen_index_id($str, ''); + $index{$str} .= &make_half_href("$CURRENT_FILE#$br_id"); + "<a name=\"$br_id\">$anchor_invisible_mark<\/a>"; } sub add_idx { print "\nDoing the index ..."; - local($key, $str, @keys, $index, $level, $count, - @previous, @current); + local($key, $str, @keys, $index, $level, $count, @previous, @current); @keys = keys %index; @keys = sort keysort @keys; $level = 0; @@ -180,12 +182,12 @@ sub add_idx { $level++; } $str = $current[$#current]; - $str =~ s/\#\#\#\d+$//o; # Remove the unique id's - $index .= #$index{$key} . - # If it's the same string don't start a new line - (&index_key_eq(join('',@current), join('',@previous)) ? - ", $index{$key}" . $cross_ref_visible_mark . "</a>\n" : - "<dt>$index{$key}<strong>" . $str . "</strong></a>\n"); + $str =~ s/\#\#\#\d+$//o; # Remove the unique id's + $str =~ s/\#\#\#[DR]EF\d+$//o; # Remove the unique id's + if (&index_key_eq(join('',@current), join('',@previous))) { + $index .= ",\n$index{$key}" . $cross_ref_visible_mark . "</a>"; } + else { + $index .= "\n<dt>$index{$key}" . $str . "</a>"; } @previous = @current; } while ($count < $level) { @@ -196,12 +198,22 @@ sub add_idx { } +sub index_key_eq { + local($a,$b) = @_; + $a = &clean_key($a); + $a =~ s/\#\#\#\d+$//o; # Remove the unique id's + $a =~ s/\#\#\#[dr]ef\d+$//o; # Remove the unique id's + $b = &clean_key($b); + $b =~ s/\#\#\#\d+$//o; # Remove the unique id's + $b =~ s/\#\#\#[dr]ef\d+$//o; # Remove the unique id's + $a eq $b; +} + # need to remove leading <...> sub clean_key { local ($_) = @_; tr/A-Z/a-z/; s/\s//; - s/\#\#\#\d+$//o; # Remove the unique id s/^<[a-z][-._a-z0-9]*>//; # Remove leading <gi> $_ } |