bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(feature request) footnote formatting in makeinfo --html


From: Roger Crew
Subject: (feature request) footnote formatting in makeinfo --html
Date: Thu, 25 Jul 2024 19:55:03 -0700

So, I have issues (*) with the way footnotes are formatted in HTML info
files.  The specifics aren't that important, or rather, since these can
be deemed matters of taste, I imagine you *don't* want to do too much
beyond making sure sufficient customization hooks are available.

Now, as it happens, what I want to do is indeed possible in 7.1 with
a custom 'format_footnotes_sequence' handler.

However, since what I actually want is format *individual* footnotes,
doing it using THAT handler first requires re-parsing the footnotes
back out of a previously formatted string, which, aside from needing a
slightly hairy regexp, will be inherently fragile, i.e., if some other
custom handler/config-setting or some later makeinfo version decides
the <h5> that currently starts each footnote should change to
something else, I will lose.

It would be much better to have a 'format_single_footnote' handler that
gets invoked on each footnote.

Also, this looks like a really easy change to make.  

I've included a vague "patch" (**) below, which looks to me to be all
that's needed, but I may be wrong (read: it's not really a patch and I
haven't tested anything yet).

I'm quite happy to do an actual pull request if you'd prefer, but since
this would be a new codebase for me, I'd rather first make sure that this
is not something you've already considered and rejected for some reason.

And, also, it might be simple enough that it'll be faster for you to
Just Do It.

Details:

(*) Mainly it's about not liking the amount of vertical space taken
up.  I would like the <h5>s to go away and instead have the
number/mark be inlined into the first paragraph as is done in
plaintext info and the printed documents.  I also want to give each
footnote its own <div> to make inter-note padding/margin accessible so
that removing the <h5>s doesn't cause multi-paragraph footnotes to run
together.

(**) In the latest source, the needed changes seem to be confined to
     tp/TexInfo/Convert/HTML.pm:

 %default_formatting_references = (
...
      'format_footnotes_segment' => \&_default_format_footnotes_segment,
      'format_footnotes_sequence' => \&_default_format_footnotes_sequence,
+     'format_single_footnote' => \&_default_format_single_footnote, 
      'format_heading_text' => \&_default_format_heading_text,
      'format_navigation_header' => \&_default_format_navigation_header,
...
 );

... 

+sub _default_format_single_footnote($$$$$)
+{
+  my $self = shift;
+  my ($id, $href, $mark, $text) = @_;
+  return $self->html_attribute_class('h5', ['footnote-body-heading']) . '>'.
+     "<a id=\"$id\" href=\"$href\">($mark)</a></h5>\n" . $text;
+}

...

 sub _default_format_footnotes_sequence($)
 {
...
-  $result .= $self->html_attribute_class('h5', ['footnote-body-heading']) . 
'>'.
-     "<a id=\"$footid\" 
href=\"$footnote_location_href\">($footnote_mark)</a></h5>\n"
-     . $footnote_text;
+  $result .= &{$self->{'format_single_footnote'})}(
+     $self, $footid, "$footnote_location_href", $footnote_mark,
+     $footnote_text);
...
 }

-- 
Roger Crew
wrog@wrog.net (crew@cs.stanford.edu)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]