my ( $xml, $prepend_chapter, $xref ) = @_;
my $index_hash = {};
+ my $seealso_hash = {};
my $current_id;
foreach my $node ( $xml->findnodes('//section | //chapter | //indexterm') ) {
if ( $node->nodeName eq 'indexterm' ) {
my $primary = $node->findvalue('child::primary');
my $first = ( $primary =~ /^[A-Za-z]/ ) ? uc( substr( $primary, 0, 1 ) ) : ''; # first letter or marker
my $secondary = $node->findvalue('child::secondary') || '';
+ my $see = $node->findvalue('child::see');
+ my $see_also = $node->findvalue('child::seealso');
+
next unless ( $primary || $secondary ); # skip blank entries for now...
+
$index_hash->{$role}{$first}{$primary}{$secondary} ||= [];
- push @{ $index_hash->{$role}{$first}{$primary}{$secondary} }, $current_id;
+ if ( $see || $see_also ) {
+ # The scalar value being written here assumes only one seealso on an indeed term
+ # It would be nice to have the $see displayed in bold rather than in quotes
+ $seealso_hash->{$role}{$first}{$primary}{$secondary} = 'see "' . $see .'"' if ($see);
+ $seealso_hash->{$role}{$first}{$primary}{$secondary} = 'see also "' . $see_also .'"' if ($see_also);
+ }
+
+ else {
+# JGH 2022/07/01
+# The $current_id being pushed here is presumably the section, given where the
+# hyperlink end up pointing to. For bug 2889 we'd like to have something more
+# precise; tha presumably requires an anchor at the indexed point?
+
+ push @{ $index_hash->{$role}{$first}{$primary}{$secondary} }, $current_id;
+ }
}
else {
$current_id = $node->getAttribute('id');
$slist->appendChild($sentry)->appendTextChild( 'term', $secondary );
$sentry->appendChild($sitem)->appendChild($para);
}
+
+ my $seealso = $seealso_hash->{$role}{$first}{$primary}{$secondary};
+ $para->appendText($seealso) if ($seealso);
+
my $count = 0;
foreach my $ref ( @{ $index_hash->{$role}{$first}{$primary}{$secondary} } ) {
$para->appendText(', ')