texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * doc/texi2any_api.tex (Customizing Footnotes), t


From: Patrice Dumas
Subject: branch master updated: * doc/texi2any_api.tex (Customizing Footnotes), tp/Texinfo/Convert/HTML.pm (_default_format_single_footnote) (_default_format_footnotes_sequence), tp/Texinfo/XS/convert/call_html_perl_function.c (call_formatting_function_format_single_footnote), tp/Texinfo/XS/convert/convert_html.c (html_default_format_single_footnote, format_single_footnote) (html_default_format_footnotes_sequence): format the footnote text in format_single_footnote. Remove footnote_text argument of default_format_single [...]
Date: Sat, 27 Jul 2024 07:43:47 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 056d518faa * doc/texi2any_api.tex (Customizing Footnotes), 
tp/Texinfo/Convert/HTML.pm (_default_format_single_footnote) 
(_default_format_footnotes_sequence), 
tp/Texinfo/XS/convert/call_html_perl_function.c 
(call_formatting_function_format_single_footnote), 
tp/Texinfo/XS/convert/convert_html.c (html_default_format_single_footnote, 
format_single_footnote) (html_default_format_footnotes_sequence): format the 
footnote text in format_single_footnote.  Remove footnote_text argument of  
[...]
056d518faa is described below

commit 056d518faac6d799ca3f461d8849045da927abfb
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jul 27 13:43:38 2024 +0200

    * doc/texi2any_api.tex (Customizing Footnotes),
    tp/Texinfo/Convert/HTML.pm (_default_format_single_footnote)
    (_default_format_footnotes_sequence),
    tp/Texinfo/XS/convert/call_html_perl_function.c
    (call_formatting_function_format_single_footnote),
    tp/Texinfo/XS/convert/convert_html.c
    (html_default_format_single_footnote, format_single_footnote)
    (html_default_format_footnotes_sequence): format the footnote text in
    format_single_footnote.  Remove footnote_text argument of
    default_format_single_footnote, add the footnote element and
    number_in_doc.
---
 ChangeLog                                       | 14 +++++
 doc/texi2any_api.texi                           | 11 ++--
 tp/Texinfo/Convert/HTML.pm                      | 38 ++++++------
 tp/Texinfo/XS/convert/call_html_perl_function.c | 11 ++--
 tp/Texinfo/XS/convert/call_html_perl_function.h |  8 +--
 tp/Texinfo/XS/convert/convert_html.c            | 78 +++++++++++++------------
 6 files changed, 92 insertions(+), 68 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3d879f1e39..ac7c59878e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-07-27  Patrice Dumas  <pertusus@free.fr>
+
+       * doc/texi2any_api.tex (Customizing Footnotes),
+       tp/Texinfo/Convert/HTML.pm (_default_format_single_footnote)
+       (_default_format_footnotes_sequence),
+       tp/Texinfo/XS/convert/call_html_perl_function.c
+       (call_formatting_function_format_single_footnote),
+       tp/Texinfo/XS/convert/convert_html.c
+       (html_default_format_single_footnote, format_single_footnote)
+       (html_default_format_footnotes_sequence): format the footnote text in
+       format_single_footnote.  Remove footnote_text argument of
+       default_format_single_footnote, add the footnote element and
+       number_in_doc.
+
 2024-07-26  Patrice Dumas  <pertusus@free.fr>
 
        Add format_single_footnote formatting reference for a single footnote
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index d54c461841..e9cd961cbb 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -4132,7 +4132,7 @@ functions formatting their argument elsewhere, two 
functions are available:
 
 @defun @var{$converter}->register_footnote (\%element, $footnote_id, @
   $foot_in_doc_id, $number_in_doc, $footnote_location_filename, 
$multi_expanded_region)
-@var{\%element} is the footnote texinfo tree element. @var{$footnote_id} is the
+@var{\%element} is the footnote Texinfo tree element. @var{$footnote_id} is the
 identifier for the location where the footnote arguments are expanded.
 @var{$foot_in_doc_id} is the identifier for the location where the footnote
 appears in the document.  @var{$number_in_doc} is the number of the footnote
