]> git.donarmstrong.com Git - lilypond.git/commitdiff
texi2html: Better footnote handling
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 24 Aug 2008 14:26:00 +0000 (16:26 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 24 Aug 2008 14:33:46 +0000 (16:33 +0200)
-) Insert footnotes on the page where they appear in the text, not in a separate file

-) Use <p><sup>nr</sup> text</p> format rather than the ugly texi2html default.

lilypond-texi2html.init

index 28fb2f9ef8d2c86200e35adfc99ae9452b499aef..08af1b05b0e60060ee9abfaf16b53f86083af78d 100644 (file)
@@ -47,6 +47,9 @@
 ### -) The HTML anchors for all sections are derived from the node name /
 ###    section title (pre-generated in the .xref-map file). Implemented by:
 ###           split_at_numbered_sections (adjust section anchors)
+### -) Use the standard footnote format "<sup>nr</sup> text" instead of the
+###    ugly format of texi2html (<h3>(nr)</h3><p>text</p>). Implemented in
+###           lilypond_foot_line_and_ref
 ###
 ###
 ### Useful helper functions:
@@ -70,6 +73,7 @@ package Texi2HTML::Config;
 $Texi2HTML::Config::USE_ACCESSKEY = 1;
 $Texi2HTML::Config::USE_LINKS     = 1;
 $Texi2HTML::Config::USE_REL_REV   = 1;
+$Texi2HTML::Config::SEPARATED_FOOTNOTES = 0; # Print footnotes on same page, not separated
 $Texi2HTML::Config::element_file_name    = \&split_at_numbered_sections;
 $Texi2HTML::Config::print_element_header = \&lilypond_print_element_header;
 $Texi2HTML::Config::print_page_foot      = \&print_lilypond_page_foot;
@@ -80,6 +84,7 @@ $Texi2HTML::Config::toc_body             = \&lilypond_toc_body;
 $Texi2HTML::Config::css_lines            = \&lilypond_css_lines;
 $Texi2HTML::Config::unknown              = \&lilypond_unknown;
 $Texi2HTML::Config::print_page_head      = \&lilypond_print_page_head;
+$Texi2HTML::Config::foot_line_and_ref    = \&lilypond_foot_line_and_ref;
 
 # Examples should be formatted similar to quotes:
 $Texi2HTML::Config::complex_format_map->{'example'} = {
@@ -852,6 +857,46 @@ sub lilypond_print_navigation
 
 
 
+#############################################################################
+###  FOOTNOTE FORMATTING
+#############################################################################
+
+# Format footnotes in a nicer way: Instead of printing the number in a separate
+# (nr) heading line, use the standard way of prepending <sup>nr</sup> immediately
+# before the fn text.
+sub lilypond_foot_line_and_ref($$$$$$$)
+{
+    my $number_in_doc = shift;
+    my $number_in_page = shift;
+    my $footnote_id = shift;
+    my $place_id = shift;
+    my $document_file = shift;
+    my $footnote_file = shift;
+    my $lines = shift;
+    my $state = shift;
+
+    if ($document_file eq $footnote_file)
+    {
+        $document_file = $footnote_file = '';
+    }
+    # FN number printed before the fn text:
+    my $tmptxt =  &$anchor($footnote_id, $document_file . "#$place_id",
+                   "<sup>$number_in_doc</sup>");
+    # unfortunately, the @$lines contain the already formatted footnote in the
+    # from <p>...</p>. This means that we have to modify this string and
+    # insert the FN number manually. The default (nr) on a separate line before
+    # the FN text is just plain ugly:
+    $lines->[0] =~ s/^<p>/<p>$tmptxt /;
+    # this is a bit obscure, this allows to add an anchor only if formatted
+    # as part of the document.
+    $place_id = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});
+    # return FN lines and text to be inserted in the running text (link to FN)
+    return ($lines, &$anchor($place_id,  $footnote_file . "#$footnote_id",
+           "<sup>$number_in_doc</sup>"));
+}
+
+
+
 #############################################################################
 ###  OTHER SETTINGS
 #############################################################################