texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/TexinfoMarkup.pm (_convert), tp/Texinfo/Convert/TexinfoXML.pm (_xml_attributes), util/txixml2texi.pl (unprotect_spaces): add attribute for spaces_after_cmd_before_arg info, protect special spaces in it and unprotect in txixml2texi.pl.
Date: Thu, 01 Dec 2022 03:41:18 -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 ace7c5a1b6 * tp/Texinfo/Convert/TexinfoMarkup.pm (_convert), 
tp/Texinfo/Convert/TexinfoXML.pm (_xml_attributes), util/txixml2texi.pl 
(unprotect_spaces): add attribute for spaces_after_cmd_before_arg info, protect 
special spaces in it and unprotect in txixml2texi.pl.
ace7c5a1b6 is described below

commit ace7c5a1b692aac42924753773310f867a59d8b0
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Dec 1 09:41:06 2022 +0100

    * tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),
    tp/Texinfo/Convert/TexinfoXML.pm (_xml_attributes),
    util/txixml2texi.pl (unprotect_spaces): add attribute for
    spaces_after_cmd_before_arg info, protect special spaces in it
    and unprotect in txixml2texi.pl.
---
 ChangeLog                                          |  8 +++
 tp/Texinfo/Convert/TexinfoMarkup.pm                | 20 ++++++-
 tp/Texinfo/Convert/TexinfoXML.pm                   |  5 +-
 tp/t/02coverage.t                                  | 34 +++++------
 .../results/coverage/lettered_accent_and_spaces.pl | 15 ++---
 .../coverage/spaces_after_braced_command.pl        | 68 ++++++++++++++++++++++
 util/txixml2texi.pl                                | 38 +++++++-----
 7 files changed, 142 insertions(+), 46 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3c790f8a2b..e2eef9c62e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-11-30  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),
+       tp/Texinfo/Convert/TexinfoXML.pm (_xml_attributes),
+       util/txixml2texi.pl (unprotect_spaces): add attribute for
+       spaces_after_cmd_before_arg info, protect special spaces in it
+       and unprotect in txixml2texi.pl.
+
 2022-11-30  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/TexinfoMarkup.pm (_convert): add end lines
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm 
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index 06cf3dab02..715a635e51 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -638,7 +638,8 @@ sub _convert($$;$)
           if ($element->{'info'}
               and $element->{'info'}->{'spaces_after_cmd_before_arg'}) {
             push @$attributes, ['spaces',
-                      $element->{'info'}->{'spaces_after_cmd_before_arg'}];
+               _protect_in_spaces_attribute_text(
+                    $element->{'info'}->{'spaces_after_cmd_before_arg'})];
           }
           if ($element->{'args'}->[0]->{'type'} eq 'following_arg') {
              push @$attributes, ['bracketed', 'off'];
@@ -1041,6 +1042,14 @@ sub _convert($$;$)
         push @$attribute, ['name', $anchor_name];
       }
 
+      my $space_after_command_attribute;
+      if ($element->{'info'}
+          and $element->{'info'}->{'spaces_after_cmd_before_arg'}) {
+        $space_after_command_attribute = ['spacesaftercmd',
+              _protect_in_spaces_attribute_text(
+                $element->{'info'}->{'spaces_after_cmd_before_arg'})];
+      }
+
       my @format_elements;
       my $main_cmdname;
       if ($commands_args_elements{$element->{'cmdname'}}) {
@@ -1055,6 +1064,8 @@ sub _convert($$;$)
         # leading spaces are directly associated to the @-command for @-command
         # in context brace_commands
         push @$attribute, _leading_spaces_arg($element);
+        push @$attribute, $space_after_command_attribute
+           if (defined($space_after_command_attribute));
       }
 
       if ($Texinfo::Commands::brace_commands{$element->{'cmdname'}} eq 
'context') {
@@ -1104,8 +1115,9 @@ sub _convert($$;$)
           # inline conditional arguments.
           } elsif (defined($main_cmdname)
                    and not $brace_commands{$element->{'cmdname'}} eq 'inline') 
{
-            $last_empty_element = 
$self->txi_markup_open_element($format_element)
-                                  
.$self->txi_markup_close_element($format_element);
+            $last_empty_element
+               = $self->txi_markup_open_element($format_element)
+                           .$self->txi_markup_close_element($format_element);
           }
           $attribute = [];
         } else {
@@ -1125,6 +1137,8 @@ sub _convert($$;$)
       }
       # This is for the main command
       $attribute = [];