@@ -4171,14 +4171,15 @@ The formatting of one footnote is done by the 
@code{format_single_footnote}
 formatting reference:
 
 @deftypefn {Function Reference} @var{$footnote} format_single_footnote @
-  (@var{$converter}, @var{$footnote_id}, @var{$footnote_location_href}, @
-   @var{$footnote_mark}, @var{$footnote_text})
+  (@var{$converter}, @var{\%element}, @var{$footnote_id}, 
@var{$number_in_doc}, @
+   @var{$footnote_location_href}, @var{$footnote_mark})
 Formats and returns a single footnote.
-@var{$footnote_id} is the
+@var{\%element} is the footnote Texinfo tree element. @var{$footnote_id} is the
 identifier for the location where the footnote arguments are expanded.
+@var{$number_in_doc} is the number of the footnote
+in the document.
 @var{$footnote_location_href} is the href that links to the footnote location
 in the main document.  @var{$footnote_mark} is the footnote number or mark.
-Lastly, @var{$footnote_text} is the formatted footnote argument.
 @end deftypefn
 
 If footnotes are in a separate output unit (@pxref{Output Units}), the
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index f4aa2d93ce..f9abd8aa40 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -11467,12 +11467,18 @@ $after_body_open
   return $result;
 }
 
-sub _default_format_single_footnote($$$$$)
+sub _default_format_single_footnote($$$$$$)
 {
   my $self = shift;
-  my ($id, $href, $mark, $text) = @_;
+  my ($command, $footid, $number_in_doc, $href, $mark) = @_;
+  my $footnote_text
+      = $self->convert_tree_new_formatting_context($command->{'args'}->[0],
+                            "$command->{'cmdname'} $number_in_doc $footid");
+  chomp ($footnote_text);
+  $footnote_text .= "\n";
+
   return $self->html_attribute_class('h5', ['footnote-body-heading']) . '>'.
-     "<a id=\"$id\" href=\"$href\">($mark)</a></h5>\n" . $text;
+     "<a id=\"$footid\" href=\"$href\">($mark)</a></h5>\n" . $footnote_text;
 }
 
 sub _default_format_footnotes_sequence($)
@@ -11487,6 +11493,15 @@ sub _default_format_footnotes_sequence($)
           = @$pending_footnote_info_array;
     my $footnote_location_href = $self->footnote_location_href($command, undef,
                                            $docid, 
$footnote_location_filename);
+
+    my $footnote_mark;
+    if ($self->get_conf('NUMBER_FOOTNOTES')) {
+      $footnote_mark = $number_in_doc;
+    } else {
+      $footnote_mark = $self->get_conf('NO_NUMBER_FOOTNOTE_SYMBOL');
+      $footnote_mark = '' if (!defined($footnote_mark));
+    }
+
     # NOTE the @-commands in @footnote that are formatted differently depending
     # on in_multi_expanded($self) cannot know that the original context
     # of the @footnote in the main document was $multi_expanded_region.
@@ -11497,23 +11512,10 @@ sub _default_format_footnotes_sequence($)
     # with those @-commands in @footnote in multi expanded
     # region do not justify this additional code and complexity.  The 
consequences
     # should only be redundant anchors HTML elements.
