Commit 819b789f authored by Fred Drake's avatar Fred Drake

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.
parent 84818d7a
......@@ -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>
$_
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment