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:57:40 -0400 (EDT)

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

    * tp/Texinfo/Convert/Text.pm (%ignored_types, %ignored_text_types)
    (_convert): process text elements first.
---
 ChangeLog                  |  5 ++++
 tp/Texinfo/Convert/Text.pm | 62 ++++++++++++++++++++++++++--------------------
 2 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d268651ba3..25d6618e35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-07-01  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Text.pm (%ignored_types, %ignored_text_types)
+       (_convert): process text elements first.
+
 2024-07-01  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Makefile.tres, tp/t/08misc_commands.t (comment_without_line): add
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 27f3ba5955..cc02c2be6a 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -127,16 +127,19 @@ foreach my $command (keys(%def_commands)) {
 }
 
 my %ignored_types;
+foreach my $type ('postamble_after_end',
+            'preamble_before_beginning') {
+  $ignored_types{$type} = 1;
+}
+
+my %ignored_text_types;
 foreach my $type ('ignorable_spaces_after_command',
-            'postamble_after_end',
-            'preamble_before_beginning',
             'spaces_at_end',
             'spaces_before_paragraph',
             'spaces_after_close_brace') {
-  $ignored_types{$type} = 1;
+  $ignored_text_types{$type} = 1;
 }
 
-
 my @text_indicator_converter_options
       = ('ASCII_GLYPH', 'NUMBER_SECTIONS', 'TEST');
 
@@ -486,6 +489,32 @@ sub _convert($$)
     confess("Texinfo::Convert::Text::_convert: element undef");
   }
 
+  if (defined($element->{'text'})) {
+    if ($element->{'type'} and $ignored_text_types{$element->{'type'}}) {
+      return '';
+    }
+    my $result = $element->{'text'};
+    if ((! defined($element->{'type'})
+         or $element->{'type'} ne 'raw')
+        and !$options->{'_raw_state'}) {
+      if ($options->{'set_case'}) {
+        if ($options->{'set_case'} > 0) {
+          $result = uc($result);
+        } else {
+          $result = lc($result);
+        }
+      }
+      if (!$options->{'_code_state'}) {
+        $result =~ s/``/"/g;
+        $result =~ s/\'\'/"/g;
+        $result =~ s/---/\x{1F}/g;
+        $result =~ s/--/-/g;
+        $result =~ s/\x{1F}/--/g;
+      }
+    }
+    return $result;
+  }
+
   return '' if (!($element->{'type'} and $element->{'type'} eq 'def_line')
      and (($element->{'type'} and $ignored_types{$element->{'type'}})
           or ($element->{'cmdname'}
@@ -511,36 +540,15 @@ sub _convert($$)
                              and (!$element->{'extra'}
                                   or 
!defined($element->{'extra'}->{'expand_index'})))))
              # here ignore most of the line commands
-                 or ($element->{'args'} and $element->{'args'}->[0]
+                 or ($element->{'args'}
                      and $element->{'args'}->[0]->{'type'}
                      and ($element->{'args'}->[0]->{'type'} eq 'line_arg'
                          or $element->{'args'}->[0]->{'type'} eq 'rawline_arg')
                      and !$formatted_line_commands{$element->{'cmdname'}}
                      and !$converted_formattable_line_commands{
                                                     
$element->{'cmdname'}})))));
+
   my $result = '';
-  if (defined($element->{'text'})) {
-    $result = $element->{'text'};
-    if ((! defined($element->{'type'})
-         or $element->{'type'} ne 'raw')
-        and !$options->{'_raw_state'}) {
-      if ($options->{'set_case'}) {
-        if ($options->{'set_case'} > 0) {
-          $result = uc($result);
-        } else {
-          $result = lc($result);
-        }
-      }
-      if (!$options->{'_code_state'}) {
-        $result =~ s/``/"/g;
-        $result =~ s/\'\'/"/g;
-        $result =~ s/---/\x{1F}/g;
-        $result =~ s/--/-/g;
-        $result =~ s/\x{1F}/--/g;
-      }
-    }
-    return $result;
-  }
   if ($element->{'cmdname'}) {
     my $command = $element->{'cmdname'};
     if (defined($nobrace_symbol_text{$element->{'cmdname'}})) {



reply via email to

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