texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/HTML.pm (_default_format_ele


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_default_format_element_footer): rearrange code for rules. Make a condition clearer.
Date: Fri, 05 Jan 2024 08:47:51 -0500

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 12272d5a7b * tp/Texinfo/Convert/HTML.pm 
(_default_format_element_footer): rearrange code for rules.  Make a condition 
clearer.
12272d5a7b is described below

commit 12272d5a7b359bbad33983dad362030ef48fb6bc
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Jan 5 14:47:48 2024 +0100

    * tp/Texinfo/Convert/HTML.pm (_default_format_element_footer):
    rearrange code for rules.  Make a condition clearer.
    
    * tp/Texinfo/XS/convert/call_html_perl_function.c
    (call_formatting_function_format_element_footer): make element
    argument const.
    
    * tp/Texinfo/XS/convert/convert_html.c: move functions round.
    
    * tp/Texinfo/XS/convert/convert_html.c (word_number_more_than_level)
    (html_default_format_element_footer, format_element_footer): implement
    html_default_format_element_footer.
---
 ChangeLog                                       |  15 +
 tp/Texinfo/Convert/HTML.pm                      |  29 +-
 tp/Texinfo/XS/convert/call_html_perl_function.c |   2 +-
 tp/Texinfo/XS/convert/call_html_perl_function.h |   2 +-
 tp/Texinfo/XS/convert/convert_html.c            | 543 ++++++++++++++++--------
 5 files changed, 393 insertions(+), 198 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5ce3316a7f..6d2d24f514 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-01-05  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_default_format_element_footer):
+       rearrange code for rules.  Make a condition clearer.
+
+       * tp/Texinfo/XS/convert/call_html_perl_function.c
+       (call_formatting_function_format_element_footer): make element
+       argument const.
+
+       * tp/Texinfo/XS/convert/convert_html.c: move functions round.
+
+       * tp/Texinfo/XS/convert/convert_html.c (word_number_more_than_level)
+       (html_default_format_element_footer, format_element_footer): implement
+       html_default_format_element_footer.
+
 2024-01-05  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/convert_html.c
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 24cf69ca36..5e5f275f54 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -7945,7 +7945,6 @@ sub _default_format_element_footer($$$$;$)
 </table>"."\n";
   }
 
-  my $rule = '';
   my $buttons;
 
   if ($end_page) {
@@ -7954,7 +7953,7 @@ sub _default_format_element_footer($$$$;$)
 
     # setup buttons for navigation footer
     if (($is_top or $is_special)
-        and ($self->get_conf('SPLIT') or !$self->get_conf('MONOLITHIC'))
+        and ($self->get_conf('SPLIT') ne '' or !$self->get_conf('MONOLITHIC'))
         and (($self->get_conf('HEADERS')
               or ($self->get_conf('SPLIT')
                   and $self->get_conf('SPLIT') ne 'node')))) {
@@ -7998,21 +7997,21 @@ sub _default_format_element_footer($$$$;$)
     $result .= 
&{$self->formatting_function('format_footnotes_segment')}($self);
   }
 
-  if (!$buttons or $is_top or $is_special
-     or ($end_page and ($self->get_conf('SPLIT') eq 'chapter'
-                       or $self->get_conf('SPLIT') eq 'section'))
-     or ($self->get_conf('SPLIT') eq 'node' and $self->get_conf('HEADERS'))) {
-    $rule = $self->get_conf('DEFAULT_RULE');
-  }
-
-  if (!$end_page and ($is_top or $next_is_top or ($next_is_special
-                                                  and !$is_special))) {
-    $rule = $self->get_conf('BIG_RULE');
-  }
-
   if ($buttons or !$end_page or $self->get_conf('PROGRAM_NAME_IN_FOOTER')) {
-    $result .= "$rule\n" if ($rule);
+    my $rule;
+    if (!$end_page and ($is_top or $next_is_top or ($next_is_special
+                                                    and !$is_special))) {
+      $rule = $self->get_conf('BIG_RULE');
+    } elsif (!$buttons or $is_top or $is_special
+             or ($end_page and ($self->get_conf('SPLIT') eq 'chapter'
+                                 or $self->get_conf('SPLIT') eq 'section'))
+             or ($self->get_conf('SPLIT') eq 'node'
+                 and $self->get_conf('HEADERS'))) {
+      $rule = $self->get_conf('DEFAULT_RULE');
+    }
+    $result .= "$rule\n" if (defined($rule) and $rule ne '');
   }
+
   if ($buttons) {
     my $cmdname;
     $cmdname = $command->{'cmdname'} if ($command and $command->{'cmdname'});
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c 
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index 720737dc5b..9161837549 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -1835,7 +1835,7 @@ call_formatting_function_format_element_footer (CONVERTER 
*self,
                          const FORMATTING_REFERENCE *formatting_reference,
                               const enum output_unit_type unit_type,
                               const OUTPUT_UNIT *output_unit,
-                              const char *content, ELEMENT *command)
+                              const char *content, const ELEMENT *command)
 {
   int count;
   char *result = 0;
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.h 
b/tp/Texinfo/XS/convert/call_html_perl_function.h
index f38f3224d7..d4922ec67f 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.h
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.h
@@ -124,7 +124,7 @@ char *call_formatting_function_format_element_footer 
(CONVERTER *self,
                          const FORMATTING_REFERENCE *formatting_reference,
                               const enum output_unit_type unit_type,
                               const OUTPUT_UNIT *output_unit,
-                              const char *content, ELEMENT *command);
+                              const char *content, const ELEMENT *command);
 
 void call_types_conversion (CONVERTER *self, const enum element_type type,
                        const FORMATTING_REFERENCE *formatting_reference,
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 6dfab626e2..57565722dd 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -6116,33 +6116,205 @@ format_heading_text (CONVERTER *self, const enum 
command_id cmd,
     }
 }
 
+static char *foot_body_heading_array[] = {"footnote-body-heading"};
+static const STRING_LIST foot_body_heading_classes
+   = {foot_body_heading_array, 1, 1};
+
 void
-format_element_footer (CONVERTER *self,
-                              const enum output_unit_type unit_type,
-                              const OUTPUT_UNIT *output_unit,
-                              const char *content, ELEMENT *element,
-                              TEXT *result)
+html_default_format_footnotes_sequence (CONVERTER *self, TEXT *result)
+{
+  size_t i;
+  HTML_PENDING_FOOTNOTE_STACK *pending_footnotes
+   = html_get_pending_footnotes (self);
+
+  if (pending_footnotes->top > 0)
+    {
+      for (i = 0; i < pending_footnotes->top; i++)
+        {
+          const HTML_PENDING_FOOTNOTE *pending_footnote_info
+           = pending_footnotes->stack[i];
+          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 *attribute_class;
+          char *footnote_mark;
+          char *footnote_location_href
+           = html_footnote_location_href (self, command, 0,
+                                     pending_footnote_info->docid,
+                    pending_footnote_info->footnote_location_filename);
+   /*
+      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.
+      We do not want to set multi_expanded in customizable code.  However, it
+      could be possible to set a shared_conversion_state based on 
$multi_expanded_region
+      and have all the conversion functions calling in_multi_expanded($self)
+      also check the shared_conversion_state.  The special situations
+      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.
+    */
+          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.integer > 0)
+            xasprintf (&footnote_mark, "%d", number_in_doc);
+          else
+            footnote_mark
+              = strdup (self->conf->NO_NUMBER_FOOTNOTE_SYMBOL.string);
+
+          attribute_class = html_attribute_class (self, "h5",
+                            &foot_body_heading_classes);
+          text_append (result, attribute_class);
+          free (attribute_class);
+
+          text_printf (result, "><a id=\"%s\" href=\"%s\">(%s)</a></h5>\n",
+                       footid, footnote_location_href, footnote_mark);
+
+          free (footnote_mark);
+          free (footnote_location_href);
+
+          text_append (result, footnote_text_with_eol);
+          free (footnote_text_with_eol);
+        }
+    }
+  destroy_pending_footnotes (pending_footnotes);
+}
+
+void
+format_footnotes_sequence (CONVERTER *self, TEXT *result)
 {
   FORMATTING_REFERENCE *formatting_reference
-   = &self->current_formatting_references[FR_format_element_footer];
+   = &self->current_formatting_references[FR_format_footnotes_sequence];
+  if (formatting_reference->status == FRS_status_default_set)
+    {
+      html_default_format_footnotes_sequence (self, result);
+    }
+  else
+    {
+      char *footnotes_sequence
+        = call_formatting_function_format_footnotes_sequence (self,
+                                                formatting_reference);
+      text_append (result, footnotes_sequence);
+      free (footnotes_sequence);
+    }
+}
 
-/*
+void
+default_format_footnotes_segment (CONVERTER *self, TEXT *result)
+{
+  char *class_base;
+  char *attribute_class;
+  char *class;
+  STRING_LIST *classes;
+  ELEMENT *footnote_heading_tree;
+  char *footnote_heading;
+  int level;
+  TEXT foot_lines;
+
+  text_init (&foot_lines);
+  format_footnotes_sequence (self, &foot_lines);
+
+  if (foot_lines.end <= 0)
+    {
+      free (foot_lines.text);
+      return;
+    }
+
+  classes = (STRING_LIST *) malloc (sizeof (STRING_LIST));
+  memset (classes, 0, sizeof (STRING_LIST));
+
+  class_base = special_unit_info (self, SUI_type_class,
+                                  "footnotes");
+  xasprintf (&class, "%s-segment", class_base);
+
+  add_string (class, classes);
+  free (class);
+  attribute_class = html_attribute_class (self, "div", classes);
+  clear_strings_list (classes);
+
+  text_append (result, attribute_class);
+  free (attribute_class);
+
+  text_append_n (result, ">\n", 2);
+
+  if (self->conf->DEFAULT_RULE.string
+      && strlen (self->conf->DEFAULT_RULE.string))
+    {
+      text_append (result, self->conf->DEFAULT_RULE.string);
+      text_append_n (result, "\n", 1);
+    }
+
+  footnote_heading_tree = special_unit_info_tree (self,
+                              SUIT_type_heading, "footnotes");
+  if (footnote_heading_tree)
+    {
+      footnote_heading = html_convert_tree (self, footnote_heading_tree,
+                                    "convert footnotes special heading");
+    }
+  else
+    {
+      footnote_heading = "";
+    }
+
+  level = self->conf->FOOTNOTE_END_HEADER_LEVEL.integer;
+
+  xasprintf (&class, "%s-heading", class_base);
+
+  add_string (class, classes);
+  free (class);
+
+  format_heading_text (self, 0, classes, footnote_heading, level, 0, 0, 0,
+                       result);
+  destroy_strings_list (classes);
+  text_append_n (result, "\n", 1);
+
+  if (footnote_heading_tree)
+    free (footnote_heading);
+
+  text_append (result, foot_lines.text);
+  free (foot_lines.text);
+  text_append (result, "</div>\n");
+}
+
+void
+format_footnotes_segment (CONVERTER *self, TEXT *result)
+{
+  FORMATTING_REFERENCE *formatting_reference
+   = &self->current_formatting_references[FR_format_footnotes_segment];
   if (formatting_reference->status == FRS_status_default_set)
     {
-      html_default_format_element_footer (self, unit_type, output_unit,
-                                          content, element, result);
+      default_format_footnotes_segment (self, result);
     }
   else
-*/
-   {
-     char *formatted_footer
-       = call_formatting_function_format_element_footer (self,
-                                         formatting_reference,
-                                         unit_type,
-                                         output_unit, content, element);
-     text_append (result, formatted_footer);
-     free (formatted_footer);
-   }
+    {
+      char *footnotes_segment
+        = call_formatting_function_format_footnotes_segment (self,
+                                             formatting_reference);
+      if (footnotes_segment)
+        {
+          text_append (result, footnotes_segment);
+          free (footnotes_segment);
+        }
+    }
 }
 
 void
@@ -7476,205 +7648,214 @@ format_element_header (CONVERTER *self,
     }
 }
 
