texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sun, 29 Sep 2024 09:29:50 -0400 (EDT)

branch: master
commit e3b71fca908d0d4236f3e846bf591f539ac19ea7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jul 1 11:47:14 2024 +0200

    * tp/Texinfo/Convert/Text.pm (_convert),
    tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal):
    handle @image without brace, with 0 args.
    
    * tp/Makefile.tres, tp/t/03coverage_braces.t (image_no_braces): test
    of @image without braces at end of document.
---
 ChangeLog                                       |  9 ++++
 tp/Makefile.tres                                |  1 +
 tp/TODO                                         |  3 +-
 tp/Texinfo/Convert/Text.pm                      | 12 +++--
 tp/Texinfo/XS/main/convert_to_text.c            | 11 +++--
 tp/t/03coverage_braces.t                        |  1 +
 tp/t/results/coverage_braces/image_no_braces.pl | 58 +++++++++++++++++++++++++
 7 files changed, 86 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 265ed42926..d39421bd05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-07-01  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Text.pm (_convert),
+       tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal):
+       handle @image without brace, with 0 args.
+
+       * tp/Makefile.tres, tp/t/03coverage_braces.t (image_no_braces): test
+       of @image without braces at end of document.
+
 2024-07-01  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/DocBook.pm (_convert): simplify condition.
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index c48c97799c..2352960713 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -411,6 +411,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/coverage_braces/form_feed_in_brace_commands.pl \
   t/results/coverage_braces/format_on_first_footnote_line.pl \
   t/results/coverage_braces/heading_in_footnote.pl \
+  t/results/coverage_braces/image_no_braces.pl \
   t/results/coverage_braces/inforef_too_much_args.pl \
   t/results/coverage_braces/kbd.pl \
   t/results/coverage_braces/math_bracketed_inside_not_closed.pl \
diff --git a/tp/TODO b/tp/TODO
index e5156cec00..40b2df57b9 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -11,7 +11,8 @@ Before next release
 ===================
 
 test of
-@image
+@email
+@abbr
 @math
 @strong
 @footnote
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index ebd5d473f1..54177c1a11 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -570,10 +570,14 @@ sub _convert($$)
                                 $options->{'set_case'});
       return $result;
     } elsif ($element->{'cmdname'} eq 'image') {
-      $options->{'_code_state'}++;
-      my $text = _convert($options, $element->{'args'}->[0]);
-      $options->{'_code_state'}--;
-      return $text;
+      if ($element->{'args'}) {
+        $options->{'_code_state'}++;
+        my $text = _convert($options, $element->{'args'}->[0]);
+        $options->{'_code_state'}--;
+        return $text;
+      } else {
+        return '';
+      }
     } elsif ($element->{'cmdname'} eq 'email') {
       my $text;
       $text = _convert($options, $element->{'args'}->[1])
diff --git a/tp/Texinfo/XS/main/convert_to_text.c 
b/tp/Texinfo/XS/main/convert_to_text.c
index 8dc329f1a4..f4cb9b1363 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -711,10 +711,13 @@ convert_to_text_internal (const ELEMENT *element, 
TEXT_OPTIONS *text_options,
         }
       else if (data_cmd == CM_image)
         {
-          text_options->code_state++;
-          convert_to_text_internal (element->e.c->args.list[0],
-                                    text_options, result);
-          text_options->code_state--;
+          if (element->e.c->args.number > 0)
+            {
+              text_options->code_state++;
+              convert_to_text_internal (element->e.c->args.list[0],
+                                        text_options, result);
+              text_options->code_state--;
+            }
           return;
         }
       else if (data_cmd == CM_email)
diff --git a/tp/t/03coverage_braces.t b/tp/t/03coverage_braces.t
index 24a0be0737..0fdaf93354 100644
--- a/tp/t/03coverage_braces.t
+++ b/tp/t/03coverage_braces.t
@@ -90,6 +90,7 @@ my @test_cases = (
 ['command_in_U',
 '@U{@code{09AF}}'],
 ['brace_command_no_braces', '@xref'],
+['image_no_braces', '@image '],
 ['verb_in_xref',
 '@anchor{point}
 
diff --git a/tp/t/results/coverage_braces/image_no_braces.pl 
b/tp/t/results/coverage_braces/image_no_braces.pl
new file mode 100644
index 0000000000..337501810f
--- /dev/null
+++ b/tp/t/results/coverage_braces/image_no_braces.pl
@@ -0,0 +1,58 @@
+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{'image_no_braces'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'cmdname' => 'image',
+          'info' => {
+            'spaces_after_cmd_before_arg' => {
+              'text' => ' '
+            }
+          },
+          'source_info' => {
+            'line_nr' => 1
+          }
+        }
+      ],
+      'type' => 'before_node_section'
+    }
+  ],
+  'type' => 'document_root'
+};
+
+$result_texis{'image_no_braces'} = '@image ';
+
+
+$result_texts{'image_no_braces'} = '';
+
+$result_errors{'image_no_braces'} = [
+  {
+    'error_line' => '@image expected braces
+',
+    'line_nr' => 1,
+    'text' => '@image expected braces',
+    'type' => 'error'
+  }
+];
+
+
+$result_floats{'image_no_braces'} = {};
+
+
+
+$result_converted{'plaintext'}->{'image_no_braces'} = '';
+
+
+$result_converted{'html_text'}->{'image_no_braces'} = '';
+
+
+$result_converted{'latex_text'}->{'image_no_braces'} = '';
+
+1;



reply via email to

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