texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Fri, 3 May 2024 06:30:55 -0400 (EDT)

branch: master
commit eb09a880e778cddb1d2f17c41fcda12a8cf8ce65
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri May 3 11:51:05 2024 +0200

    * tp/Texinfo/Convert/TexinfoMarkup.pm (_convert): fix @inline*
    commands output to include inlinefmtifelse second argument.
    
    * tp/t/converters_tests.t (inlinefmtifelse_with_commands): update xml
    part of the test to have argument text content match the context.
    
    * tp/Makefile.tres, tp/t/xml_tests.t (inline_commands): add @inline*
    commands expansion test.
---
 ChangeLog                                          |  11 +
 tp/Makefile.tres                                   |   1 +
 tp/TODO                                            |   4 +-
 tp/Texinfo/Convert/TexinfoMarkup.pm                |  10 +-
 tp/t/converters_tests.t                            |   4 +-
 tp/t/results/converters_tests/inlinefmtifelse.pl   |   2 +-
 .../inlinefmtifelse_with_commands.pl               |   6 +-
 tp/t/results/xml_tests/inline_commands.pl          | 344 +++++++++++++++++++++
 tp/t/xml_tests.t                                   |  10 +
 9 files changed, 379 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5abdf81b7d..18ed006aed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-05-03  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/TexinfoMarkup.pm (_convert): fix @inline*
+       commands output to include inlinefmtifelse second argument.
+
+       * tp/t/converters_tests.t (inlinefmtifelse_with_commands): update xml
+       part of the test to have argument text content match the context.
+
+       * tp/Makefile.tres, tp/t/xml_tests.t (inline_commands): add @inline*
+       commands expansion test.
+
 2024-05-03  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Indices.pm (setup_index_entry_keys_formatting): handle
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 861fabdaab..3f4f3d4459 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -2091,6 +2091,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/xml_tests/comments_on_block_command_lines.pl \
   t/results/xml_tests/comments_on_misc_command_line.pl \
   t/results/xml_tests/image_inline_or_not.pl \
+  t/results/xml_tests/inline_commands.pl \
   t/results/xml_tests/inlineifset_empty_second_arg.pl \
   t/results/xml_tests/lone_bye.pl \
   t/results/xml_tests/macro_and_args.pl \
diff --git a/tp/TODO b/tp/TODO
index e2622069c8..1441705490 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -222,7 +222,7 @@ There is a test of translation in parser in a translation 
in converter, in
   tp/t/init_files_tests.t translation_in_parser_in_translation
 
 It would be nice to also have a translation in parser in a translation
-in parser.  That would meen having a po/gmo file where the string
+in parser.  That would mean having a po/gmo file where the string
 translated in the parser for @def* indices, for instance "{name} of {class}"
 is translated to a string including @def* commands, like
 @deftypeop a b c d e f        
@@ -266,8 +266,6 @@ line by line.
 
 See message/thread from Reißner Ernst: Feature request: api docs
 
-Add in_math (for \) as flag in command_data.txt?
-
 Right now VERBOSE is almost not used.
 
 Should we warn if output is on STDOUT and OUTPUT_ENCODING_NAME != 
MESSAGE_OUTPUT_ENCODING_NAME?
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm 
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index 27943d6abb..af7becbc31 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -1041,12 +1041,12 @@ sub _convert($$;$)
           $self->{'document_context'}->[-1]->{'raw'} = 1;
         }
         my $command_result = '';
-        if (scalar (@{$element->{'args'}}) == 2
-              and defined($element->{'args'}->[-1])
-              and $element->{'args'}->[-1]->{'contents'}
-              and @{$element->{'args'}->[-1]->{'contents'}}) {
+        if (scalar(@{$element->{'args'}}) >= 2
+              and defined($element->{'args'}->[1])
+              and $element->{'args'}->[1]->{'contents'}
+              and scalar(@{$element->{'args'}->[1]->{'contents'}})) {
           $command_result = $self->_convert({'contents'
-                        => $element->{'args'}->[-1]->{'contents'}});
+                                         => [$element->{'args'}->[1]]});
         }
         if ($element->{'cmdname'} eq 'inlineraw') {
           pop @{$self->{'document_context'}};
diff --git a/tp/t/converters_tests.t b/tp/t/converters_tests.t
index b39ec8439c..12d8540790 100644
--- a/tp/t/converters_tests.t
+++ b/tp/t/converters_tests.t
@@ -577,6 +577,8 @@ $inline_text, {'EXPANDED_FORMATS' => ['tex']},
 ',
 {'EXPANDED_FORMATS' => []}
 ],