-static char *foot_body_heading_array[] = {"footnote-body-heading"};
-static const STRING_LIST foot_body_heading_classes
-   = {foot_body_heading_array, 1, 1};
-
-void
-html_default_format_footnotes_sequence (CONVERTER *self, TEXT *result)
+static int
+word_number_more_than_level (const char *text, int level)
 {
-  size_t i;
-  HTML_PENDING_FOOTNOTE_STACK *pending_footnotes
-   = html_get_pending_footnotes (self);
+  const char *p = text;
+  int count = 0;
 
-  if (pending_footnotes->top > 0)
+  while (*p)
     {
-      for (i = 0; i < pending_footnotes->top; i++)
+      int n = strspn (p, whitespace_chars);
+      if (n)
         {
-          const HTML_PENDING_FOOTNOTE *pending_footnote_info
-           = pending_footnotes->stack[i];
-          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 *attribute_class;
-          char *footnote_mark;
-          char *footnote_location_href
-           = html_footnote_location_href (self, command, 0,
-                                     pending_footnote_info->docid,
-                    pending_footnote_info->footnote_location_filename);
-   /*
-      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.
-      We do not want to set multi_expanded in customizable code.  However, it
-      could be possible to set a shared_conversion_state based on 
$multi_expanded_region
-      and have all the conversion functions calling in_multi_expanded($self)
-      also check the shared_conversion_state.  The special situations
-      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.
-    */
-          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.integer > 0)
-            xasprintf (&footnote_mark, "%d", number_in_doc);
-          else
-            footnote_mark
-              = strdup (self->conf->NO_NUMBER_FOOTNOTE_SYMBOL.string);
-
-          attribute_class = html_attribute_class (self, "h5",
-                            &foot_body_heading_classes);
-          text_append (result, attribute_class);
-          free (attribute_class);
-
-          text_printf (result, "><a id=\"%s\" href=\"%s\">(%s)</a></h5>\n",
-                       footid, footnote_location_href, footnote_mark);
-
-          free (footnote_mark);
-          free (footnote_location_href);
-
-          text_append (result, footnote_text_with_eol);
-          free (footnote_text_with_eol);
+          count++;
+          if (count > level)
+            return 1;
+          p += n;
+        }
+      if (*p)
+        {
+          /* skip a character */
+          int char_len = 1;
+          while ((p[char_len] & 0xC0) == 0x80)
+            char_len++;
+          p += char_len;
         }
     }
-  destroy_pending_footnotes (pending_footnotes);
+  return 0;
 }
 
 void
-format_footnotes_sequence (CONVERTER *self, TEXT *result)
+html_default_format_element_footer (CONVERTER *self,
+                              const enum output_unit_type unit_type,
+                              const OUTPUT_UNIT *output_unit,
+                              const char *content, const ELEMENT *element,
+                              TEXT *result)
 {
-  FORMATTING_REFERENCE *formatting_reference
-   = &self->current_formatting_references[FR_format_footnotes_sequence];
-  if (formatting_reference->status == FRS_status_default_set)
-    {
-      html_default_format_footnotes_sequence (self, result);
-    }
-  else
-    {
-      char *footnotes_sequence
-        = call_formatting_function_format_footnotes_sequence (self,
-                                                formatting_reference);
-      text_append (result, footnotes_sequence);
-      free (footnotes_sequence);
-    }
-}
+  int is_top = unit_is_top_output_unit (self, output_unit);
+  int next_is_top = 0;
+  int next_is_special = 0;
+  int end_page = 0;
+  const BUTTON_SPECIFICATION_LIST *buttons = 0;
 
