texinfo-commits
[Top][All Lists]
Advanced

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

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


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/Texinfo.pm (convert_to_texinfo): remove menu_entry and menu_comment from types with args.
Date: Sat, 04 Feb 2023 15:41:04 -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 2ec05a8ccf * tp/Texinfo/Convert/Texinfo.pm (convert_to_texinfo): 
remove menu_entry and menu_comment from types with args.
2ec05a8ccf is described below

commit 2ec05a8ccf3dbe251527bfc8ff58dccd363dabd9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Feb 4 21:39:17 2023 +0100

    * tp/Texinfo/Convert/Texinfo.pm (convert_to_texinfo): remove
    menu_entry and menu_comment from types with args.
    
    * tp/Texinfo/Convert/Texinfo.pm (_expand_cmd_args_to_texi):
    use common code for the different types of commands.
---
 ChangeLog                     |  8 +++++++
 tp/Texinfo/Convert/Texinfo.pm | 52 +++++++++++++------------------------------
 2 files changed, 24 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fecbf635d0..da682b15d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,14 @@
        * tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting):
        Do not check any line commands for basic inline content.
 
+2023-02-04  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Texinfo.pm (convert_to_texinfo): remove
+       menu_entry and menu_comment from types with args.
+
+       * tp/Texinfo/Convert/Texinfo.pm (_expand_cmd_args_to_texi):
+       use common code for the different types of commands.
+
 2023-02-04  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/Text.pm (_convert): do not handle menu entry
diff --git a/tp/Texinfo/Convert/Texinfo.pm b/tp/Texinfo/Convert/Texinfo.pm
index c75ba07889..3e8c18cf2f 100644
--- a/tp/Texinfo/Convert/Texinfo.pm
+++ b/tp/Texinfo/Convert/Texinfo.pm
@@ -96,9 +96,6 @@ sub root_heading_command_to_texinfo($)
 # Following subroutines deal with transforming a texinfo tree into texinfo
 # text.  Should give the text that was used parsed, except for a few cases.
 
-# the second arguments, if defined triggers replaced
-# tree item to be shown, in the default case they are
-# not shown.
 # expand a tree to the corresponding texinfo.
 sub convert_to_texinfo($);
 sub convert_to_texinfo($)
@@ -116,9 +113,7 @@ sub convert_to_texinfo($)
     $result .= $element->{'text'};
   } else {
     if ($element->{'cmdname'}
-       or ($element->{'type'} and ($element->{'type'} eq 'def_line'
-                                or $element->{'type'} eq 'menu_entry'
-                                or $element->{'type'} eq 'menu_comment'))) {
+        or ($element->{'type'} and $element->{'type'} eq 'def_line')) {
       $result .= _expand_cmd_args_to_texi($element);
     }
     if ($element->{'type'}
@@ -163,35 +158,12 @@ sub _expand_cmd_args_to_texi($) {
       and exists ($cmd->{'info'}->{'spaces_after_cmd_before_arg'})) {
     $result .= $cmd->{'info'}->{'spaces_after_cmd_before_arg'};
   }
-  # block line commands with arguments not separated by commas
-  if ($block_commands{$cmdname}
-         and ($def_commands{$cmdname}
-              or $block_commands{$cmdname} eq 'multitable')
-         and $cmd->{'args'}) {
-     $result .= $cmd->{'info'}->{'spaces_before_argument'}->{'text'}
-       if $cmd->{'info'} and $cmd->{'info'}->{'spaces_before_argument'};
-     foreach my $arg (@{$cmd->{'args'}}) {
-        $result .= convert_to_texinfo($arg);
-    }
   # arg_line set for line_commands with type special and @macro
-  } elsif ($cmd->{'info'} and defined($cmd->{'info'}->{'arg_line'})) {
+  if ($cmd->{'info'} and defined($cmd->{'info'}->{'arg_line'})) {
     $result .= $cmd->{'info'}->{'spaces_before_argument'}->{'text'}
       if $cmd->{'info'} and $cmd->{'info'}->{'spaces_before_argument'};
     $result .= $cmd->{'info'}->{'arg_line'};
-  } elsif (($block_commands{$cmdname} or $cmdname eq 'node')
-            and defined($cmd->{'args'})) {
-    $result .= $cmd->{'info'}->{'spaces_before_argument'}->{'text'}
-      if $cmd->{'info'} and $cmd->{'info'}->{'spaces_before_argument'};
-    foreach my $arg (@{$cmd->{'args'}}) {
-      next if $arg->{'type'} and $ignored_types{$arg->{'type'}};
-      if ($arg->{'info'} and $arg->{'info'}->{'spaces_before_argument'}) {
-        $result .= $arg->{'info'}->{'spaces_before_argument'}->{'text'};
-      }
-      $result .= convert_to_texinfo($arg);
-      $result .= ',';
-    }
-    $result =~ s/,$//;
-  } elsif (defined($cmd->{'args'})) {
+  } elsif ($cmd->{'args'}) {
     my $braces;
     $braces = 1 if (scalar(@{$cmd->{'args'}})
                     and $cmd->{'args'}->[0]->{'type'}
@@ -201,14 +173,22 @@ sub _expand_cmd_args_to_texi($) {
     if ($cmdname eq 'verb') {
       $result .= $cmd->{'info'}->{'delimiter'};
     }
-    if ($cmd->{'info'}
-        and $cmd->{'info'}->{'spaces_before_argument'}) {
-      $result .= $cmd->{'info'}->{'spaces_before_argument'}->{'text'};
+    $result .= $cmd->{'info'}->{'spaces_before_argument'}->{'text'}
+       if ($cmd->{'info'} and $cmd->{'info'}->{'spaces_before_argument'});
+    my $with_commas = 0;
+    if (($block_commands{$cmdname}
+         # block line commands with arguments not separated by commas
+         and not ($def_commands{$cmdname}
+                  or $block_commands{$cmdname} eq 'multitable'))
+        or $cmdname eq 'node'
+        or exists($brace_commands{$cmdname})
+        or ($cmd->{'type'} and $cmd->{'type'} eq 'definfoenclose_command')) {
+      $with_commas = 1;
     }
     my $arg_nr = 0;
     foreach my $arg (@{$cmd->{'args'}}) {
-      if (exists($brace_commands{$cmdname}) or ($cmd->{'type'}
-                    and $cmd->{'type'} eq 'definfoenclose_command')) {
+      next if $arg->{'type'} and $ignored_types{$arg->{'type'}};
+      if ($with_commas) {
         $result .= ',' if ($arg_nr);
         $arg_nr++;
       }



reply via email to

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