texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Tue, 23 Jan 2024 05:17:20 -0500 (EST)

branch: master
commit 4f0434f46053e7fa7a59192ebaac5e79131bf3aa
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jan 23 11:17:03 2024 +0100

    * tp/Texinfo/Convert/HTML.pm (_mini_toc),
    tp/Texinfo/XS/convert/convert_html.c (mini_toc_internal): handle empty
    sectioning command in mini toc.
    
    * tp/Makefile.tres, tp/t/30sectioning.t (empty_section_in_chapter):
    test empty @section in @chapter conversion.
---
 ChangeLog                                          |   9 +
 tp/Makefile.tres                                   |   1 +
 tp/Texinfo/Convert/HTML.pm                         |   2 +
 tp/Texinfo/XS/convert/convert_html.c               |   7 +
 tp/t/30sectioning.t                                |   5 +
 .../results/sectioning/empty_section_in_chapter.pl | 192 +++++++++++++++++++++
 6 files changed, 216 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 4d60dbc65b..f82a3c669e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-22  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_mini_toc),
+       tp/Texinfo/XS/convert/convert_html.c (mini_toc_internal): handle empty
+       sectioning command in mini toc.
+
+       * tp/Makefile.tres, tp/t/30sectioning.t (empty_section_in_chapter):
+       test empty @section in @chapter conversion.
+
 2024-01-22  Patrice Dumas  <pertusus@free.fr>
 
        * contrib/mass_test/generate_perlVSC.sh: show command line when doing
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 0abcd70bd9..2a129aa6b3 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -1822,6 +1822,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/sectioning/empty_nodes_with_commands.pl \
   t/results/sectioning/empty_ref_arg.pl \
   t/results/sectioning/empty_refs.pl \
+  t/results/sectioning/empty_section_in_chapter.pl \
   t/results/sectioning/equivalent_labels.pl \
   t/results/sectioning/equivalent_nodes.pl \
   t/results/sectioning/equivalent_nodes_novalidate.pl \
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index fb6892c007..5c054d984e 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -10624,6 +10624,8 @@ sub _mini_toc
       # converts in the current page context.
       #my $text = $self->command_text($section, 'text_nonumber');
       my $tree = $self->command_tree($section, 1);
+      # happens with empty sectioning command
+      next if (!$tree);
       my $text = $self->convert_tree($tree, "mini_toc 
\@$section->{'cmdname'}");
 
       $entry_index++;
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 8f9c680fde..574477d0fd 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -3762,6 +3762,9 @@ html_footnote_location_href (CONVERTER *self, const 
ELEMENT *command,
   return href.text;
 }
 
+/* the returned TREE_ADDED_ELEMENTS may not be NUL but have a NUL tree
+   field, for instance in the case of an empty sectioning element
+ */
 TREE_ADDED_ELEMENTS *
 html_internal_command_tree (CONVERTER *self, const ELEMENT *command,
                             int no_number)
@@ -9784,6 +9787,10 @@ mini_toc_internal (CONVERTER *self, const ELEMENT 
*element, TEXT *result)
           char *text;
           char *href = html_command_href (self, section, 0, 0, 0);
 
+          /* happens with empty sectioning command */
+          if (!command_tree->tree)
+            continue;
+
           xasprintf (&explanation, "mini_toc @%s",
                      element_command_name (section));
           text = html_convert_tree (self, command_tree->tree, explanation);
diff --git a/tp/t/30sectioning.t b/tp/t/30sectioning.t
index 859c447e71..a33bdec148 100644
--- a/tp/t/30sectioning.t
+++ b/tp/t/30sectioning.t
@@ -136,6 +136,11 @@ my @tests_converted = (
 ['one_subsection',
 '@subsection The subsection
 '],
+['empty_section_in_chapter',
+'@chapter chap
+
+@section
+'],
 ['section_below_unnumbered',
 '
 @contents
diff --git a/tp/t/results/sectioning/empty_section_in_chapter.pl 
b/tp/t/results/sectioning/empty_section_in_chapter.pl
new file mode 100644
index 0000000000..8ba52fab5b
--- /dev/null
+++ b/tp/t/results/sectioning/empty_section_in_chapter.pl
@@ -0,0 +1,192 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'empty_section_in_chapter'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'type' => 'preamble_before_content'
+        }
+      ],
+      'type' => 'before_node_section'
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'chap'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'chapter',
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        }
+      ],
+      'extra' => {
+        'section_number' => '1'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 1
+      }
+    },
+    {
+      'args' => [
+        {
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'section',
+      'extra' => {
+        'section_number' => '1.1'
+      },
+      'source_info' => {
+        'line_nr' => 3
+      }
+    }
+  ],
+  'type' => 'document_root'
+};
+
+$result_texis{'empty_section_in_chapter'} = '@chapter chap
+
+@section
+';
+
+
+$result_texts{'empty_section_in_chapter'} = '1 chap
+******
+
+1.1 
+====
+';
+
+$result_sectioning{'empty_section_in_chapter'} = {
+  'extra' => {
+    'section_childs' => [
+      {
+        'cmdname' => 'chapter',
+        'extra' => {
+          'section_childs' => [
+            {
+              'cmdname' => 'section',
+              'extra' => {
+                'section_directions' => {
+                  'up' => {}
+                },
+                'section_level' => 2,
+                'section_number' => '1.1'
+              }
+            }
+          ],
+          'section_level' => 1,
+          'section_number' => '1',
+          'sectioning_root' => {}
+        }
+      }
+    ],
+    'section_level' => 0
+  }
+};
+$result_sectioning{'empty_section_in_chapter'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'section_directions'}{'up'}
 = $result_sectioning{'empty_section_in_chapter'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'empty_section_in_chapter'}{'extra'}{'section_childs'}[0]{'extra'}{'sectioning_root'}
 = $result_sectioning{'empty_section_in_chapter'};
+
+$result_errors{'empty_section_in_chapter'} = [
+  {
+    'error_line' => 'warning: @section missing argument
+',
+    'line_nr' => 3,
+    'text' => '@section missing argument',
+    'type' => 'warning'
+  }
+];
+
+
+$result_floats{'empty_section_in_chapter'} = {};
+
+
+
+$result_converted{'plaintext'}->{'empty_section_in_chapter'} = '1 chap
+******
+
+';
+
+
+$result_converted{'html'}->{'empty_section_in_chapter'} = '<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Untitled Document</title>
+
+<meta name="description" content="Untitled Document">
+<meta name="keywords" content="Untitled Document">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+span:hover a.copiable-link {visibility: visible}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+<div class="chapter-level-extent" id="chap">
+<h2 class="chapter"><span>1 chap<a class="copiable-link" href="#chap"> 
&para;</a></span></h2>
+
+<ul class="mini-toc">
+</ul>
+<div class="section-level-extent">
+</div>
+</div>
+
+
+
+</body>
+</html>
+';
+
+$result_converted_errors{'html'}->{'empty_section_in_chapter'} = [
+  {
+    'error_line' => 'warning: must specify a title with a title command or @top
+',
+    'text' => 'must specify a title with a title command or @top',
+    'type' => 'warning'
+  }
+];
+
+
+1;



reply via email to

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