texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_text): in


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_text): in space_protected, protect spaces in 'line_break_element' before prepending and replacing spaces with 'non_breaking_space'. The unprotection is already implemented.
Date: Sat, 14 Jan 2023 17:48:55 -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 1f61b08b60 * tp/Texinfo/Convert/HTML.pm (_convert_text): in 
space_protected, protect spaces in 'line_break_element' before prepending and 
replacing spaces with 'non_breaking_space'.  The unprotection is already 
implemented.
1f61b08b60 is described below

commit 1f61b08b60c33f6307d9002ac12f2db961eb17e0
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jan 14 23:48:44 2023 +0100

    * tp/Texinfo/Convert/HTML.pm (_convert_text): in space_protected,
    protect spaces in 'line_break_element' before prepending and
    replacing spaces with 'non_breaking_space'.  The unprotection is
    already implemented.
    
    * tp/Makefile.am (test_files), tp/Makefile.tres, tp/t/html_tests.t:
    add the spaces_in_line_break_in_verb_w test testing space in
    line_break_element.  There is no API to modify line_break_element,
    so $self->{'line_break_element'} is directly set in an init file.
---
 ChangeLog                                          |  12 ++
 tp/Makefile.am                                     |   1 +
 tp/Makefile.tres                                   |   1 +
 tp/Texinfo/Convert/HTML.pm                         |  13 +-
 tp/t/html_tests.t                                  |   8 ++
 tp/t/init/spaces_in_line_breaks.init               |  12 ++
 .../html_tests/spaces_in_line_break_in_verb_w.pl   | 152 +++++++++++++++++++++
 7 files changed, 198 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 75001bf57f..b9fc6aebc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2023-01-14  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_text): in space_protected,
+       protect spaces in 'line_break_element' before prepending and
+       replacing spaces with 'non_breaking_space'.  The unprotection is
+       already implemented.
+
+       * tp/Makefile.am (test_files), tp/Makefile.tres, tp/t/html_tests.t:
+       add the spaces_in_line_break_in_verb_w test testing space in
+       line_break_element.  There is no API to modify line_break_element,
+       so $self->{'line_break_element'} is directly set in an init file.
+
 2023-01-13  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_parse_texi),
diff --git a/tp/Makefile.am b/tp/Makefile.am
index b34d8ad586..19cc92ca4c 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -180,6 +180,7 @@ test_files = \
  t/init/translate_txiinternalvalue_macro.init \
  t/init/translated_strings_customization.pm \
  t/init/undef_node_file_name.init \
+ t/init/spaces_in_line_breaks.init \
  t/test_utils.pl \
  t/input_files/all_spaces.texi \
  t/input_files/bib-example.texi \
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 0c9ba1b24f..a58a80acd0 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -620,6 +620,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/html_tests/simple_menu_in_example.pl \
   t/results/html_tests/simplest_test_date_in_header.pl \
   t/results/html_tests/simplest_test_date_in_header/res_html \
+  t/results/html_tests/spaces_in_line_break_in_verb_w.pl \
   t/results/html_tests/split_html_text.pl \
   t/results/html_tests/test_accents_sc_default.pl \
   t/results/html_tests/test_accents_sc_default/res_html \
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 2cc6da5e97..8dd0f1c951 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -6301,7 +6301,18 @@ sub _convert_text($$$)
   # API info: in_space_protected() API code conforming would be:
   #} elsif ($self->in_space_protected()) {
   } elsif ($formatting_context->{'space_protected'}) {
-    $text .= $self->{'line_break_element'} if (chomp($text));
+    if (chomp($text)) {
+      # API info: API code conforming would be:
+      # $self->get_info('line_break_element')
+      my $line_break_element = $self->{'line_break_element'};
+      # protect spaces in line_break_element formatting.
+      # Note that this case is theoretical right now, as it is not possible
+      # to redefine $self->{'line_break_element'} and there are no spaces
+      # in the possible values.  However this is a deficiency of the API,
+      # it would be better to be able to redefine $self->{'line_break_element'}
+      $line_break_element =~ s/ /\x{1F}/g;
+      $text .= $line_break_element;
+    }
     # Protect spaces within text
     my $non_breaking_space = $self->get_info('non_breaking_space');
     $text =~ s/ /$non_breaking_space/g;
diff --git a/tp/t/html_tests.t b/tp/t/html_tests.t
index 38ecfbb7c1..409b74aae4 100644
--- a/tp/t/html_tests.t
+++ b/tp/t/html_tests.t
@@ -605,6 +605,14 @@ In top.
 '
 @titlefont{}
 '],
+['spaces_in_line_break_in_verb_w',
+'@w{aaa  bb
+ccc}
+
+@verb{|aaa  bb
+ccc|}
+', {'init_files' => ['spaces_in_line_breaks.init']},
+],
 );
 
 my $test_accents_sc_no_brace_commands_quotes = '@u{--a}
