texinfo-commits
[Top][All Lists]
Advanced

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

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


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/Text.pm (_convert), tp/Texinfo/XS/convert/convert_html.c (convert_uref_command), tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal): handle @url without braces, with 0 args.
Date: Sun, 29 Sep 2024 09:41:32 -0400

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 7a0f136b1a * tp/Texinfo/Convert/Text.pm (_convert), 
tp/Texinfo/XS/convert/convert_html.c (convert_uref_command), 
tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal): handle @url 
without braces, with 0 args.
7a0f136b1a is described below

commit 7a0f136b1a7b0fe7cf38ec13746e1728d6fca50c
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jul 1 15:53:43 2024 +0200

    * tp/Texinfo/Convert/Text.pm (_convert),
    tp/Texinfo/XS/convert/convert_html.c (convert_uref_command),
    tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal):
    handle @url without braces, with 0 args.
    
    * tp/Makefile.tres, tp/t/03coverage_braces.t (url_no_braces): test of
    @url without braces at end of document.
---
 ChangeLog                                     | 10 ++++
 tp/Makefile.tres                              |  1 +
 tp/TODO                                       |  2 -
 tp/Texinfo/Convert/Text.pm                    | 50 +++++++++++--------
 tp/Texinfo/XS/convert/convert_html.c          |  3 ++
 tp/Texinfo/XS/main/convert_to_text.c          | 71 ++++++++++++++-------------
 tp/t/03coverage_braces.t                      |  1 +
 tp/t/results/coverage_braces/url_no_braces.pl | 58 ++++++++++++++++++++++
 8 files changed, 139 insertions(+), 57 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 133143e90f..a312b486eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-07-01  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Text.pm (_convert),
+       tp/Texinfo/XS/convert/convert_html.c (convert_uref_command),
+       tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal):
+       handle @url without braces, with 0 args.
+
+       * tp/Makefile.tres, tp/t/03coverage_braces.t (url_no_braces): test of
+       @url without braces at end of document.
+
 2024-07-01  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/DocBook.pm (_convert),
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 5e983bdfbb..8d5f7160ed 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -447,6 +447,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/coverage_braces/uref_in_ref.pl \
   t/results/coverage_braces/uref_url.pl \
   t/results/coverage_braces/uref_with_commands_characters.pl \
+  t/results/coverage_braces/url_no_braces.pl \
   t/results/coverage_braces/verb_in_xref.pl \
   t/results/coverage_braces/w_end_sentence.pl \
   t/results/def/adjacent_defline.pl \
diff --git a/tp/TODO b/tp/TODO
index 84653b6f62..117eab0492 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -11,13 +11,11 @@ Before next release
 ===================
 
 test of
-@url
 @math
 @strong
 @footnote
 @caption
 @hyphenation
-@exdent
 
 Bugs
 ====
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 5be0800f54..81828a9168 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -591,29 +591,37 @@ sub _convert($$)
       } else {
         return '';
       }
