texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sat, 30 Dec 2023 13:06:24 -0500 (EST)

branch: master
commit c064ba00a71be66a408a703d21dda571e9dcba88
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Dec 30 17:59:20 2023 +0100

    * tp/Texinfo/Convert/HTML.pm (_default_format_special_body_about):
    rename $button as $direction.
    
    * tp/Texinfo/XS/convert/convert_html.c
    (translate_convert_to_html_internal): add a function to translate and
    convert.
    
    * tp/Texinfo/XS/convert/convert_html.c
    (default_format_special_body_about)
    (special_unit_body_internal_formatting_table): implement
    default_format_special_body_about.
---
 ChangeLog                            |  14 +++
 tp/Texinfo/Convert/HTML.pm           |  24 ++---
 tp/Texinfo/XS/convert/convert_html.c | 180 +++++++++++++++++++++++++++++++++++
 3 files changed, 206 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 06b0289568..4ec76121e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,20 @@
        test results to meaningless values.  If these offsets needed to be
        tested, a separate Info output file would have to be used instead.
 
+2023-12-30  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_default_format_special_body_about):
+       rename $button as $direction.
+
+       * tp/Texinfo/XS/convert/convert_html.c
+       (translate_convert_to_html_internal): add a function to translate and
+       convert.
+
+       * tp/Texinfo/XS/convert/convert_html.c
+       (default_format_special_body_about)
+       (special_unit_body_internal_formatting_table): implement
+       default_format_special_body_about.
+
 2023-12-30  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 2f73a86fa1..6cf6806b9b 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -11289,35 +11289,35 @@ EOT
     next if ($button_spec eq ' ' or ref($button_spec) eq 'CODE'
              or ref($button_spec) eq 'SCALAR'
              or (ref($button_spec) eq 'ARRAY' and scalar(@$button_spec) != 2));
-    my $button;
+    my $direction;
     if (ref($button_spec) eq 'ARRAY') {
-      $button = $button_spec->[0];
+      $direction = $button_spec->[0];
     } else {
-      $button = $button_spec;
+      $direction = $button_spec;
     }
     $about .= "  <tr>\n    ".$self->html_attribute_class('td',
                                           ['button-direction-about']) .'>';
-    # if the button spec is an array we do not knwow what the button
+    # if the button spec is an array we do not know what the button
     # looks like, so we do not show the button but still show explanations.
     if (ref($button_spec) ne 'ARRAY') {
       my $button_name_string
-          = $self->direction_string($button, 'button', 'string');
+          = $self->direction_string($direction, 'button', 'string');
       # FIXME strip FirstInFile from $button to get active icon file?
       $about .=
         (($self->get_conf('ICONS') &&
-           $self->get_conf('ACTIVE_ICONS')->{$button}) ?
+           $self->get_conf('ACTIVE_ICONS')->{$direction}) ?
             &{$self->formatting_function('format_button_icon_img')}($self,
-               $button_name_string, $self->get_conf('ACTIVE_ICONS')->{$button})
-        : ' [' . $self->direction_string($button, 'text') . '] ');
+             $button_name_string, 
$self->get_conf('ACTIVE_ICONS')->{$direction})
+        : ' [' . $self->direction_string($direction, 'text') . '] ');
     }
     $about .= "</td>\n";
     my $button_name
-          = $self->direction_string($button, 'button');
+          = $self->direction_string($direction, 'button');
     $about .=
 '    '.$self->html_attribute_class('td', ['name-direction-about']).'>'
     .$button_name."</td>
-    <td>".$self->direction_string($button, 'description')."</td>
-    <td>".$self->direction_string($button, 'example')."</td>
+    <td>".$self->direction_string($direction, 'description')."</td>
+    <td>".$self->direction_string($direction, 'example')."</td>
   </tr>
 ";
   }