-void
-default_format_footnotes_segment (CONVERTER *self, TEXT *result)
-{
-  char *class_base;
-  char *attribute_class;
-  char *class;
-  STRING_LIST *classes;
-  ELEMENT *footnote_heading_tree;
-  char *footnote_heading;
-  int level;
-  TEXT foot_lines;
+  if (output_unit->tree_unit_directions[D_next]
+          && unit_is_top_output_unit (self,
+                               output_unit->tree_unit_directions[D_next]))
+    next_is_top = 1;
 
-  text_init (&foot_lines);
-  format_footnotes_sequence (self, &foot_lines);
+  if (output_unit->tree_unit_directions[D_next]
+      && output_unit->tree_unit_directions[D_next]->unit_type
+                                               == OU_special_unit)
+    next_is_special = 1;
 
-  if (foot_lines.end <= 0)
+  if (!output_unit->tree_unit_directions[D_next])
+    end_page = 1;
+  else if (output_unit->unit_filename
+           && strcmp (output_unit->unit_filename,
+              output_unit->tree_unit_directions[D_next]->unit_filename))
     {
-      free (foot_lines.text);
-      return;
-    }
-
-  classes = (STRING_LIST *) malloc (sizeof (STRING_LIST));
-  memset (classes, 0, sizeof (STRING_LIST));
-
-  class_base = special_unit_info (self, SUI_type_class,
-                                  "footnotes");
-  xasprintf (&class, "%s-segment", class_base);
-
-  add_string (class, classes);
-  free (class);
-  attribute_class = html_attribute_class (self, "div", classes);
-  clear_strings_list (classes);
+      size_t file_index;
+      size_t count_in_file;
 
-  text_append (result, attribute_class);
-  free (attribute_class);
+      if (unit_type == OU_special_unit)
+        file_index = self->special_unit_file_indices[output_unit->index];
+      else
+        file_index = self->output_unit_file_indices[output_unit->index];
+      count_in_file
+        = count_elements_in_file_number (self, CEFT_remaining, file_index +1);
 
-  text_append_n (result, ">\n", 2);
+      if (count_in_file == 1)
+        end_page = 1;
+    }
 
-  if (self->conf->DEFAULT_RULE.string
-      && strlen (self->conf->DEFAULT_RULE.string))
+  if ((end_page || next_is_top || next_is_special || is_top)
+      && self->conf->VERTICAL_HEAD_NAVIGATION.integer > 0
+      && (strcmp (self->conf->SPLIT.string, "node")
+          || self->conf->HEADERS.integer > 0 || unit_type == OU_special_unit
+          || is_top))
     {
-      text_append (result, self->conf->DEFAULT_RULE.string);
-      text_append_n (result, "\n", 1);
+      text_append_n (result, "</td>\n</tr>\n</table>\n", 21);
     }
 
-  footnote_heading_tree = special_unit_info_tree (self,
-                              SUIT_type_heading, "footnotes");
-  if (footnote_heading_tree)
+  if (end_page)
     {
-      footnote_heading = html_convert_tree (self, footnote_heading_tree,
-                                    "convert footnotes special heading");
+      STRING_LIST *closed_strings;
+      closed_strings = html_close_registered_sections_level (self, 0);
+
+      if (closed_strings->number)
+        {
+          int i;
+          for (i = 0; i < closed_strings->number; i++)
+            {
+              text_append (result, closed_strings->list[i]);
+              free (closed_strings->list[i]);
+            }
+        }
+      free (closed_strings->list);
+      free (closed_strings);
+
+      /* setup buttons for navigation footer */
+      if ((is_top || unit_type == OU_special_unit)
+           && ((self->conf->SPLIT.string
+                && strcmp (self->conf->SPLIT.string, ""))
+               || self->conf->MONOLITHIC.integer <= 0)
+           && (self->conf->HEADERS.integer > 0
+               || (self->conf->SPLIT.string
+                   && strcmp (self->conf->SPLIT.string, "")
+                   && strcmp (self->conf->SPLIT.string, "node"))))
+         {
+           if (is_top)
+             buttons = self->conf->TOP_BUTTONS.buttons;
+           else
+             buttons = self->conf->MISC_BUTTONS.buttons;
+         }
+      else if (self->conf->SPLIT.string
+                && !strcmp (self->conf->SPLIT.string, "section"))
+        buttons = self->conf->SECTION_FOOTER_BUTTONS.buttons;
+      else if (self->conf->SPLIT.string
+                && !strcmp (self->conf->SPLIT.string, "chapter"))
+        buttons = self->conf->CHAPTER_FOOTER_BUTTONS.buttons;
+      else if (self->conf->SPLIT.string
+                && !strcmp (self->conf->SPLIT.string, "node"))
+        {
+          if (self->conf->HEADERS.integer > 0)
+            {
+              if (self->conf->WORDS_IN_PAGE.integer > 0)
+                {
+                  if (content
+                      && word_number_more_than_level (content,
+                                        self->conf->WORDS_IN_PAGE.integer))
+                    {
+                      buttons = self->conf->NODE_FOOTER_BUTTONS.buttons;
+                    }
+                }
+              else
+                buttons = self->conf->NODE_FOOTER_BUTTONS.buttons;
+            }
+        }
     }
