]> git.donarmstrong.com Git - lilypond.git/blobdiff - lilypond-texi2html.init
texi2html: Skeleton to use original target file names for translated sections
[lilypond.git] / lilypond-texi2html.init
index 29d46d54aa4fa7623c57c7bd628ff775764dadcf..eb6cd876015d2eac19e44cb3e8e35eefcc36dca0 100644 (file)
@@ -150,6 +150,170 @@ sub lilypond_external_ref($$$$$$)
 #   return t2h_default_external_ref($type, $section, $book, $file_node, $href, $cross_ref);
 }
 
+# Construct a href to an external source of information.
+# node is the node with texinfo @-commands
+# node_id is the node transliterated and transformed as explained in the
+#         texinfo manual
+# node_xhtml_id is the node transformed such that it is unique and can 
+#     be used to make an html cross ref as explained in the texinfo manual
+# file is the file in '(file)node'
+sub lilypond_external_href($$$)
+{
+    my $node = shift;
+    my $node_id = shift;
+    my $node_xhtml_id = shift;
+    my $file = shift;
+    
+    # TODO: 
+    # 1) Keep a hash of book->section_map
+    # 2) if not file in keys hash => try to load the map (assign empty map is non-existent => will load only once!)
+    # 3) if node in the section=>(file, anchor) map, replace node_id and node_xhtml_id by the map's values
+    # 4) call the t2h_default_external_href with these values (or the old ones if not found)
+print STDERR "lilypond_external_href: texi_node='$node', node_file='$node_id', node_xhtml_id='$node_xhtml_id', file='$file'\n\n";
+# 
+#     $file = '' if (!defined($file));
+#     my $default_target_split = $EXTERNAL_CROSSREF_SPLIT;
+#     my $target_split;
+#     my $target_mono;
+#     my $href_split;
+#     my $href_mono;
+#     if ($file ne '')
+#     {
+#          if ($NEW_CROSSREF_STYLE)
+#          {
+#              $file =~ s/\.[^\.]*$//;
+#              $file =~ s/^.*\///;
+#              my $href;
+#              if (exists($Texi2HTML::THISDOC{'htmlxref'}->{$file}))
+#              {
+#                   if (exists($Texi2HTML::THISDOC{'htmlxref'}->{$file}->{'split'}))
+#                   {
+#                        $target_split = 1;
+#                        $href_split =  $Texi2HTML::THISDOC{'htmlxref'}->{$file}->{'split'}->{'href'};
+#                   }
+#                   if (exists($Texi2HTML::THISDOC{'htmlxref'}->{$file}->{'mono'}))
+#                   {
+#                        $target_mono = 1;
+#                        $href_mono =  $Texi2HTML::THISDOC{'htmlxref'}->{$file}->{'mono'}->{'href'};
+#                   }
+#              }
+# 
+#              if ((not $target_mono) and (not $target_split))
+#              { # nothing specified for that manual, use default
+#                   $target_split = $default_target_split;
+#              }
+#              elsif ($target_split and $target_mono)
+#              { # depends on the splitting of the manual
+#                   $target_split = $SPLIT;
+#              }
+#              elsif ($target_mono)
+#              { # only mono specified
+#                   $target_split = 0;
+#              }
+# 
+#              if ($target_split)
+#              {
+#                   if (defined($href_split))
+#                   {
+#                        $file = "$href_split";
+#                   }
+#                   elsif (defined($EXTERNAL_DIR))
+#                   {
+#                        $file = "$EXTERNAL_DIR/$file";
+#                   }
+#                   elsif ($SPLIT)
+#                   {
+#                        $file = "../$file";
+#                   }
+#                   $file .= "/";
+#              }
+#              else
+#              {# target not split
+#                   if (defined($href_mono))
+#                   {
+#                        $file = "$href_mono";
+#                   }
+#                   else
+#                   {
+#                        if (defined($EXTERNAL_DIR))
+#                        {
+#                             $file = "$EXTERNAL_DIR/$file";
+#                        }
+#                        elsif ($SPLIT)
+#                        {
+#                            $file = "../$file";
+#                        }
+#                        $file .= "." . $NODE_FILE_EXTENSION;
+#                   }
+#              }
+#          }
+#          else
+#          {
+#              $file .= "/";
+#              if (defined($EXTERNAL_DIR))
+#              {
+#                  $file = $EXTERNAL_DIR . $file;
+#              }
+#              else
+#              {
+#                  $file = '../' . $file;
+#              } 
+#          }
+#     }
+#     else
+#     {
+#         $target_split = $default_target_split;
+#     }
+#     if ($node eq '')
+#     {
+#          if ($NEW_CROSSREF_STYLE)
+#          {
+#              if ($target_split)
+#              {
+#                  return $file . $TOP_NODE_FILE . '.' . $NODE_FILE_EXTENSION . '#Top';
+#                  # or ?
+#                  #return $file . '#Top';
+#              }
+#              else
+#              {
+#                   return $file . '#Top';
+#              }
+#          }
+#          else
+#          {
+#              return $file;
+#          }
+#     }
+#     my $target;
+#     if ($NEW_CROSSREF_STYLE)
+#     {
+#          $node = $node_id;
+#          $target = $node_xhtml_id;
+#     }
+#     else
+#     {
+#          $node = main::remove_texi($node);
+#          $node =~ s/[^\w\.\-]/-/g;
+#     }
+#     my $file_basename = $node;
+#     $file_basename = $TOP_NODE_FILE if ($node =~ /^top$/i);
+#     if ($NEW_CROSSREF_STYLE)
+#     {
+#         if ($target_split)
+#         {
+#             return $file . $file_basename . ".$NODE_FILE_EXTENSION" . '#' . $target;
+#         }
+#         else
+#         {
+#             return $file . '#' . $target;
+#         }
+#     }
+#     else
+#     {
+#         return $file . $file_basename . ".$NODE_FILE_EXTENSION";
+#     }
+  return t2h_default_external_href($node, $node_id, $node_hxmlt_id, $file);
+}
 
 
 
@@ -508,6 +672,7 @@ $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
 $Texi2HTML::Config::print_page_foot      = \&print_lilypond_page_foot;
 $Texi2HTML::Config::print_navigation     = \&lilypond_print_navigation;
 $Texi2HTML::Config::external_ref         = \&lilypond_external_ref;
+$Texi2HTML::Config::external_href         = \&lilypond_external_href;
 $Texi2HTML::Config::toc_body             = \&lilypond_toc_body;
 $Texi2HTML::Config::css_lines            = \&lilypond_css_lines;
 $Texi2HTML::Config::finish_out           = \&lilypond_finish_out;