texinfo-commits
[Top][All Lists]
Advanced

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

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


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/DocBook.pm (_new_document_context): Add the _new_document_context function to push a new documeent context.
Date: Sat, 14 Jan 2023 18:16:12 -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 ae99f6a963 * tp/Texinfo/Convert/DocBook.pm (_new_document_context): 
Add the _new_document_context function to push a new documeent context.
ae99f6a963 is described below

commit ae99f6a963302a804d939c566ef94c7d3f3d00fd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 15 00:16:02 2023 +0100

    * tp/Texinfo/Convert/DocBook.pm (_new_document_context): Add the
    _new_document_context function to push a new documeent context.
    
    * tp/Texinfo/Convert/DocBook.pm (_convert): add 'no_break'
    in document context for @w, and protect text with non-breakable spaces
    in that context.  Report from Gavin.
---
 ChangeLog                                          |  9 ++++++
 tp/Texinfo/Convert/DocBook.pm                      | 36 +++++++++++++++++-----
 .../converters_tests/spaces_in_empty_node_names.pl |  2 +-
 .../converters_tests/spaces_in_node_names.pl       |  2 +-
 tp/t/results/coverage/empty_w.pl                   |  2 +-
 .../formats_encodings/at_commands_in_refs.pl       |  4 +--
 6 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b9fc6aebc3..bc8e37d7d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-01-14  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/DocBook.pm (_new_document_context): Add the
