]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/lilypond-texi2html.init
Make MF code more readable.
[lilypond.git] / Documentation / lilypond-texi2html.init
index 9fb7e4096cffdf9551e31873184bbd206d18dbe4..9635e3a41b9f206d7756ea9dd51669c43f42b586 100644 (file)
@@ -879,8 +879,14 @@ sub lilypond_element_target_name($$$)
   }
   # TODO: Once texi2html correctly prints out the target and not the id for
   #       the sections, change this back to ($id, $target)
+  # I don't understand this comment, so I'm reluctant to delete it -gp
   $target = lc($target);
-  return ($target, $target);
+  if ($target eq lc($id)) {
+    $id = "";
+  } else {
+    $id = substr($id, 0, - 2); # remove the "-1"
+  }
+  return ($id, $target);
 }
 
 
@@ -976,8 +982,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 +1027,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
+}