]> git.donarmstrong.com Git - lilypond.git/commitdiff
texi2html: Create tab-separated file containing the NODE<=>FILENAME map
authorReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 7 Jul 2008 15:16:07 +0000 (17:16 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 7 Jul 2008 15:16:07 +0000 (17:16 +0200)
For each main html file, I now write out the map of filename<=>nodename
associations to the file basename_xref.map (where basename is e.g. index).
This file contains tab-separated lines of the form

NODENAME\tFILENAME\tANCHOR_IN_FILE

In the future, this association will be used by the other files to
properly resolve external references. Of course, this will require processing
each texi file twice...

lilypond-texi2html.init

index 6ca04c3cfc9cf4266bc01b816929a814e8d540a3..29d46d54aa4fa7623c57c7bd628ff775764dadcf 100644 (file)
@@ -6,6 +6,7 @@ my $lastfilename;
 my $docnr = 0;
 my $page_toc_depth = 2;
 my @default_toc = [];
+my @section_to_filename;
 
 use Data::Dumper;
 $Data::Dumper::Maxdepth = 2;
@@ -84,7 +85,8 @@ sub split_at_numbered_sections($$$)
   } else {
     # derive the name of the anchor (i.e. the part after # in the links!), 
     # don't use texi2html's SECx.x default!
-    my $anchor = main::remove_texi($$element{texi});
+    my $sec_name = main::remove_texi($$element{texi});
+    my $anchor = $sec_name;
     if ($$element{translationof}) {
       $anchor = main::remove_texi($$element{translationof});
     }
@@ -99,9 +101,11 @@ sub split_at_numbered_sections($$$)
       $docnr += 1;
       $$element{doc_nr} = $docnr;
       $lastfilename = $filename;
+      push (@section_to_filename, [$sec_name, $filename, $anchor]);
       return $filename;
     } else {
       $$element{doc_nr} = $docnr;
+      push (@section_to_filename, [$sec_name, $lastfilename, $anchor]);
       return $lastfilename;
     }
   }
@@ -109,6 +113,20 @@ sub split_at_numbered_sections($$$)
   return;
 }
 
+sub lilypond_finish_out()
+{
+  my $map_filename = "$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'file_base_name'}_xref.map";
+  if (open(XREFFILE, ">$map_filename")) {
+    foreach (@section_to_filename) {
+      my ($sec, $file, $anchor) = @$_;
+      print XREFFILE "$sec\t$file\t$anchor\n";
+    }
+    close XREFFILE;
+  } else {
+    print "Can't open $map_filename for writing: $! The map of X-refs will not be written out\n";
+  }
+}
+
 
 
 # The default formatting of external refs returns e.g. 
@@ -492,6 +510,7 @@ $Texi2HTML::Config::print_navigation     = \&lilypond_print_navigation;
 $Texi2HTML::Config::external_ref         = \&lilypond_external_ref;
 $Texi2HTML::Config::toc_body             = \&lilypond_toc_body;
 $Texi2HTML::Config::css_lines            = \&lilypond_css_lines;
+$Texi2HTML::Config::finish_out           = \&lilypond_finish_out;
 
 
 # For split pages, use index(.lang).html as start page!