texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Fix conditions on @kpdinputstyle example


From: Patrice Dumas
Subject: branch master updated: Fix conditions on @kpdinputstyle example
Date: Tue, 23 Aug 2022 04:02:56 -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 170342f8cd Fix conditions on @kpdinputstyle example
170342f8cd is described below

commit 170342f8cd3dbbc25d8a2abf55b1967e34690a5d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Aug 23 10:02:46 2022 +0200

    Fix conditions on @kpdinputstyle example
    
    * tp/Texinfo/ParserNonXS.pm (_kbd_formatted_as_code),
    tp/Texinfo/XS/parsetexi/parser.c (kbd_formatted_as_code),
    tp/Texinfo/Convert/LaTeX.pm (_kbd_code_style): fix formatting
    of kbd in example, it does not depend on being in @code or not,
    only of being in @example or not and the condition is kbd as
    code outside of @example, not inside.
---
 ChangeLog                                          | 11 ++++++++
 tp/Texinfo/Convert/LaTeX.pm                        |  4 +--
 tp/Texinfo/ParserNonXS.pm                          | 17 +++---------
 tp/Texinfo/XS/parsetexi/parser.c                   | 18 ++----------
 tp/t/results/latex_tests/kbdinputstyle_and_kbd.pl  | 10 +++----
 tp/t/results/misc_commands/kbdinputstyle.pl        | 32 +++++++++++-----------
 .../misc_commands/kbdinputstyle_in_table.pl        | 32 +++++++++++-----------
 7 files changed, 56 insertions(+), 68 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d0356fcf41..f24e18a476 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-08-23  Patrice Dumas  <pertusus@free.fr>
+
+       Fix conditions on @kpdinputstyle example
+
+       * tp/Texinfo/ParserNonXS.pm (_kbd_formatted_as_code),
+       tp/Texinfo/XS/parsetexi/parser.c (kbd_formatted_as_code),
+       tp/Texinfo/Convert/LaTeX.pm (_kbd_code_style): fix formatting
+       of kbd in example, it does not depend on being in @code or not,
+       only of being in @example or not and the condition is kbd as
+       code outside of @example, not inside.
+
 2022-08-23  Patrice Dumas  <pertusus@free.fr>
 
        In @r do not consider @kbd to be in code
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 0ecd47d062..6f01eed8c3 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -2000,8 +2000,8 @@ sub _kbd_code_style($)
   return (defined($kbdinputstyle)
           and ($kbdinputstyle eq 'code'
             or ($kbdinputstyle eq 'example'
-              and 
(scalar(@{$self->{'formatting_context'}->[-1]->{'preformatted_context'}})
-                   and 
$preformatted_code_commands{$self->{'formatting_context'}->[-1]->{'preformatted_context'}->[-1]}))));
+              and (not 
(scalar(@{$self->{'formatting_context'}->[-1]->{'preformatted_context'}})
+                        and 
$preformatted_code_commands{$self->{'formatting_context'}->[-1]->{'preformatted_context'}->[-1]})))));
 }
 
 sub _finish_front_cover_page($)
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 8ac280e32d..b0ec3714b2 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -1425,20 +1425,11 @@ sub _kbd_formatted_as_code($$)
   if ($self->{'kbdinputstyle'} eq 'code') {
     return 1;
   } elsif ($self->{'kbdinputstyle'} eq 'example') {
-    my $current = $current->{'parent'};
-    # first check if in code or no code brace nested commands
-    while ($current->{'parent'} and $current->{'parent'}->{'cmdname'}
-           and exists $brace_commands{$current->{'parent'}->{'cmdname'}}
-           and !exists 
$context_brace_commands{$current->{'parent'}->{'cmdname'}}) {
-      if ($brace_commands{$current->{'parent'}->{'cmdname'}} eq 'style_code') {
-        return 1;
-      } elsif ($brace_commands{$current->{'parent'}->{'cmdname'}} eq 
'style_no_code') {
-        return 0;
-      }
+    if ($self->_in_preformatted_context_not_menu()) {
+      return 0;
+    } else {
+      return 1;
     }
-    # check if in preformatted context
-    return 1
-      if $self->_in_preformatted_context_not_menu();
   }
   return 0;
 }
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index dface9a3af..12efdc4f0b 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -801,23 +801,9 @@ kbd_formatted_as_code (ELEMENT *current)
     }
   else if (global_kbdinputstyle == kbd_example)
     {
-      /* TODO: Understand what is going on here. */
-      ELEMENT *tmp = current->parent;
-      while (tmp->parent
-             && (command_flags(tmp->parent) & CF_brace)
-             && command_data(tmp->parent->cmd).data != BRACE_context)
-        {
-          if (command_data(tmp->parent->cmd).data == BRACE_style_code)
-            {
-              return 1;
-            }
-          else if (command_data(tmp->parent->cmd).data == BRACE_style_no_code)
-            {
-              return 0;
-            }
-          tmp = tmp->parent->parent;
-        }
       if (in_preformatted_context_not_menu ())
+        return 0;
+      else
         return 1;
     }
   return 0;