+       _new_document_context function to push a new documeent context.
+
+       * tp/Texinfo/Convert/DocBook.pm (_convert): add 'no_break'
+       in document context for @w, and protect text with non-breakable spaces
+       in that context.  Report from Gavin.
+
 2023-01-14  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/HTML.pm (_convert_text): in space_protected,
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 54e6445744..53a4ffb305 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -276,7 +276,8 @@ sub converter_initialize($)
 {
   my $self = shift;
 
-  $self->{'document_context'} = [{'monospace' => [0], 'upper_case' => [0]}];
+  $self->{'document_context'} = [];
+  $self->_new_document_context();
   $self->{'context_block_commands'} = {%default_context_block_commands};
   foreach my $raw (grep {$Texinfo::Commands::block_commands{$_} eq 
'format_raw'}
                         keys(%Texinfo::Commands::block_commands)) {
@@ -577,7 +578,7 @@ sub _index_entry($$)
     # FIXME DocBook 5 role->type
     my $result = "<indexterm role=\"$index_entry->{'index_name'}\">";
 
-    push @{$self->{'document_context'}}, {'monospace' => [0], 'upper_case' => 
[0]};
+    $self->_new_document_context();
     $self->{'document_context'}->[-1]->{'monospace'}->[-1] = 1
       if ($index_entry->{'in_code'});
 
@@ -648,6 +649,16 @@ sub _convert_argument_and_end_line($$)
   return ($converted, $end_line);
 }
 
+sub _new_document_context($)
+{
+  my $self = shift;
+  push (@{$self->{'document_context'}}, {
+                            'monospace' => [0],
+                            'upper_case' => [0],
+                            'no_break' => [0],
+                          });
+}
+
 my $debug_global_element_nr = 0;
 
 
@@ -685,6 +696,10 @@ sub _convert($$;$)
     if ($self->{'document_context'}->[-1]->{'upper_case'}->[-1]) {
       $result = uc($result);
     }
+    if ($self->{'document_context'}->[-1]->{'no_break'}->[-1]) {
+      $result =~ s/\n/ /g;
+      $result =~ s/ +/$nbsp/g;
+    }
     $result = $self->_protect_text($result);
     if (! defined($element->{'type'}) or $element->{'type'} ne 'raw') {
       if (!$self->{'document_context'}->[-1]->{'monospace'}->[-1]) {
@@ -971,8 +986,7 @@ sub _convert($$;$)
       #Texinfo::Common::debug_list(" brace command with args", 
$element->{'args'});
       if ($style_commands_formatting{$element->{'cmdname'}}) {
         if ($Texinfo::Commands::brace_commands{$element->{'cmdname'}} eq 
'context') {
-          push (@{$self->{'document_context'}},
-                {'monospace' => [0], 'upper_case' => [0]});
+          $self->_new_document_context();
         }
         my $formatting = $style_commands_formatting{$element->{'cmdname'}};
 
@@ -987,6 +1001,9 @@ sub _convert($$;$)
         if ($formatting->{'upper_case'}) {
           push @{$self->{'document_context'}->[-1]->{'upper_case'}}, 1;
         }
+        if ($element->{'cmdname'} eq 'w') {
+          push @{$self->{'document_context'}->[-1]->{'no_break'}}, 1;
+        }
         push @{$self->{'document_context'}->[-1]->{'monospace'}}, 
           $in_monospace_not_normal
             if (defined($in_monospace_not_normal));
@@ -1007,6 +1024,9 @@ sub _convert($$;$)
         if (defined($formatting->{'upper_case'})) {
           pop @{$self->{'document_context'}->[-1]->{'upper_case'}};
         }
+        if ($element->{'cmdname'} eq 'w') {
+          pop @{$self->{'document_context'}->[-1]->{'no_break'}};
+        }
         pop @{$self->{'document_context'}->[-1]->{'monospace'}}
           if (defined($in_monospace_not_normal));
         if ($Texinfo::Commands::brace_commands{$element->{'cmdname'}} eq 
'context') {
@@ -1404,7 +1424,7 @@ sub _convert($$;$)
         return '' if (! $expand);
         my $arg_index = 1;
         if ($element->{'cmdname'} eq 'inlineraw') {
-          push @{$self->{'document_context'}}, {'monospace' => [0], 
'upper_case' => [0]};
+          $self->_new_document_context();
           $self->{'document_context'}->[-1]->{'raw'} = 1;
         } elsif ($element->{'cmdname'} eq 'inlinefmtifelse'
                  and ! 
$self->{'expanded_formats_hash'}->{$element->{'extra'}->{'format'}}) {
@@ -1437,8 +1457,7 @@ sub _convert($$;$)
         return '';
       }
       if ($self->{'context_block_commands'}->{$element->{'cmdname'}}) {
-        push (@{$self->{'document_context'}},
-              {'monospace' => [0], 'upper_case' => [0]});
+        $self->_new_document_context();
       }
       my @attributes;
       my $appended = '';
@@ -1589,7 +1608,8 @@ sub _convert($$;$)
     } elsif ($element->{'type'} eq 'def_line') {
       $result .= "<synopsis>";
       $result .= $self->_index_entry($element);
-      push @{$self->{'document_context'}}, {'monospace' => [1], 'upper_case' 
=> [0]};
+      $self->_new_document_context();
+      $self->{'document_context'}->[-1]->{'monospace'}->[0] = 1;
       $self->{'document_context'}->[-1]->{'inline'}++;
       if ($element->{'args'} and @{$element->{'args'}}
           and $element->{'args'}->[0]->{'contents'}) {
diff --git a/tp/t/results/converters_tests/spaces_in_empty_node_names.pl 
b/tp/t/results/converters_tests/spaces_in_empty_node_names.pl
index 6bf81780a9..c251168766 100644
--- a/tp/t/results/converters_tests/spaces_in_empty_node_names.pl
+++ b/tp/t/results/converters_tests/spaces_in_empty_node_names.pl
@@ -851,7 +851,7 @@ 
$result_converted{'docbook'}->{'spaces_in_empty_node_names'} = '
 </para>
 <para><link linkend="-"><literal>  </literal></link>
 </para>
-<para><link linkend="-">  <!-- /@w --></link>
+<para><link linkend="-">&amp;#160;<!-- /@w --></link>
 </para>';
 
 
diff --git a/tp/t/results/converters_tests/spaces_in_node_names.pl 
b/tp/t/results/converters_tests/spaces_in_node_names.pl
index 333573349f..8b864e9494 100644
--- a/tp/t/results/converters_tests/spaces_in_node_names.pl
+++ b/tp/t/results/converters_tests/spaces_in_node_names.pl
@@ -950,7 +950,7 @@ $result_converted{'docbook'}->{'spaces_in_node_names'} = 
'<anchor id="a-"/>
 </para>
 <para><link linkend="b-">b<literal>  </literal></link>
 </para>
-<para><link linkend="c-">c  <!-- /@w --></link>
+<para><link linkend="c-">c&amp;#160;<!-- /@w --></link>
 </para>';
 
 
diff --git a/tp/t/results/coverage/empty_w.pl b/tp/t/results/coverage/empty_w.pl
index 943ec39a03..73fc842c96 100644
--- a/tp/t/results/coverage/empty_w.pl
+++ b/tp/t/results/coverage/empty_w.pl
@@ -83,6 +83,6 @@ $result_converted{'xml'}->{'empty_w'} = '<para><w></w> <w>a 
b</w>.</para>';
 $result_converted{'latex_text'}->{'empty_w'} = '\\hbox{} \\hbox{a b}.';
 
 
-$result_converted{'docbook'}->{'empty_w'} = '<para><!-- /@w --> a b<!-- /@w 
-->.</para>';
+$result_converted{'docbook'}->{'empty_w'} = '<para><!-- /@w --> 
a&amp;#160;b<!-- /@w -->.</para>';
 
 1;
diff --git a/tp/t/results/formats_encodings/at_commands_in_refs.pl 
b/tp/t/results/formats_encodings/at_commands_in_refs.pl
index 2a38e6a13c..c4cd67d91f 100644
--- a/tp/t/results/formats_encodings/at_commands_in_refs.pl
+++ b/tp/t/results/formats_encodings/at_commands_in_refs.pl
@@ -18432,7 +18432,7 @@ $result_converted{'docbook'}->{'at_commands_in_refs'} = 
'<chapter label="1" id="
 
 </chapter>
 <chapter label="21" id="cite-asis-in-_0040w-b-in-r-SC-str-t-var-dfn-i">
-<title><citetitle>cite asis</citetitle> in @w <emphasis 
role="bold">b</emphasis><!-- /@w --> in r SC <emphasis 
role="bold">str</emphasis> <literal>t</literal> <replaceable>var</replaceable> 
<firstterm>dfn</firstterm> <emphasis>i</emphasis></title>
+<title><citetitle>cite asis</citetitle> in&amp;#160;@w&amp;#160;<emphasis 
role="bold">b</emphasis><!-- /@w --> in r SC <emphasis 
role="bold">str</emphasis> <literal>t</literal> <replaceable>var</replaceable> 
<firstterm>dfn</firstterm> <emphasis>i</emphasis></title>
 
 </chapter>
 <chapter label="22" id="env-code-option-samp-command-file-C_002dx-ESC">
@@ -18499,7 +18499,7 @@ $result_converted{'docbook'}->{'at_commands_in_refs'} = 
'<chapter label="1" id="
 </para>
 <para><link linkend="-_0040-_007b_007d-_002e-"><literal> @ {} . 
</literal></link>
 </para>
-<para><link 
linkend="cite-asis-in-_0040w-b-in-r-SC-str-t-var-dfn-i"><citetitle>cite 
asis</citetitle> in @w <emphasis role="bold">b</emphasis><!-- /@w --> in r SC 
<emphasis role="bold">str</emphasis> <literal>t</literal> 
<replaceable>var</replaceable> <firstterm>dfn</firstterm> 
<emphasis>i</emphasis></link>
+<para><link 
linkend="cite-asis-in-_0040w-b-in-r-SC-str-t-var-dfn-i"><citetitle>cite 
asis</citetitle> in&amp;#160;@w&amp;#160;<emphasis role="bold">b</emphasis><!-- 
/@w --> in r SC <emphasis role="bold">str</emphasis> <literal>t</literal> 
<replaceable>var</replaceable> <firstterm>dfn</firstterm> 
<emphasis>i</emphasis></link>
 </para>
 <para><link 
linkend="env-code-option-samp-command-file-C_002dx-ESC"><envar>env</envar> 
<literal>code</literal> <option>option</option> 
&#8216;<literal>samp</literal>&#8217; <command>command</command> 
<filename>file</filename> <userinput>C-x <keycap>ESC</keycap></userinput></link>
 </para>



reply via email to

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