]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/lilypond-texi2html.init
Make MF code more readable.
[lilypond.git] / Documentation / lilypond-texi2html.init
index 666aa015ac12de151f932d070fcad037d0c50d25..9635e3a41b9f206d7756ea9dd51669c43f42b586 100644 (file)
@@ -806,7 +806,7 @@ sub lilypond_element_file_name($$$)
 
     # unnumbered sections (except those at top-level!) always go to the same
     # file as the previous numbered section
-    if (not $docu_name == "web" and not ($element->{number})
+    if (not ($web_manual) and not ($element->{number})
        and not ($lastfilename eq '') and ($element->{level} > 1)) {
       $filename = $lastfilename;
     }
@@ -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
+}
 
 
 
@@ -1064,7 +1087,7 @@ push @Texi2HTML::Config::command_handler_process, \&lilypond_init_toc_depth;
 # -) the parent is a numbered element at top-level toplevel (i.e. show numbered
 #    and unnumbered 2nd-level children of numbered nodes)
 # -) the child element is a numbered node below level maxlevel
-sub generate_ly_toc_entries($$$$)
+sub generate_ly_toc_entries($$$$$)
 {
   my $element = shift;
   my $element_path = shift;
@@ -1073,6 +1096,7 @@ sub generate_ly_toc_entries($$$$)
     $maxlevel = 1;
   }
   my $child_count = shift;
+  my $current_element = shift;
   # Skip undefined sections, plus all sections generated by index splitting
   return() if (not defined($element) or exists($element->{'index_page'}));
   my @result = ();
@@ -1113,7 +1137,7 @@ sub generate_ly_toc_entries($$$$)
       my $below_maxlevel = $c->{'toc_level'} le $maxlevel;
       if ($force_children or ($is_numbered_child and $below_maxlevel)) {
         my @child_res =
-           generate_ly_toc_entries($c, $element_path, $maxlevel, $sub_child_count);
+           generate_ly_toc_entries($c, $element_path, $maxlevel, $sub_child_count, $current_element);
         push (@child_result, @child_res);
        $sub_child_count += 1;
       }
@@ -1123,7 +1147,9 @@ sub generate_ly_toc_entries($$$$)
     if (@child_result) {
       push (@result, "\n$ind<ul$NO_BULLET_LIST_ATTRIBUTE>\n");
       if ($web_manual) {
-        push (@result, "$ind<li class=\"colorDefault toc_current\">" .
+        push (@result, "$ind<li class=\"colorDefault" .
+             ($element->{'text'} eq $current_element->{'text'} ?
+              ' toc_current">' : '">') .
              &$anchor ($element->{'tocid'},
                        "$element->{'file'}#$element->{'target'}",
                        $element->{'text'}) . "</li>\n");
@@ -1177,7 +1203,7 @@ sub lilypond_generate_page_toc_body($)
     }
     my $children = $current_element->{'section_childs'};
     foreach ( @$children ) {
-      push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, 0));
+      push (@toc_entries, generate_ly_toc_entries($_, \%parentelements, $page_toc_depth, 0, $element));
     }
     # search box
     local $/=undef;
@@ -1186,7 +1212,7 @@ sub lilypond_generate_page_toc_body($)
     open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$lang/$name.ihtml" or
        open FILE, "$ENV{TOP_SRC_DIR}/Documentation/$name.ihtml"  or
        die "no such file: $name.ihtml: $!";
-    my $search_string = <FILE>;
+    my $search_string = decode ('UTF-8', <FILE>);
     $search_string = "<li>\n" . $search_string . "</li>\n";
     push (@toc_entries, $search_string);
     close FILE;
@@ -1222,9 +1248,8 @@ sub lilypond_print_toc_div ($$)
     } else {
       $lang = "";
     }
-    my $reldir = "";
-    $reldir = "../" if ($Texi2HTML::Config::SPLIT eq 'section');
-    my $uplink = $reldir."web/manuals.${lang}html";
+    my $reldir = $ENV{DEPTH};
+    my $uplink = $reldir."/Documentation/web/manuals.${lang}html";
 
     if (not $web_manual) {
       print $fh "<p class=\"toc_uplink\"><a href=\"$uplink\"