diff --git a/tp/t/results/latex_tests/kbdinputstyle_and_kbd.pl 
b/tp/t/results/latex_tests/kbdinputstyle_and_kbd.pl
index 037c4b1fa3..ff6d0bb403 100644
--- a/tp/t/results/latex_tests/kbdinputstyle_and_kbd.pl
+++ b/tp/t/results/latex_tests/kbdinputstyle_and_kbd.pl
@@ -361,6 +361,9 @@ $result_trees{'kbdinputstyle_and_kbd'} = {
               ],
               'cmdname' => 'kbd',
               'contents' => [],
+              'extra' => {
+                'code' => 1
+              },
               'parent' => {},
               'source_info' => {
                 'file_name' => '',
@@ -406,9 +409,6 @@ $result_trees{'kbdinputstyle_and_kbd'} = {
                   ],
                   'cmdname' => 'kbd',
                   'contents' => [],
-                  'extra' => {
-                    'code' => 1
-                  },
                   'parent' => {},
                   'source_info' => {
                     'file_name' => '',
@@ -773,10 +773,10 @@ $result_converted{'latex'}->{'kbdinputstyle_and_kbd'} = 
'\\begin{document}
 \\texttt{in example code kbdinputstyle}
 \\end{GNUTexinfopreformatted}
 
-\\GNUTexinfocommandstyletextkbd{example kbdinputstyle}
+\\texttt{example kbdinputstyle}
 \\begin{GNUTexinfopreformatted}
 \\leftskip=2em\\relax\\ttfamily%
-\\texttt{in example example kbdinputstyle}
+\\GNUTexinfocommandstyletextkbd{in example example kbdinputstyle}
 \\end{GNUTexinfopreformatted}
 
 \\GNUTexinfocommandstyletextkbd{distinct kbdinputstyle}
diff --git a/tp/t/results/misc_commands/kbdinputstyle.pl 
b/tp/t/results/misc_commands/kbdinputstyle.pl
index 79610c7ff4..c8fb3676bf 100644
--- a/tp/t/results/misc_commands/kbdinputstyle.pl
+++ b/tp/t/results/misc_commands/kbdinputstyle.pl
@@ -804,6 +804,9 @@ $result_trees{'kbdinputstyle'} = {
               ],
               'cmdname' => 'kbd',
               'contents' => [],
+              'extra' => {
+                'code' => 1
+              },
               'parent' => {},
               'source_info' => {
                 'file_name' => '',
@@ -899,6 +902,9 @@ $result_trees{'kbdinputstyle'} = {
                               ],
                               'cmdname' => 'kbd',
                               'contents' => [],
+                              'extra' => {
+                                'code' => 1
+                              },
                               'parent' => {},
                               'source_info' => {
                                 'file_name' => '',
@@ -1038,9 +1044,6 @@ $result_trees{'kbdinputstyle'} = {
                   ],
                   'cmdname' => 'kbd',
                   'contents' => [],
-                  'extra' => {
-                    'code' => 1
-                  },
                   'parent' => {},
                   'source_info' => {
                     'file_name' => '',
@@ -1076,9 +1079,6 @@ $result_trees{'kbdinputstyle'} = {
                           ],
                           'cmdname' => 'kbd',
                           'contents' => [],
-                          'extra' => {
-                            'code' => 1
-                          },
                           'parent' => {},
                           'source_info' => {
                             'file_name' => '',
@@ -2201,15 +2201,15 @@ $result_converted{'html_text'}->{'kbdinputstyle'} = '
 </p>
 
 <p><code class="code">in code out of example <code class="code">in nested 
code</code></code>.
-<kbd class="kbd">kbd out of example</kbd>.
+<code class="code as-code-kbd">kbd out of example</code>.
 <code class="code">kbd <code class="code as-code-kbd">in code</code></code>.
-<code class="code">for nesting <span class="r">r in code <kbd class="kbd">in r 
in code</kbd></span></code>
+<code class="code">for nesting <span class="r">r in code <code class="code 
as-code-kbd">in r in code</code></span></code>
 </p>
 <p>in example
 </p><div class="example">
 <pre class="example-preformatted"><code class="code">in code in example <code 
class="code">in nested code</code></code>.
-<code class="code as-code-kbd">kbd in example</code>.
-<code class="code">kbd <code class="code as-code-kbd">in code</code> in 
example</code>.
+<kbd class="kbd">kbd in example</kbd>.
+<code class="code">kbd <kbd class="kbd">in code</kbd> in example</code>.
 <code class="code">for nesting in example <span class="r">r in code in example 
<kbd class="kbd">in r in code in example</kbd></span></code>
 </pre></div>
 
@@ -2253,17 +2253,17 @@ in example
 
 
 \\texttt{in code out of example \\texttt{in nested code}}.
-\\GNUTexinfocommandstyletextkbd{kbd out of example}.
-\\texttt{kbd \\GNUTexinfocommandstyletextkbd{in code}}.
-\\texttt{for nesting \\textnormal{r in code \\GNUTexinfocommandstyletextkbd{in 
r in code}}}
+\\texttt{kbd out of example}.
+\\texttt{kbd \\texttt{in code}}.
+\\texttt{for nesting \\textnormal{r in code \\texttt{in r in code}}}
 
 in example
 \\begin{GNUTexinfopreformatted}
 \\leftskip=2em\\relax\\ttfamily%
 \\texttt{in code in example \\texttt{in nested code}}.
-\\texttt{kbd in example}.
-\\texttt{kbd \\texttt{in code}\\ in example}.
-\\texttt{for nesting in example \\textnormal{r in code in example \\texttt{in 
r in code in example}}}
+\\GNUTexinfocommandstyletextkbd{kbd in example}.
+\\texttt{kbd \\GNUTexinfocommandstyletextkbd{in code}\\ in example}.
+\\texttt{for nesting in example \\textnormal{r in code in example 
\\GNUTexinfocommandstyletextkbd{in r in code in example}}}
 \\end{GNUTexinfopreformatted}
 
 @kbdinputstyle distinct
diff --git a/tp/t/results/misc_commands/kbdinputstyle_in_table.pl 
b/tp/t/results/misc_commands/kbdinputstyle_in_table.pl
index e653cd34c3..7bc0bc4de1 100644
--- a/tp/t/results/misc_commands/kbdinputstyle_in_table.pl
+++ b/tp/t/results/misc_commands/kbdinputstyle_in_table.pl
@@ -821,6 +821,9 @@ $result_trees{'kbdinputstyle_in_table'} = {
                 {
                   'cmdname' => 'kbd',
                   'contents' => [],
+                  'extra' => {
+                    'code' => 1
+                  },
                   'parent' => {},
                   'source_info' => {
                     'file_name' => '',
@@ -913,6 +916,7 @@ $result_trees{'kbdinputstyle_in_table'} = {
           ],
           'extra' => {
             'command_as_argument' => {},
+            'command_as_argument_kbd_code' => 1,
             'end_command' => {},
             'spaces_before_argument' => ' '
           },
@@ -943,6 +947,9 @@ $result_trees{'kbdinputstyle_in_table'} = {
                   ],
                   'cmdname' => 'kbd',
                   'contents' => [],
+                  'extra' => {
+                    'code' => 1
+                  },
                   'parent' => {},
                   'source_info' => {
                     'file_name' => '',
@@ -1035,6 +1042,7 @@ $result_trees{'kbdinputstyle_in_table'} = {
           ],
           'extra' => {
             'command_as_argument' => {},
+            'command_as_argument_kbd_code' => 1,
             'end_command' => {},
             'spaces_before_argument' => ' '
           },
@@ -1081,9 +1089,6 @@ $result_trees{'kbdinputstyle_in_table'} = {
                     {
                       'cmdname' => 'kbd',
                       'contents' => [],
-                      'extra' => {
-                        'code' => 1
-                      },
                       'parent' => {},
                       'source_info' => {
                         'file_name' => '',
@@ -1176,7 +1181,6 @@ $result_trees{'kbdinputstyle_in_table'} = {
               ],
               'extra' => {
                 'command_as_argument' => {},
-                'command_as_argument_kbd_code' => 1,
                 'end_command' => {},
                 'spaces_before_argument' => ' '
               },
@@ -1201,9 +1205,6 @@ $result_trees{'kbdinputstyle_in_table'} = {
                       ],
                       'cmdname' => 'kbd',
                       'contents' => [],
-                      'extra' => {
-                        'code' => 1
-                      },
                       'parent' => {},
                       'source_info' => {
                         'file_name' => '',
@@ -1296,7 +1297,6 @@ $result_trees{'kbdinputstyle_in_table'} = {
               ],
               'extra' => {
                 'command_as_argument' => {},
-                'command_as_argument_kbd_code' => 1,
                 'end_command' => {},
                 'spaces_before_argument' => ' '
               },
@@ -2378,20 +2378,20 @@ 
$result_converted{'html_text'}->{'kbdinputstyle_in_table'} = '
 </p>
 
 <dl class="table">
-<dt><kbd class="kbd">i--tem out of example</kbd></dt>
+<dt><code class="code as-code-kbd">i--tem out of example</code></dt>
 </dl>
 
 <dl class="table">
-<dt><kbd class="kbd">braced i--tem out of example</kbd></dt>
+<dt><code class="code as-code-kbd">braced i--tem out of example</code></dt>
 </dl>
 
 <p>in example
 </p><div class="example">
 <dl class="table">
-<dt><code class="table-term-preformatted-code"><code class="code 
as-code-kbd">i--tem in example</code></code></dt>
+<dt><code class="table-term-preformatted-code"><kbd class="kbd">i--tem in 
example</kbd></code></dt>
 </dl>
 <dl class="table">
-<dt><code class="table-term-preformatted-code"><code class="code 
as-code-kbd">braced i--tem in example</code></code></dt>
+<dt><code class="table-term-preformatted-code"><kbd class="kbd">braced i--tem 
in example</kbd></code></dt>
 </dl>
 </div>
 
@@ -2447,22 +2447,22 @@ in example
 
 \\begin{description}
 \\item[{\\parbox[b]{\\linewidth}{%
-\\GNUTexinfocommandstyletextkbd{i{-}{-}tem out of example}}}]
+\\texttt{i{-}{-}tem out of example}}}]
 \\end{description}
 
 \\begin{description}
 \\item[{\\parbox[b]{\\linewidth}{%
-\\GNUTexinfocommandstyletextkbd{braced i{-}{-}tem out of example}}}]
+\\texttt{braced i{-}{-}tem out of example}}}]
 \\end{description}
 
 in example
 \\begin{description}
 \\item[{\\parbox[b]{\\linewidth}{%
-\\texttt{i{-}{-}tem in example}}}]
+\\GNUTexinfocommandstyletextkbd{i{-}{-}tem in example}}}]
 \\end{description}
 \\begin{description}
 \\item[{\\parbox[b]{\\linewidth}{%
-\\texttt{braced i{-}{-}tem in example}}}]
+\\GNUTexinfocommandstyletextkbd{braced i{-}{-}tem in example}}}]
 \\end{description}
 
 @kbdinputstyle distinct



reply via email to

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