From be6e6974e4a4ca5976b1b97ed13bee3421e95668 Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Fri, 22 Jan 2010 19:47:16 +0000 Subject: [PATCH] Web build: remove some unneeded # html links. Unfortunately this only applies to external_href, so the website TOC is still broken. But at least it's a step in the right direction. --- Documentation/lilypond-texi2html.init | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Documentation/lilypond-texi2html.init b/Documentation/lilypond-texi2html.init index 9fb7e4096c..bfd88624a3 100644 --- a/Documentation/lilypond-texi2html.init +++ b/Documentation/lilypond-texi2html.init @@ -976,8 +976,6 @@ sub lilypond_unknown($$$$$) } - - my %translated_books = (); # Construct a href to an external source of information. # node is the node with texinfo @-commands @@ -1023,13 +1021,32 @@ sub lilypond_external_href($$$) } if (defined $file) { - return &$default_external_href($node, $node_id, $node_hxmlt_id, lc($file)); + $href = &$default_external_href($node, $node_id, $node_hxmlt_id, lc($file)); + remove_unneeded_anchor($href); + return $href; } else { - return &$default_external_href($node, $node_id, $node_hxmlt_id); + $href = &$default_external_href($node, $node_id, $node_hxmlt_id); + remove_unneeded_anchor($href); + return $href; } } - +sub remove_unneeded_anchor($) +{ + my $ref = shift; + my @hrefsplit = split("/", $href); + for ($i = 0; $i < @hrefsplit; $i++) { + $item = @hrefsplit[$i]; + if ($item =~ /#/) { + @splitted = split("#", $item); + if (@splitted[0] == @splitted[1]) { + @hrefsplit[$i] = @splitted[0] + } + } + } + $href = join("/", @hrefsplit); + return $href +} -- 2.39.5