@@ -11361,7 +11361,7 @@ EOT
                   . " $non_breaking_space $non_breaking_space\n"
 .
 '            <strong>&lt;== ' . $self->convert_tree($self->gdt('Current 
Position')) . " </strong></li>\n" .
-                 # TRANSLATORS: example name of section for section 1.2.3
+                 # TRANSLATORS: example name of section for section 1.2.4
 '          <li>1.2.4 ' . $self->convert_tree($self->gdt('Subsubsection 
One-Two-Four')) . "</li>\n" .
 "        </ul>\n" .
 "      </li>\n" .
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index c24c965736..5a0642faa4 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -631,6 +631,24 @@ html_pgdt_tree (const char *translation_context, const 
char *string,
                         translation_context, in_lang);
 }
 
+static void
+translate_convert_to_html_internal (const char *string, DOCUMENT *document,
+               CONVERTER *self,
+               NAMED_STRING_ELEMENT_LIST *replaced_substrings,
+               const char *translation_context,
+               const char *in_lang, TEXT *result, char *explanation)
+{
+  ELEMENT *translation_tree = html_gdt_tree (string, document, self,
+                           replaced_substrings, translation_context, in_lang);
+
+  add_to_element_list (&self->tree_to_build, translation_tree);
+  convert_to_html_internal (self, translation_tree, result, explanation);
+  remove_element_from_list (&self->tree_to_build, translation_tree);
+
+  destroy_element_and_children (translation_tree);
+}
+
+
 int
 html_in_code (CONVERTER *self)
 {
@@ -10983,11 +11001,173 @@ default_format_special_body_footnotes (CONVERTER 
*self,
   format_footnotes_sequence (self, result);
 }
 
+static char *button_direction_about_array[] = {"button-direction-about"};
+static const STRING_LIST button_direction_about_classes
+    = {button_direction_about_array, 1, 1};
+
+static char *name_direction_about_array[] = {"name-direction-about"};
+static const STRING_LIST name_direction_about_classes
+    = {name_direction_about_array, 1, 1};
+
+void
+default_format_special_body_about (CONVERTER *self,
+                               const size_t special_unit_number,
+                               const char *special_unit_variety,
+                               const OUTPUT_UNIT *output_unit,
+                               TEXT *result)
+{
+  int i;
+  const BUTTON_SPECIFICATION_LIST *buttons = self->conf->SECTION_BUTTONS;
+
+  if (self->conf->PROGRAM_NAME_IN_ABOUT > 0)
+    {
+      text_append_n (result, "<p>\n  ", 6);
+      format_program_string (self, result);
+      text_append_n (result, "\n</p>\n", 6);
+    }
+
+  text_append_n (result, "<p>\n", 4);
+  translate_convert_to_html_internal (
+   "  The buttons in the navigation panels have the following meaning:",
+   self->document, self, 0, 0, 0, result, 0);
+  text_append (result, "\n</p>\n<table border=\"1\">\n  <tr>\n    <th> ");
+  translate_convert_to_html_internal ("Button", self->document, self, 0,
+                                      0, 0, result, 0);
+  text_append (result, " </th>\n    <th> ");
+  translate_convert_to_html_internal ("Name", self->document, self, 0,
+                                      0, 0, result, 0);
+  text_append (result, " </th>\n    <th> ");
+  translate_convert_to_html_internal ("Go to", self->document, self, 0,
+                                      0, 0, result, 0);
+  text_append (result, " </th>\n    <th> ");
+  translate_convert_to_html_internal ("From 1.2.3 go to", self->document,
+                                      self, 0, 0, 0, result, 0);
+  text_append (result, "</th>\n  </tr>\n");
+
+  for (i = 0; i < buttons->number; i++)
+    {
+      const BUTTON_SPECIFICATION *button = &buttons->list[i];
+      char * attribute_class;
+      int direction = -1;
+
+      if (button->type == BST_direction_info)
+        direction = button->button_info->direction;
+      else if (button->type == BST_direction)
+        direction = button->direction;
+
+      if (direction < 0 || direction == D_direction_Space)
+        continue;
+
+      text_append_n (result, "  <tr>\n    ", 11);
+      attribute_class = html_attribute_class (self, "td",
+                                              &button_direction_about_classes);
+      text_append (result, attribute_class);
+      free (attribute_class);
+      text_append_n (result, ">", 1);
+
+   /* if the button spec is an array we do not know what the button
+      looks like, so we do not show the button but still show explanations. */
+
+      if (button->type == BST_direction)
+        {
+         /* FIXME strip FirstInFile from $button to get active icon file? */
+          if (self->conf->ICONS > 0
+              && self->conf->ACTIVE_ICONS.number > 0
+              && self->conf->ACTIVE_ICONS.list[direction]
+              && strlen (self->conf->ACTIVE_ICONS.list[direction]))
+            {
+              char *button_name_string = direction_string (self, direction,
+                                       TDS_type_button, TDS_context_string);
+              char *button = format_button_icon_img (self, button_name_string,
+                        self->conf->ACTIVE_ICONS.list[direction], 0);
+              text_append (result, button);
+              free (button);
+            }
+          else
+            {
+              text_append_n (result, " [", 2);
+              text_append (result, direction_string (self, direction,
+                                                     TDS_type_text, 0));
+              text_append_n (result, "] ", 2);
+            }
+        }
+      text_append_n (result, "</td>\n    ", 10);
+      attribute_class = html_attribute_class (self, "td",
+                                              &name_direction_about_classes);
+      text_append (result, attribute_class);
+      free (attribute_class);
+      text_append_n (result, ">", 1);
+
+      text_append (result, direction_string (self, direction,
+                                             TDS_type_button, 0));
+      text_append_n (result, "</td>\n    <td>", 14);
+      text_append (result, direction_string (self, direction,
+                                             TDS_type_description, 0));
+      text_append_n (result, "</td>\n    <td>", 14);
+      text_append (result, direction_string (self, direction,
+                                             TDS_type_example, 0));
+      text_append_n (result, "</td>\n  </tr>\n", 14);
+    }
+
+  text_append_n (result, "</table>\n\n<p>\n", 14);
+
+  translate_convert_to_html_internal (
+ "  where the @strong{ Example } assumes that the current position is at "
+ "@strong{ Subsubsection One-Two-Three } of a document of the following "
+ "structure:", self->document, self, 0, 0, 0, result, 0);
+
+  text_append_n (result, "\n</p>\n\n<ul>\n", 12);
+  text_append (result, "  <li> 1. ");
+  translate_convert_to_html_internal ("Section One",
+                           self->document, self, 0, 0, 0, result, 0);
+  text_append (result, "\n    <ul>\n      <li>1.1 ");
+  translate_convert_to_html_internal ("Subsection One-One",
+                           self->document, self, 0, 0, 0, result, 0);
+  text_append (result, "\n        <ul>\n          <li>...</li>\n"
+     "        </ul>\n      </li>\n      <li>1.2 ");
+  translate_convert_to_html_internal ("Subsection One-Two",
+                           self->document, self, 0, 0, 0, result, 0);
+  text_append (result, "\n        <ul>\n          <li>1.2.1 ");
+  translate_convert_to_html_internal ("Subsubsection One-Two-One",
+                           self->document, self, 0, 0, 0, result, 0);
+  text_append (result, "</li>\n          <li>1.2.2 ");
+  translate_convert_to_html_internal ("Subsubsection One-Two-Two",
+                           self->document, self, 0, 0, 0, result, 0);
+  text_append (result, "</li>\n          <li>1.2.3 ");
+  translate_convert_to_html_internal ("Subsubsection One-Two-Three",
+                           self->document, self, 0, 0, 0, result, 0);
+  text_append_n (result, " ", 1);
+  text_append_n (result,
+                self->special_character[SC_non_breaking_space].string,
+                self->special_character[SC_non_breaking_space].len);
+  text_append_n (result, " ", 1);
+  text_append_n (result,
+                self->special_character[SC_non_breaking_space].string,
+                self->special_character[SC_non_breaking_space].len);
+  text_append_n (result, "\n", 1);
+
+  text_append (result, "            <strong>&lt;== ");
+  translate_convert_to_html_internal ("Current Position",
+                           self->document, self, 0, 0, 0, result, 0);
+  text_append (result, " </strong></li>\n          <li>1.2.4 ");
+  translate_convert_to_html_internal ("Subsubsection One-Two-Four",
+                           self->document, self, 0, 0, 0, result, 0);
+  text_append (result, "</li>\n        </ul>\n      </li>\n      <li>1.3 ");
+  translate_convert_to_html_internal ("Subsection One-Three",
+                           self->document, self, 0, 0, 0, result, 0);
+  text_append (result, "\n        <ul>\n          <li>...</li>\n"
+  "        </ul>\n      </li>\n      <li>1.4 ");
+  translate_convert_to_html_internal ("Subsection One-Four",
+                           self->document, self, 0, 0, 0, result, 0);
+  text_append (result, "</li>\n    </ul>\n  </li>\n</ul>\n");
+}
+
 static SPECIAL_UNIT_BODY_INTERNAL_CONVERSION
    special_unit_body_internal_formatting_table[] = {
   {"contents", &default_format_special_body_contents},
   {"shortcontents", &default_format_special_body_shortcontents},
   {"footnotes", &default_format_special_body_footnotes},
+  {"about", &default_format_special_body_about},
   {0, 0},
 };
 



reply via email to

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