diff --git a/tp/t/init/spaces_in_line_breaks.init 
b/tp/t/init/spaces_in_line_breaks.init
new file mode 100644
index 0000000000..3945efc4e4
--- /dev/null
+++ b/tp/t/init/spaces_in_line_breaks.init
@@ -0,0 +1,12 @@
+
+# There is no API to set $self->{'line_break_element'}.
+
+texinfo_register_handler('setup', \&_texi2any_tests_set_line_break_element);
+
+sub _texi2any_tests_set_line_break_element
+{
+  my ($self, $tree, $stage) = @_;
+
+  $self->{'line_break_element'} = '<br >';
+  return 0;
+}
diff --git a/tp/t/results/html_tests/spaces_in_line_break_in_verb_w.pl 
b/tp/t/results/html_tests/spaces_in_line_break_in_verb_w.pl
new file mode 100644
index 0000000000..81b413a0f8
--- /dev/null
+++ b/tp/t/results/html_tests/spaces_in_line_break_in_verb_w.pl
@@ -0,0 +1,152 @@
+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{'spaces_in_line_break_in_verb_w'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'contents' => [
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'aaa  bb
+'
+                    },
+                    {
+                      'text' => 'ccc'
+                    }
+                  ],
+                  'type' => 'brace_command_arg'
+                }
+              ],
+              'cmdname' => 'w',
+              'source_info' => {
+                'file_name' => '',
+                'line_nr' => 1,
+                'macro' => ''
+              }
+            },
+            {
+              'text' => '
+'
+            }
+          ],
+          'type' => 'paragraph'
+        },
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'contents' => [
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'aaa  bb
+',
+                      'type' => 'raw'
+                    },
+                    {
+                      'text' => 'ccc',
+                      'type' => 'raw'
+                    }
+                  ],
+                  'type' => 'brace_command_arg'
+                }
+              ],
+              'cmdname' => 'verb',
+              'info' => {
+                'delimiter' => '|'
+              },
+              'source_info' => {
+                'file_name' => '',
+                'line_nr' => 4,
+                'macro' => ''
+              }
+            },
+            {
+              'text' => '
+'
+            }
+          ],
+          'type' => 'paragraph'
+        }
+      ],
+      'type' => 'before_node_section'
+    }
+  ],
+  'type' => 'document_root'
+};
+
+$result_texis{'spaces_in_line_break_in_verb_w'} = '@w{aaa  bb
+ccc}
+
+@verb{|aaa  bb
+ccc|}
+';
+
+
+$result_texts{'spaces_in_line_break_in_verb_w'} = 'aaa  bb
+ccc
+
+aaa  bb
+ccc
+';
+
+$result_errors{'spaces_in_line_break_in_verb_w'} = [];
+
+
+$result_floats{'spaces_in_line_break_in_verb_w'} = {};
+
+
+
+$result_converted{'html'}->{'spaces_in_line_break_in_verb_w'} = '<!DOCTYPE 
html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Untitled Document</title>
+
+<meta name="description" content="Untitled Document">
+<meta name="keywords" content="Untitled Document">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+
+
+</head>
+
+<body lang="en">
+<p>aaa&nbsp;bb&nbsp;ccc<!-- /@w -->
+</p>
+<p><code class="verb">aaa&nbsp;&nbsp;bb<br >ccc</code>
+</p>
+
+
+</body>
+</html>
+';
+
+$result_converted_errors{'html'}->{'spaces_in_line_break_in_verb_w'} = [
+  {
+    'error_line' => 'warning: must specify a title with a title command or @top
+',
+    'file_name' => 'spaces_in_line_break_in_verb_w.texi',
+    'text' => 'must specify a title with a title command or @top',
+    'type' => 'warning'
+  }
+];
+
+
+1;



reply via email to

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