-  else
+
+  if ((!output_unit->tree_unit_directions[D_next]
+       || (output_unit->unit_filename
+           && strcmp (output_unit->unit_filename,
+              output_unit->tree_unit_directions[D_next]->unit_filename)))
+      && !strcmp (self->conf->footnotestyle.string, "end"))
     {
-      footnote_heading = "";
+      format_footnotes_segment (self, result);
     }
 
-  level = self->conf->FOOTNOTE_END_HEADER_LEVEL.integer;
-
-  xasprintf (&class, "%s-heading", class_base);
-
-  add_string (class, classes);
-  free (class);
+  if (buttons || !end_page || self->conf->PROGRAM_NAME_IN_FOOTER.integer > 0)
+    {
+      char *rule = 0;
 
-  format_heading_text (self, 0, classes, footnote_heading, level, 0, 0, 0,
-                       result);
-  destroy_strings_list (classes);
-  text_append_n (result, "\n", 1);
+      if (!end_page && (is_top || next_is_top || (next_is_special
+                                       && unit_type != OU_special_unit)))
+        {
+          rule = self->conf->BIG_RULE.string;
+        }
+      else if (!buttons || is_top || unit_type == OU_special_unit
+               || (end_page && self->conf->SPLIT.string
+                   && (!strcmp (self->conf->SPLIT.string, "section")
+                       || !strcmp (self->conf->SPLIT.string, "chapter")))
+               || (self->conf->SPLIT.string
+                   && !strcmp (self->conf->SPLIT.string, "node")
+                   && self->conf->HEADERS.integer > 0))
+        {
+          rule = self->conf->DEFAULT_RULE.string;
+        }
+      if (rule && strlen (rule))
+        {
+          text_append (result, rule);
+          text_append_n (result, "\n", 1);
+        }
+    }
 
-  if (footnote_heading_tree)
-    free (footnote_heading);
+  if (buttons)
+    {
+      const char *cmdname = 0;
+      if (element)
+        cmdname = element_command_name (element);
 
-  text_append (result, foot_lines.text);
-  free (foot_lines.text);
-  text_append (result, "</div>\n");
+      format_navigation_panel (self, buttons, cmdname, element, 0, result);
+    }
 }
 
 void
-format_footnotes_segment (CONVERTER *self, TEXT *result)
+format_element_footer (CONVERTER *self,
+                              const enum output_unit_type unit_type,
+                              const OUTPUT_UNIT *output_unit,
+                              const char *content, const ELEMENT *element,
+                              TEXT *result)
 {
   FORMATTING_REFERENCE *formatting_reference
-   = &self->current_formatting_references[FR_format_footnotes_segment];
+   = &self->current_formatting_references[FR_format_element_footer];
+
   if (formatting_reference->status == FRS_status_default_set)
     {
-      default_format_footnotes_segment (self, result);
+      html_default_format_element_footer (self, unit_type, output_unit,
+                                          content, element, result);
     }
   else
-    {
-      char *footnotes_segment
-        = call_formatting_function_format_footnotes_segment (self,
-                                             formatting_reference);
-      if (footnotes_segment)
-        {
-          text_append (result, footnotes_segment);
-          free (footnotes_segment);
-        }
-    }
+   {
+     char *formatted_footer
+       = call_formatting_function_format_element_footer (self,
+                                         formatting_reference,
+                                         unit_type,
+                                         output_unit, content, element);
+     text_append (result, formatted_footer);
+     free (formatted_footer);
+   }
 }
 
 static void



reply via email to

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