+      push @$attribute, $space_after_command_attribute
+           if (defined($space_after_command_attribute));
       if ($element->{'cmdname'} eq 'image') {
         if (Texinfo::Common::element_is_inline($element)) {
           push @$attribute, ['where', 'inline'];
diff --git a/tp/Texinfo/Convert/TexinfoXML.pm b/tp/Texinfo/Convert/TexinfoXML.pm
index fc423647e6..e9932c12a3 100644
--- a/tp/Texinfo/Convert/TexinfoXML.pm
+++ b/tp/Texinfo/Convert/TexinfoXML.pm
@@ -113,10 +113,11 @@ sub _xml_attributes($$)
     # even protected (and even in xml 1.1 in contrast to what is said on
     # internet).  Cf above the full explanation for XML 1.0.
     if ($attribute_spec->[0] ne 'spaces'
-        and $attribute_spec->[0] ne 'trailingspaces') {
+        and $attribute_spec->[0] ne 'trailingspaces'
+        and $attribute_spec->[0] ne 'spacesaftercmd') {
       $text =~ s/\f/&attrformfeed;/g;
       $text =~ s/\N{U+000B}/&attrverticaltab;/g;
-      # &attrformfeed; and similar resolves to \f and similar so \ are doubled
+      # &attrformfeed; and similar resolves to \f and similar so \ are doubled.
       $text =~ s/\\/\\\\/g;
     }
     my $attribute_name = $attribute_spec->[0];
diff --git a/tp/t/02coverage.t b/tp/t/02coverage.t
index 8d368e5e82..014efe91ee 100644
--- a/tp/t/02coverage.t
+++ b/tp/t/02coverage.t
@@ -585,6 +585,23 @@ In float with caption.
 ['at_after_accent_command',
 '@ringaccent @@. @^@@.
 '],
+['spaces_after_braced_command',
+'@code {b}
+
+@samp
+{v}
+
+@AA
+ {}
+
+@email
+{a, b 
+ }
+
+@TeX
+
+{}
+'],
 ['setfilename_in_paragraph',
 'Some text
 @setfilename setfilename_in_paragraph.info
@@ -691,23 +708,6 @@ continue on other line}
 
 cut by blank line}
 '],
-['spaces_after_braced_command',
-'@code {b}
-
-@samp
-{v}
-
-@AA
- {}
-
-@email
-{a, b 
- }
-
-@TeX
-
-{}
-'],
 ['spaces_no_brace_after_braced_command',
 '@code b
 '],
diff --git a/tp/t/results/coverage/lettered_accent_and_spaces.pl 
b/tp/t/results/coverage/lettered_accent_and_spaces.pl
index 49a34528b6..9b207c838b 100644
--- a/tp/t/results/coverage/lettered_accent_and_spaces.pl
+++ b/tp/t/results/coverage/lettered_accent_and_spaces.pl
@@ -440,22 +440,17 @@ circ;
 
 $result_converted{'xml'}->{'lettered_accent_and_spaces'} = '<para><accent 
type="ring" spaces="    " bracketed="off">a</accent>
 </para>
-<para><accent type="ring" spaces="
-">a</accent>
+<para><accent type="ring" spaces="\\n">a</accent>
 </para>
-<para><accent type="ring" spaces="
-" bracketed="off">a</accent>
+<para><accent type="ring" spaces="\\n" bracketed="off">a</accent>
 </para>
-<para><accent type="ring" spaces="
-  " bracketed="off">a</accent>
+<para><accent type="ring" spaces="\\n  " bracketed="off">a</accent>
 </para>
 <para><accent type="circ" spaces=" " bracketed="off">a</accent>
 </para>
-<para><accent type="circ" spaces="
-" bracketed="off">a</accent>
+<para><accent type="circ" spaces="\\n" bracketed="off">a</accent>
 </para>
-<para><accent type="circ" spaces="
- " bracketed="off">a</accent>
+<para><accent type="circ" spaces="\\n " bracketed="off">a</accent>
 </para>
 <para><accent type="circ" spaces=" ">a
 </accent>
diff --git a/tp/t/results/coverage/spaces_after_braced_command.pl 
b/tp/t/results/coverage/spaces_after_braced_command.pl
index 1810268940..8da72319f5 100644
--- a/tp/t/results/coverage/spaces_after_braced_command.pl
+++ b/tp/t/results/coverage/spaces_after_braced_command.pl
@@ -302,4 +302,72 @@ $result_errors{'spaces_after_braced_command'} = [
 $result_floats{'spaces_after_braced_command'} = {};
 
 
+
+$result_converted{'plaintext'}->{'spaces_after_braced_command'} = '‘b’
+
+   ‘v’
+
+   Å
+
+   b <a>
+
+   TeX
+';
+
+
+$result_converted{'html_text'}->{'spaces_after_braced_command'} = '<p><code 
class="code">b</code>
+</p>
+<p>&lsquo;<samp class="samp">v</samp>&rsquo;
+</p>
+<p>&Aring;
+</p>
+<p><a class="email" href="mailto:a";>b 
+</a>
+</p>
+<p>TeX
+
+</p>';
+
+
+$result_converted{'xml'}->{'spaces_after_braced_command'} = '<para><code 
spacesaftercmd=" ">b</code>
+</para>
+<para><samp spacesaftercmd="\\n">v</samp>
+</para>
+<para>&Aring;
+</para>
+<para><email spacesaftercmd="\\n"><emailaddress>a</emailaddress><emailname 
spaces=" ">b 
+ </emailname></email>
+</para>
+<para>&tex;
+
+</para>';
+
+
+$result_converted{'latex_text'}->{'spaces_after_braced_command'} = '\\texttt{b}
+
+`\\texttt{v}\'
+
+\\AA{}
+
+\\href{mailto:a}{b 
+}
+
+\\TeX{}
+
+';
+
+
+$result_converted{'docbook'}->{'spaces_after_braced_command'} = 
'<para><literal>b</literal>
+</para>
+<para>&#8216;<literal>v</literal>&#8217;
+</para>
+<para>&#197;
+</para>
+<para><ulink url="mailto:a";>b 
+</ulink>
+</para>
+<para>&tex;
+
+</para>';
+
 1;
diff --git a/util/txixml2texi.pl b/util/txixml2texi.pl
index b6f11c7763..e7671f6835 100755
--- a/util/txixml2texi.pl
+++ b/util/txixml2texi.pl
@@ -233,6 +233,21 @@ sub skip_until_end($$)
   }
 }
 
+sub unprotect_spaces($)
+{
+  my $spaces = shift;
+
+  if (defined($spaces)) {
+    $spaces =~ s/\\n/\n/g;
+    # convert back formfeed and other special characters
+    $spaces =~ s/\\f/\f/g;
+    $spaces =~ s/\\v/\x{000B}/g;
+    return $spaces;
+  } else {
+    return '';
+  }
+}
+
 my $eat_space = 0;
 my $skip_comment = 0;
 my @commands_with_args_stack;
@@ -287,20 +302,14 @@ while ($reader->read) {
     if ($Texinfo::Convert::TexinfoMarkup::commands_args_elements{$name}) {
       push @commands_with_args_stack, [$name, 0];
     }
-    my $spaces = $reader->getAttribute('spaces');
-    if (defined($spaces)) {
-      $spaces =~ s/\\n/\n/g;
-      # convert back formfeed and other special characters
-      $spaces =~ s/\\f/\f/g;
-      $spaces =~ s/\\v/\x{000B}/g;
-    } else {
-      $spaces = '';
-    }
+    my $spaces = unprotect_spaces($reader->getAttribute('spaces'));
+    my $spaces_after_command
+      = unprotect_spaces($reader->getAttribute('spacesaftercmd'));
     if ($name eq 'accent') {
       if ($reader->hasAttributes()) {
         if (defined($reader->getAttribute('type'))) {
           my $command = $accent_type_command{$reader->getAttribute('type')};
-          print "\@$command"
+          print "\@${command}${spaces_after_command}"
             if (defined($command));
         }
         print "$spaces";
@@ -319,11 +328,12 @@ while ($reader->read) {
         if ($reader->hasAttributes()
             and defined($reader->getAttribute($attribute))) {
           print
-            
$element_at_commands{$name}->{$attribute}->{$reader->getAttribute($attribute)};
+            $element_at_commands{$name}->{$attribute}->{
+                             $reader->getAttribute($attribute)};
         }
       }
     } elsif (exists($Texinfo::Commands::brace_commands{$name})) {
-      print "\@${name}\{";
+      print "\@${name}${spaces_after_command}\{";
       if ($name eq 'verb' and $reader->hasAttributes()
           and defined($reader->getAttribute('delimiter'))) {
         print $reader->getAttribute('delimiter');
@@ -490,8 +500,8 @@ while ($reader->read) {
     my $trailingspaces = '';
     if ($reader->hasAttributes()
         and defined($reader->getAttribute('trailingspaces'))) {
-      $trailingspaces = $reader->getAttribute('trailingspaces');
-      $trailingspaces =~ s/\\f/\f/g;
+      $trailingspaces
+         = unprotect_spaces($reader->getAttribute('trailingspaces'));
     }
     if ($reader->hasAttributes()) {
       if (defined($reader->getAttribute('bracketed'))



reply via email to

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