-    } elsif ($element->{'cmdname'} eq 'uref' or $element->{'cmdname'} eq 
'url') {
-      my $replacement;
-      $replacement = _convert($options, $element->{'args'}->[2])
-        if (defined($element->{'args'}->[2]));
-      return $replacement if (defined($replacement) and $replacement ne '');
-      my $text;
-      $text = _convert($options, $element->{'args'}->[1])
-        if (defined($element->{'args'}->[1]));
-      $options->{'_code_state'}++;
-      my $url = _convert($options, $element->{'args'}->[0]);
-      $options->{'_code_state'}--;
-      if (defined($text) and $text ne '') {
-        return "$url ($text)";
+    } elsif ($element->{'cmdname'} eq 'uref'
+             or $element->{'cmdname'} eq 'url') {
+      if ($element->{'args'}) {
+        my $replacement;
+        $replacement = _convert($options, $element->{'args'}->[2])
+          if (defined($element->{'args'}->[2]));
+        return $replacement if (defined($replacement) and $replacement ne '');
+        my $text;
+        $text = _convert($options, $element->{'args'}->[1])
+          if (defined($element->{'args'}->[1]));
+        $options->{'_code_state'}++;
+        my $url = _convert($options, $element->{'args'}->[0]);
+        $options->{'_code_state'}--;
+        if (defined($text) and $text ne '') {
+          return "$url ($text)";
+        } else {
+          return $url;
+        }
       } else {
-        return $url;
+        return '';
       }
-    } elsif ($Texinfo::Commands::explained_commands{$element->{'cmdname'}}
-             and $element->{'args'} and $element->{'args'}->[1]) {
-      my $explanation = _convert($options, $element->{'args'}->[1]);
-      if ($explanation ne '') {
-        return _convert($options, $element->{'args'}->[0]) ." ($explanation)";
+    } elsif ($Texinfo::Commands::explained_commands{$element->{'cmdname'}}) {
+      if ($element->{'args'} and $element->{'args'}->[1]) {
+        my $explanation = _convert($options, $element->{'args'}->[1]);
+        if ($explanation ne '') {
+          return _convert($options, $element->{'args'}->[0]) ." 
($explanation)";
+        } else {
+          return _convert($options, $element->{'args'}->[0]);
+        }
       } else {
-        return _convert($options, $element->{'args'}->[0]);
+        return '';
       }
     } elsif ($Texinfo::Commands::brace_commands{$element->{'cmdname'}}
              and $Texinfo::Commands::brace_commands{$element->{'cmdname'}} eq 
'inline') {
@@ -637,7 +645,7 @@ sub _convert($$)
         $options->{'_raw_state'}--;
       }
       return $result;
-    } elsif ($element->{'args'} and $element->{'args'}->[0]
+    } elsif ($element->{'args'}
            and (($element->{'args'}->[0]->{'type'}
                 and ($element->{'args'}->[0]->{'type'} eq 'brace_container'
                      or $element->{'args'}->[0]->{'type'} eq 'brace_arg'))
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 30fd0808cc..163f7b27b4 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -9447,6 +9447,9 @@ convert_uref_command (CONVERTER *self, const enum 
command_id cmd,
   char *attribute_class;
   STRING_LIST *classes;
 
+  if (!args_formatted)
+    return;
+
   if (args_formatted->number > 0
       && args_formatted->args[0].formatted[AFT_type_url]
       && args_formatted->args[0].formatted[AFT_type_monospacestring])
diff --git a/tp/Texinfo/XS/main/convert_to_text.c 
b/tp/Texinfo/XS/main/convert_to_text.c
index b29ce3b52d..ed7b7a3447 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -748,47 +748,50 @@ convert_to_text_internal (const ELEMENT *element, 
TEXT_OPTIONS *text_options,
         }
       else if (data_cmd == CM_uref || data_cmd == CM_url)
         {
-          TEXT url_text;
-
-          if (element->e.c->args.number >= 3)
+          if (element->e.c->args.number > 0)
             {
-              TEXT replacement;
-              text_init (&replacement);
-              convert_to_text_internal (element->e.c->args.list[2],
-                                        text_options, &replacement);
-              if (replacement.end > 0)
+              TEXT url_text;
+
+              if (element->e.c->args.number >= 3)
                 {
-                  ADD(replacement.text);
-                  free (replacement.text);
-                  return;
+                  TEXT replacement;
+                  text_init (&replacement);
+                  convert_to_text_internal (element->e.c->args.list[2],
+                                            text_options, &replacement);
+                  if (replacement.end > 0)
+                    {
+                      ADD(replacement.text);
+                      free (replacement.text);
+                      return;
+                    }
                 }
-            }
 
-          text_init (&url_text);
-          text_append (&url_text, "");
-          text_options->code_state++;
-          convert_to_text_internal (element->e.c->args.list[0],
-                                    text_options, &url_text);
-          text_options->code_state--;
-          if (element->e.c->args.number >= 2)
-            {
-              TEXT text;
-              text_init (&text);
-              convert_to_text_internal (element->e.c->args.list[1],
-                                        text_options, &text);
-              if (text.end > 0)
+              text_init (&url_text);
+              text_append (&url_text, "");
+              text_options->code_state++;
+              convert_to_text_internal (element->e.c->args.list[0],
+                                        text_options, &url_text);
+              text_options->code_state--;
+              if (element->e.c->args.number >= 2)
                 {
-                  text_printf (result, "%s (%s)", url_text.text, text.text);
-                  free (text.text);
-                  free (url_text.text);
-                  return;
+                  TEXT text;
+                  text_init (&text);
+                  convert_to_text_internal (element->e.c->args.list[1],
+                                            text_options, &text);
+                  if (text.end > 0)
+                    {
+                      text_printf (result, "%s (%s)", url_text.text, 
text.text);
+                      free (text.text);
+                      free (url_text.text);
+                      return;
+                    }
                 }
-            }
 
-          if (url_text.text)
-            {
-              ADD(url_text.text);
-              free (url_text.text);
+              if (url_text.text)
+                {
+                  ADD(url_text.text);
+                  free (url_text.text);
+                }
             }
           return;
         }
diff --git a/tp/t/03coverage_braces.t b/tp/t/03coverage_braces.t
index e1c497ee59..c75ce8d237 100644
--- a/tp/t/03coverage_braces.t
+++ b/tp/t/03coverage_braces.t
@@ -93,6 +93,7 @@ my @test_cases = (
 ['image_no_braces', '@image '],
 ['abbr_no_braces', '@abbr'],
 ['email_no_braces', '@email'],
+['url_no_braces', '@url'],
 ['verb_in_xref',
 '@anchor{point}
 
diff --git a/tp/t/results/coverage_braces/url_no_braces.pl 
b/tp/t/results/coverage_braces/url_no_braces.pl
new file mode 100644
index 0000000000..54f35aa754
--- /dev/null
+++ b/tp/t/results/coverage_braces/url_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{'url_no_braces'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'contents' => [
+            {
+              'cmdname' => 'url',
+              'source_info' => {
+                'line_nr' => 1
+              }
+            }
+          ],
+          'type' => 'paragraph'
+        }
+      ],
+      'type' => 'before_node_section'
+    }
+  ],
+  'type' => 'document_root'
+};
+
+$result_texis{'url_no_braces'} = '@url';
+
+
+$result_texts{'url_no_braces'} = '';
+
+$result_errors{'url_no_braces'} = [
+  {
+    'error_line' => '@url expected braces
+',
+    'line_nr' => 1,
+    'text' => '@url expected braces',
+    'type' => 'error'
+  }
+];
+
+
+$result_floats{'url_no_braces'} = {};
+
+
+
+$result_converted{'plaintext'}->{'url_no_braces'} = '';
+
+
+$result_converted{'html_text'}->{'url_no_braces'} = '';
+
+
+$result_converted{'latex_text'}->{'url_no_braces'} = '';
+
+1;



reply via email to

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