From: Reinhold Kainhofer Date: Mon, 7 Jul 2008 15:16:07 +0000 (+0200) Subject: texi2html: Create tab-separated file containing the NODE<=>FILENAME map X-Git-Tag: release/2.11.58-1~32^2~128 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a8c01b16507985f43cc76b5f0138833a373ec7c9;p=lilypond.git texi2html: Create tab-separated file containing the NODE<=>FILENAME map 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... --- diff --git a/lilypond-texi2html.init b/lilypond-texi2html.init index 6ca04c3cfc..29d46d54aa 100644 --- a/lilypond-texi2html.init +++ b/lilypond-texi2html.init @@ -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!