-    my $footnote_text
-        = $self->convert_tree_new_formatting_context($command->{'args'}->[0],
-                              "$command->{'cmdname'} $number_in_doc $footid");
-    chomp ($footnote_text);
-    $footnote_text .= "\n";
-
-    my $footnote_mark;
-    if ($self->get_conf('NUMBER_FOOTNOTES')) {
-      $footnote_mark = $number_in_doc;
-    } else {
-      $footnote_mark = $self->get_conf('NO_NUMBER_FOOTNOTE_SYMBOL');
-      $footnote_mark = '' if (!defined($footnote_mark));
-    }
 
     $result .= &{$self->formatting_function('format_single_footnote')}($self,
-                            $footid, $footnote_location_href, $footnote_mark,
-                                                              $footnote_text);
+                                           $command, $footid, $number_in_doc,
+                                     $footnote_location_href, $footnote_mark);
   }
   return $result;
 }
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c 
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index 74b911abb4..0213e16b6c 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -856,10 +856,10 @@ call_formatting_function_format_footnotes_segment 
(CONVERTER *self,
 
 char *
 call_formatting_function_format_single_footnote (CONVERTER *self,
-                                                 const char *footid,
-                        const char *footnote_location_href, const char *mark,
-                        const char *footnote_text,
-                        const FORMATTING_REFERENCE *formatting_reference)
+                        const FORMATTING_REFERENCE *formatting_reference,
+                        const ELEMENT *element, const char *footid,
+                        int number_in_doc,
+                        const char *footnote_location_href, const char *mark)
 {
   int count;
   char *result;
@@ -887,10 +887,11 @@ call_formatting_function_format_single_footnote 
(CONVERTER *self,
   EXTEND(SP, 1);
 
   PUSHs(sv_2mortal (newRV_inc (self->hv)));
+  PUSHs(sv_2mortal (newRV_inc (element->hv)));
   PUSHs(sv_2mortal (newSVpv_utf8 (footid, 0)));
+  PUSHs(sv_2mortal (newSViv ((IV) number_in_doc)));
   PUSHs(sv_2mortal (newSVpv_utf8 (footnote_location_href, 0)));
   PUSHs(sv_2mortal (newSVpv_utf8 (mark, 0)));
-  PUSHs(sv_2mortal (newSVpv_utf8 (footnote_text, 0)));
   PUTBACK;
 
   count = call_sv (formatting_reference_sv,
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.h 
b/tp/Texinfo/XS/convert/call_html_perl_function.h
index ff2e73be14..47626012a8 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.h
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.h
@@ -53,10 +53,10 @@ char *call_formatting_function_format_protect_text 
(CONVERTER *self,
 char *call_formatting_function_format_footnotes_segment (CONVERTER *self,
                          const FORMATTING_REFERENCE *formatting_reference);
 char *call_formatting_function_format_single_footnote (CONVERTER *self,
-                                                       const char *footid,
-                         const char *footnote_location_href, const char *mark,
-                         const char *footnote_text,
-                         const FORMATTING_REFERENCE *formatting_reference);
+                        const FORMATTING_REFERENCE *formatting_reference,
+                        const ELEMENT *element, const char *footid,
+                        int number_in_doc,
+                        const char *footnote_location_href, const char *mark);
 char *call_formatting_function_format_footnotes_sequence (CONVERTER *self,
                          const FORMATTING_REFERENCE *formatting_reference);
 char *call_formatting_function_format_css_lines (CONVERTER *self,
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 34e9de3d77..890a985571 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -1083,7 +1083,7 @@ special_unit_info (const CONVERTER *self, enum 
special_unit_info_type type,
 
 void
 html_register_footnote (CONVERTER *self, const ELEMENT *command,
-     const char *footid, const char *docid, const int number_in_doc,
+     const char *footid, const char *docid, int number_in_doc,
      const char *footnote_location_filename, const char *multi_expanded_region)
 {
   HTML_PENDING_FOOTNOTE_STACK *stack;
@@ -6412,11 +6412,33 @@ static const STRING_LIST foot_body_heading_classes
    = {foot_body_heading_array, 1, 1};
 
 void
-html_default_format_single_footnote (CONVERTER *self, const char *footid,
+html_default_format_single_footnote (CONVERTER *self, const ELEMENT *element,
+                    const char *footid, int number_in_doc,
                     const char *footnote_location_href, const char *mark,
-                    const char *footnote_text, TEXT *result)
+                    TEXT *result)
 {
   char *attribute_class;
+  size_t footnote_text_len;
+  char *footnote_text;
+  char *context_str;
+  char *footnote_text_with_eol;
+
+  xasprintf (&context_str, "%s %d %s", element_command_name (element),
+                           number_in_doc, footid);
+  footnote_text
+    = convert_tree_new_formatting_context (self, element->args.list[0],
+                                                 context_str, 0, 0, 0);
+  free (context_str);
+
+  footnote_text_len = strlen (footnote_text);
+  if (footnote_text_len <= 0
+      || footnote_text[footnote_text_len -1] != '\n')
+    {
+      xasprintf (&footnote_text_with_eol, "%s\n", footnote_text);
+      free (footnote_text);
+    }
+  else
+    footnote_text_with_eol = footnote_text;
 
   attribute_class = html_attribute_class (self, "h5",
                     &foot_body_heading_classes);
@@ -6426,29 +6448,32 @@ html_default_format_single_footnote (CONVERTER *self, 
const char *footid,
   text_printf (result, "><a id=\"%s\" href=\"%s\">(%s)</a></h5>\n",
                footid, footnote_location_href, mark);
 
-  text_append (result, footnote_text);
+  text_append (result, footnote_text_with_eol);
+  free (footnote_text_with_eol);
 }
 
 void
-format_single_footnote (CONVERTER *self, const char *footid,
+format_single_footnote (CONVERTER *self, const ELEMENT *element,
+                        const char *footid, int number_in_doc,
                         const char *footnote_location_href, const char *mark,
-                        const char *footnote_text, TEXT *result)
+                        TEXT *result)
 {
   const FORMATTING_REFERENCE *formatting_reference
    = &self->current_formatting_references[FR_format_single_footnote];
   if (formatting_reference->status == FRS_status_default_set)
     {
-      html_default_format_single_footnote (self, footid,
-                                   footnote_location_href, mark,
-                                   footnote_text, result);
+      html_default_format_single_footnote (self, element, footid,
+                                   number_in_doc, footnote_location_href,
+                                   mark, result);
     }
   else
     {
       char *footnote
-        = call_formatting_function_format_single_footnote (self, footid,
-                                           footnote_location_href, mark,
-                                                footnote_text,
-                                                formatting_reference);
+        = call_formatting_function_format_single_footnote (self,
+                                   formatting_reference, element, footid,
+                                   number_in_doc, footnote_location_href, 
+                                   mark);
+
       text_append (result, footnote);
       free (footnote);
     }
@@ -6470,10 +6495,6 @@ html_default_format_footnotes_sequence (CONVERTER *self, 
TEXT *result)
           const ELEMENT *command = pending_footnote_info->command;
           const char *footid = pending_footnote_info->footid;
           int number_in_doc = pending_footnote_info->number_in_doc;
-          size_t footnote_text_len;
-          char *footnote_text;
-          char *context_str;
-          char *footnote_text_with_eol;
           char *footnote_mark;
           char *footnote_location_href
            = html_footnote_location_href (self, command, 0,
@@ -6491,23 +6512,6 @@ html_default_format_footnotes_sequence (CONVERTER *self, 
TEXT *result)
       region do not justify this additional code and complexity.  The 
consequences
       should only be redundant anchors HTML elements.
     */
-          xasprintf (&context_str, "%s %d %s", element_command_name (command),
-                                   number_in_doc, footid);
-          footnote_text
-            = convert_tree_new_formatting_context (self, command->args.list[0],
-                                                         context_str, 0, 0, 0);
-          free (context_str);
-
-          footnote_text_len = strlen (footnote_text);
-          if (footnote_text_len <= 0
-              || footnote_text[footnote_text_len -1] != '\n')
-            {
-              xasprintf (&footnote_text_with_eol, "%s\n", footnote_text);
-              free (footnote_text);
-            }
-          else
-            footnote_text_with_eol = footnote_text;
-
           if (self->conf->NUMBER_FOOTNOTES.o.integer > 0)
             xasprintf (&footnote_mark, "%d", number_in_doc);
           else if (self->conf->NO_NUMBER_FOOTNOTE_SYMBOL.o.string)
@@ -6516,9 +6520,11 @@ html_default_format_footnotes_sequence (CONVERTER *self, 
TEXT *result)
           else
             footnote_mark = strdup ("");
 
-          format_single_footnote (self, footid, footnote_location_href,
-                                  footnote_mark, footnote_text_with_eol,
+          format_single_footnote (self, command, footid, number_in_doc,
+                                  footnote_location_href, footnote_mark,
                                   result);
+
+          free (footnote_mark);
         }
     }
   destroy_pending_footnotes (pending_footnotes);



reply via email to

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