+# beware that with EXPANDED_FORMATS set to an empty array no
+# format is considered to be expanded in the parser.
 # same as above, show visually that the format being converted
 # text is the first argument and is raw text without @-command
 # expanded, while for the other formats the second argument is
@@ -586,7 +588,7 @@ $inline_text, {'EXPANDED_FORMATS' => ['tex']},
 
 @inlinefmtifelse{plaintext,if @emph{plaintext},else @emph{plaintext}}.
 
-@inlinefmtifelse{xml,if xml @env{empty} second arg, xml @env{else}}.
+@inlinefmtifelse{xml,if xml @env{second} arg, xml @env{else}}.
 
 @inlinefmtifelse{ docbook , if docbook @string{spaces} , else @strong{docbook 
spaces} }.
 
diff --git a/tp/t/results/converters_tests/inlinefmtifelse.pl 
b/tp/t/results/converters_tests/inlinefmtifelse.pl
index 9dd3856042..bbf3fbfce8 100644
--- a/tp/t/results/converters_tests/inlinefmtifelse.pl
+++ b/tp/t/results/converters_tests/inlinefmtifelse.pl
@@ -604,7 +604,7 @@ $result_converted{'xml'}->{'inlinefmtifelse'} = 
'<para><inlinefmtifelse><inlinef
 
<para><inlinefmtifelse><inlinefmtifelseformat>plaintext</inlinefmtifelseformat><inlinefmtifelsecontentif>if
 plaintext no second arg</inlinefmtifelsecontentif></inlinefmtifelse>.
 
<inlinefmtifelse><inlinefmtifelseformat>plaintext</inlinefmtifelseformat><inlinefmtifelsecontentif>if
 plaintext</inlinefmtifelsecontentif><inlinefmtifelsecontentelse>else 
plaintext</inlinefmtifelsecontentelse></inlinefmtifelse>.
 </para>
-<para>.
+<para>if xml empty second arg.
 </para>
 <para><inlinefmtifelse><inlinefmtifelseformat spaces=" ">docbook 
</inlinefmtifelseformat><inlinefmtifelsecontentif> if docbook spaces 
</inlinefmtifelsecontentif><inlinefmtifelsecontentelse spaces=" ">else docbook 
spaces </inlinefmtifelsecontentelse></inlinefmtifelse>.
 </para>
diff --git a/tp/t/results/converters_tests/inlinefmtifelse_with_commands.pl 
b/tp/t/results/converters_tests/inlinefmtifelse_with_commands.pl
index a0676d5310..b6e870a462 100644
--- a/tp/t/results/converters_tests/inlinefmtifelse_with_commands.pl
+++ b/tp/t/results/converters_tests/inlinefmtifelse_with_commands.pl
@@ -158,7 +158,7 @@ $result_trees{'inlinefmtifelse_with_commands'} = {
                 {
                   'contents' => [
                     {
-                      'text' => 'if xml @env{empty} second arg',
+                      'text' => 'if xml @env{second} arg',
                       'type' => 'raw'
                     }
                   ],
@@ -438,7 +438,7 @@ $result_texis{'inlinefmtifelse_with_commands'} = 
'@inlinefmtifelse{html,if @code
 
 @inlinefmtifelse{plaintext,if @emph{plaintext},else @emph{plaintext}}.
 
-@inlinefmtifelse{xml,if xml @env{empty} second arg, xml @env{else}}.
+@inlinefmtifelse{xml,if xml @env{second} arg, xml @env{else}}.
 
 @inlinefmtifelse{ docbook , if docbook @string{spaces} , else @strong{docbook 
spaces} }.
 
@@ -500,7 +500,7 @@ $result_converted{'xml'}->{'inlinefmtifelse_with_commands'} 
= '<para><inlinefmti
 </para>
 
<para><inlinefmtifelse><inlinefmtifelseformat>plaintext</inlinefmtifelseformat><inlinefmtifelsecontentif>if
 @emph{plaintext}</inlinefmtifelsecontentif><inlinefmtifelsecontentelse>else 
<emph>plaintext</emph></inlinefmtifelsecontentelse></inlinefmtifelse>.
 </para>
-<para>.
+<para>if xml @env{second} arg.
 </para>
 <para><inlinefmtifelse><inlinefmtifelseformat spaces=" ">docbook 
</inlinefmtifelseformat><inlinefmtifelsecontentif> if docbook @string{spaces} 
</inlinefmtifelsecontentif><inlinefmtifelsecontentelse spaces=" ">else 
<strong>docbook spaces</strong> </inlinefmtifelsecontentelse></inlinefmtifelse>.
 </para>
diff --git a/tp/t/results/xml_tests/inline_commands.pl 
b/tp/t/results/xml_tests/inline_commands.pl
new file mode 100644
index 0000000000..c4083662db
--- /dev/null
+++ b/tp/t/results/xml_tests/inline_commands.pl
@@ -0,0 +1,344 @@
+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{'inline_commands'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'contents' => [
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'xml'
+                    }
+                  ],
+                  'type' => 'brace_command_arg'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => '<sc>xml inlineraw</sc>'
+                    }
+                  ],
+                  'info' => {
+                    'spaces_before_argument' => {
+                      'text' => ' '
+                    }
+                  },
+                  'type' => 'brace_command_arg'
+                }
+              ],
+              'cmdname' => 'inlineraw',
+              'extra' => {
+                'expand_index' => 1,
+                'format' => 'xml'
+              },
+              'source_info' => {
+                'line_nr' => 1
+              }
+            },
+            {
+              'text' => '
+'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'html'
+                    }
+                  ],
+                  'type' => 'brace_command_arg'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => ' <code>html</code>',
+                      'type' => 'raw'
+                    }
+                  ],
+                  'type' => 'elided_brace_command_arg'
+                }
+              ],
+              'cmdname' => 'inlineraw',
+              'extra' => {
+                'format' => 'html'
+              },
+              'source_info' => {
+                'line_nr' => 2
+              }
+            },
+            {
+              'text' => '
+'
+            }
+          ],
+          'type' => 'paragraph'
+        },
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'contents' => [
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'xml'
+                    }
+                  ],
+                  'type' => 'brace_command_arg'
+                },
+                {
+                  'contents' => [
+                    {
+                      'args' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'inlinefmt'
+                            }
+                          ],
+                          'type' => 'brace_command_arg'
+                        }
+                      ],
+                      'cmdname' => 'env',
+                      'source_info' => {
+                        'line_nr' => 4
+                      }
+                    },
+                    {
+                      'text' => ', xml'
+                    }
+                  ],
+                  'info' => {
+                    'spaces_before_argument' => {
+                      'text' => ' '
+                    }
+                  },
+                  'type' => 'brace_command_arg'
+                }
+              ],
+              'cmdname' => 'inlinefmt',
+              'extra' => {
+                'expand_index' => 1,
+                'format' => 'xml'
+              },
+              'source_info' => {
+                'line_nr' => 4
+              }
+            },
+            {
+              'text' => '
+'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'html'
+                    }
+                  ],
+                  'type' => 'brace_command_arg'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => ' @env{inlinefmt}, html',
+                      'type' => 'raw'
+                    }
+                  ],
+                  'type' => 'elided_brace_command_arg'
+                }
+              ],
+              'cmdname' => 'inlinefmt',
+              'extra' => {
+                'format' => 'html'
+              },
+              'source_info' => {
+                'line_nr' => 5
+              }
+            },
+            {
+              'text' => '
+'
+            }
+          ],
+          'type' => 'paragraph'
+        },
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'contents' => [
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'xml'
+                    }
+                  ],
+                  'type' => 'brace_command_arg'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => 'xml '
+                    },
+                    {
+                      'args' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'inlinefmtifelse'
+                            }
+                          ],
+                          'type' => 'brace_command_arg'
+                        }
+                      ],
+                      'cmdname' => 'code',
+                      'source_info' => {
+                        'line_nr' => 7
+                      }
+                    }
+                  ],
+                  'info' => {
+                    'spaces_before_argument' => {
+                      'text' => ' '
+                    }
+                  },
+                  'type' => 'brace_command_arg'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => ' else xml',
+                      'type' => 'raw'
+                    }
+                  ],
+                  'type' => 'elided_brace_command_arg'
+                }
+              ],
+              'cmdname' => 'inlinefmtifelse',
+              'extra' => {
+                'expand_index' => 1,
+                'format' => 'xml'
+              },
+              'source_info' => {
+                'line_nr' => 7
+              }
+            },
+            {
+              'text' => '
+'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'html'
+                    }
+                  ],
+                  'type' => 'brace_command_arg'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => ' html @var{inlinefmtifelse}',
+                      'type' => 'raw'
+                    }
+                  ],
+                  'type' => 'elided_brace_command_arg'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => 'else html'
+                    }
+                  ],
+                  'info' => {
+                    'spaces_before_argument' => {
+                      'text' => ' '
+                    }
+                  },
+                  'type' => 'brace_command_arg'
+                }
+              ],
+              'cmdname' => 'inlinefmtifelse',
+              'extra' => {
+                'expand_index' => 2,
+                'format' => 'html'
+              },
+              'source_info' => {
+                'line_nr' => 8
+              }
+            },
+            {
+              'text' => '
+'
+            }
+          ],
+          'type' => 'paragraph'
+        }
+      ],
+      'type' => 'before_node_section'
+    }
+  ],
+  'type' => 'document_root'
+};
+
+$result_texis{'inline_commands'} = '@inlineraw{xml, <sc>xml inlineraw</sc>}
+@inlineraw{html, <code>html</code>}
+
+@inlinefmt{xml, @env{inlinefmt}, xml}
+@inlinefmt{html, @env{inlinefmt}, html}
+
+@inlinefmtifelse{xml, xml @code{inlinefmtifelse}, else xml}
+@inlinefmtifelse{html, html @var{inlinefmtifelse}, else html}
+';
+
+
+$result_texts{'inline_commands'} = '<sc>xml inlineraw</sc>
+
+
+inlinefmt, xml
+
+
+xml inlinefmtifelse
+else html
+';
+
+$result_errors{'inline_commands'} = [];
+
+
+$result_floats{'inline_commands'} = {};
+
+
+
+$result_converted{'xml'}->{'inline_commands'} = '<para><sc>xml inlineraw</sc>
+<inlineraw><inlinerawformat>html</inlinerawformat><inlinerawcontent> 
&lt;code&gt;html&lt;/code&gt;</inlinerawcontent></inlineraw>
+</para>
+<para><env>inlinefmt</env>, xml
+<inlinefmt><inlinefmtformat>html</inlinefmtformat><inlinefmtcontent> 
@env{inlinefmt}, html</inlinefmtcontent></inlinefmt>
+</para>
+<para>xml <code>inlinefmtifelse</code>
+<inlinefmtifelse><inlinefmtifelseformat>html</inlinefmtifelseformat><inlinefmtifelsecontentif>
 html 
@var{inlinefmtifelse}</inlinefmtifelsecontentif><inlinefmtifelsecontentelse 
spaces=" ">else html</inlinefmtifelsecontentelse></inlinefmtifelse>
+</para>';
+
+1;
diff --git a/tp/t/xml_tests.t b/tp/t/xml_tests.t
index f5827ee28b..a446156194 100644
--- a/tp/t/xml_tests.t
+++ b/tp/t/xml_tests.t
@@ -375,6 +375,16 @@ $sectioning_test,
 ['sectioning_test_no_use_nodes',
 $sectioning_test, {}, {'TXI_MARKUP_NO_SECTION_EXTENT' => 1,},
 ],
+['inline_commands',
+'@inlineraw{xml, <sc>xml inlineraw</sc>}
+@inlineraw{html, <code>html</code>}
+
+@inlinefmt{xml, @env{inlinefmt}, xml}
+@inlinefmt{html, @env{inlinefmt}, html}
+
+@inlinefmtifelse{xml, xml @code{inlinefmtifelse}, else xml}
+@inlinefmtifelse{html, html @var{inlinefmtifelse}, else html}
+', {'EXPANDED_FORMATS' => ['xml']}],
 );
 
 foreach my $test (@test_cases) {



reply via email to

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