texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/LaTeX.pm (_convert): deftype


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/LaTeX.pm (_convert): deftypefnnewline with tabularx.
Date: Fri, 12 Aug 2022 03:49:06 -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 322d3aa5b4 * tp/Texinfo/Convert/LaTeX.pm (_convert): deftypefnnewline 
with tabularx.
322d3aa5b4 is described below

commit 322d3aa5b43040f49672870fd67b68468556315e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Aug 12 09:48:54 2022 +0200

    * tp/Texinfo/Convert/LaTeX.pm (_convert): deftypefnnewline with
    tabularx.
---
 ChangeLog                                          |  5 ++
 tp/Texinfo/Convert/LaTeX.pm                        | 32 ++++++---
 .../converters_tests/test_deftypefnnewline.pl      | 16 ++---
 .../res_parser/formatting_latex/formatting.tex     | 80 +++++++++++-----------
 4 files changed, 75 insertions(+), 58 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f714121c8d..e330faf446 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-08-11  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/LaTeX.pm (_convert): deftypefnnewline with
+       tabularx.
+
 2022-08-11  Patrice Dumas  <pertusus@free.fr>
 
        Add commands handled by embrac before tabularx
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 8dd280d524..8ebce90aeb 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -3532,6 +3532,10 @@ sub _convert($$)
         } else {
           $command = $element->{'extra'}->{'def_command'};
         }
+
+        my $deftypefnnewline = ($self->get_conf('deftypefnnewline') eq 'on'
+               and ($command eq 'deftypefn' or $command eq 'deftypeop'));
+
         my $name;
         if ($element->{'extra'}->{'def_parsed_hash'}->{'name'}) {
           $name = $element->{'extra'}->{'def_parsed_hash'}->{'name'};
@@ -3543,6 +3547,15 @@ sub _convert($$)
           $def_space = '';
         }
 
+        my $converted_category;
+        my $category
+          = Texinfo::Convert::Utils::definition_category_tree($self, 
$element);;
+        if (defined($category)) {
+          # category is converted in normal text context
+          my $converted = _convert($self, $category);
+          $converted_category = "[$converted]";
+        }
+
         $self->{'packages'}->{'tabularx'} = 1;
         my $def_line_result = '';
         # First column (X) is as wide as possible, second column (r) is for
@@ -3563,9 +3576,12 @@ sub _convert($$)
         if ($element->{'extra'}->{'def_parsed_hash'}->{'type'}) {
           $def_line_result .=  _convert($self,
             $element->{'extra'}->{'def_parsed_hash'}->{'type'});
-          if ($self->get_conf('deftypefnnewline') eq 'on'
-              and ($command eq 'deftypefn' or $command eq 'deftypeop')) {
-            $def_line_result .= '\\leavevmode{}\\\\'; # should be same as @*
+          if ($deftypefnnewline) {
+            if (defined($converted_category)) {
+              $def_line_result .= "}& $converted_category\\\\\n\\texttt{"
+            } else {
+              $def_line_result .= "}\\\\\n\\texttt{";
+            }
           } else {
             $def_line_result .= ' ';
           }
@@ -3607,13 +3623,9 @@ sub _convert($$)
         pop @{$self->{'formatting_context'}->[-1]->{'code'}};
         $def_line_result .= '}'; # \texttt
 
-        my $category
-          = Texinfo::Convert::Utils::definition_category_tree($self, 
$element);;
-        if (defined($category)) {
-          # category is converted in normal text context
-          my $converted = _convert($self, $category);
-          $def_line_result .= "& [$converted]\n";
-        }
+        $def_line_result .= "& $converted_category\n"
+          if (defined($converted_category) and not $deftypefnnewline);
+
         $def_line_result .= "\\end{tabularx}\n";
         # Add commands associated to embrac, prepended to be before tabularx.
         # If done in tabularx there are redefinition errors, cells are
diff --git a/tp/t/results/converters_tests/test_deftypefnnewline.pl 
b/tp/t/results/converters_tests/test_deftypefnnewline.pl
index ee363a1efd..83a90befbb 100644
--- a/tp/t/results/converters_tests/test_deftypefnnewline.pl
+++ b/tp/t/results/converters_tests/test_deftypefnnewline.pl
@@ -3627,8 +3627,8 @@ $result_converted{'latex'}->{'test_deftypefnnewline'} = '
 \\noindent\\begin{tabularx}{\\linewidth}{@{}Xr}
 \\rightskip=5em plus 1 fill
 \\hangindent=2em
-\\noindent\\texttt{data-type\\leavevmode{}\\\\name arguments...}& [Function]
-\\end{tabularx}
+\\noindent\\texttt{data-type}& [Function]\\\\
+\\texttt{name arguments...}\\end{tabularx}
 
 \\index[fn]{name@\\texttt{name}}%
 \\begin{quote}
@@ -3640,8 +3640,8 @@ aaa
 \\noindent\\begin{tabularx}{\\linewidth}{@{}Xr}
 \\rightskip=5em plus 1 fill
 \\hangindent=2em
-\\noindent\\texttt{t{-}{-}ype\\leavevmode{}\\\\d{-}{-}eftypefn\\_name}& 
[c--ategory]
-\\end{tabularx}
+\\noindent\\texttt{t{-}{-}ype}& [c--ategory]\\\\
+\\texttt{d{-}{-}eftypefn\\_name}\\end{tabularx}
 
 \\index[fn]{d--eftypefn\\_name@\\texttt{d{-}{-}eftypefn\\_name}}%
 \\begin{quote}
@@ -3653,8 +3653,8 @@ d--eftypefn no arg
 \\noindent\\begin{tabularx}{\\linewidth}{@{}Xr}
 \\rightskip=5em plus 1 fill
 \\hangindent=2em
-\\noindent\\texttt{t{-}{-}ype\\leavevmode{}\\\\d{-}{-}eftypeop\\_name 
a{-}{-}rguments...}& [c--ategory on \\texttt{c{-}{-}lass}]
-\\end{tabularx}
+\\noindent\\texttt{t{-}{-}ype}& [c--ategory on \\texttt{c{-}{-}lass}]\\\\
+\\texttt{d{-}{-}eftypeop\\_name a{-}{-}rguments...}\\end{tabularx}
 
 \\index[fn]{d--eftypeop\\_name on c--lass@\\texttt{d{-}{-}eftypeop\\_name\\ on 
c{-}{-}lass}}%
 \\begin{quote}
@@ -3666,8 +3666,8 @@ d--eftypeop
 \\noindent\\begin{tabularx}{\\linewidth}{@{}Xr}
 \\rightskip=5em plus 1 fill
 \\hangindent=2em
-\\noindent\\texttt{t{-}{-}ype\\leavevmode{}\\\\d{-}{-}eftypeop\\_name}& 
[c--ategory on \\texttt{c{-}{-}lass}]
-\\end{tabularx}
+\\noindent\\texttt{t{-}{-}ype}& [c--ategory on \\texttt{c{-}{-}lass}]\\\\
+\\texttt{d{-}{-}eftypeop\\_name}\\end{tabularx}
 
 \\index[fn]{d--eftypeop\\_name on c--lass@\\texttt{d{-}{-}eftypeop\\_name\\ on 
c{-}{-}lass}}%
 \\begin{quote}
diff --git a/tp/tests/layout/res_parser/formatting_latex/formatting.tex 
b/tp/tests/layout/res_parser/formatting_latex/formatting.tex
index 50af4208ab..765858e0dd 100644
--- a/tp/tests/layout/res_parser/formatting_latex/formatting.tex
+++ b/tp/tests/layout/res_parser/formatting_latex/formatting.tex
@@ -1318,8 +1318,8 @@ d--eftypemethod
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{data-type2\leavevmode{}\\name2 arguments2...}& [Function]
-\end{tabularx}
+\noindent\texttt{data-type2}& [Function]\\
+\texttt{name2 arguments2...}\end{tabularx}
 
 \index[fn]{name2@\texttt{name2}}%
 \begin{quote}
@@ -1331,8 +1331,8 @@ aaa2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypefn\_name2}& 
[c--ategory2]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2]\\
+\texttt{d{-}{-}eftypefn\_name2}\end{tabularx}
 
 \index[fn]{d--eftypefn\_name2@\texttt{d{-}{-}eftypefn\_name2}}%
 \begin{quote}
@@ -1344,8 +1344,8 @@ d--eftypefn no arg2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypeop\_name2 
a{-}{-}rguments2...}& [c--ategory2 on \texttt{c{-}{-}lass2}]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2 on \texttt{c{-}{-}lass2}]\\
+\texttt{d{-}{-}eftypeop\_name2 a{-}{-}rguments2...}\end{tabularx}
 
 \index[fn]{d--eftypeop\_name2 on c--lass2@\texttt{d{-}{-}eftypeop\_name2\ on 
c{-}{-}lass2}}%
 \begin{quote}
@@ -1357,8 +1357,8 @@ d--eftypeop2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypeop\_name2}& 
[c--ategory2 on \texttt{c{-}{-}lass2}]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2 on \texttt{c{-}{-}lass2}]\\
+\texttt{d{-}{-}eftypeop\_name2}\end{tabularx}
 
 \index[fn]{d--eftypeop\_name2 on c--lass2@\texttt{d{-}{-}eftypeop\_name2\ on 
c{-}{-}lass2}}%
 \begin{quote}
@@ -3009,8 +3009,8 @@ d--eftypemethod
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{data-type2\leavevmode{}\\name2 arguments2...}& [Function]
-\end{tabularx}
+\noindent\texttt{data-type2}& [Function]\\
+\texttt{name2 arguments2...}\end{tabularx}
 
 \index[fn]{name2@\texttt{name2}}%
 \begin{quote}
@@ -3022,8 +3022,8 @@ aaa2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypefn\_name2}& 
[c--ategory2]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2]\\
+\texttt{d{-}{-}eftypefn\_name2}\end{tabularx}
 
 \index[fn]{d--eftypefn\_name2@\texttt{d{-}{-}eftypefn\_name2}}%
 \begin{quote}
@@ -3035,8 +3035,8 @@ d--eftypefn no arg2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypeop\_name2 
a{-}{-}rguments2...}& [c--ategory2 on \texttt{c{-}{-}lass2}]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2 on \texttt{c{-}{-}lass2}]\\
+\texttt{d{-}{-}eftypeop\_name2 a{-}{-}rguments2...}\end{tabularx}
 
 \index[fn]{d--eftypeop\_name2 on c--lass2@\texttt{d{-}{-}eftypeop\_name2\ on 
c{-}{-}lass2}}%
 \begin{quote}
@@ -3048,8 +3048,8 @@ d--eftypeop2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypeop\_name2}& 
[c--ategory2 on \texttt{c{-}{-}lass2}]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2 on \texttt{c{-}{-}lass2}]\\
+\texttt{d{-}{-}eftypeop\_name2}\end{tabularx}
 
 \index[fn]{d--eftypeop\_name2 on c--lass2@\texttt{d{-}{-}eftypeop\_name2\ on 
c{-}{-}lass2}}%
 \begin{quote}
@@ -4721,8 +4721,8 @@ d--eftypemethod
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{data-type2\leavevmode{}\\name2 arguments2...}& [Function]
-\end{tabularx}
+\noindent\texttt{data-type2}& [Function]\\
+\texttt{name2 arguments2...}\end{tabularx}
 
 \index[fn]{name2@\texttt{name2}}%
 \begin{quote}
@@ -4734,8 +4734,8 @@ aaa2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypefn\_name2}& 
[c--ategory2]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2]\\
+\texttt{d{-}{-}eftypefn\_name2}\end{tabularx}
 
 \index[fn]{d--eftypefn\_name2@\texttt{d{-}{-}eftypefn\_name2}}%
 \begin{quote}
@@ -4747,8 +4747,8 @@ d--eftypefn no arg2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypeop\_name2 
a{-}{-}rguments2...}& [c--ategory2 on \texttt{c{-}{-}lass2}]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2 on \texttt{c{-}{-}lass2}]\\
+\texttt{d{-}{-}eftypeop\_name2 a{-}{-}rguments2...}\end{tabularx}
 
 \index[fn]{d--eftypeop\_name2 on c--lass2@\texttt{d{-}{-}eftypeop\_name2\ on 
c{-}{-}lass2}}%
 \begin{quote}
@@ -4760,8 +4760,8 @@ d--eftypeop2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypeop\_name2}& 
[c--ategory2 on \texttt{c{-}{-}lass2}]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2 on \texttt{c{-}{-}lass2}]\\
+\texttt{d{-}{-}eftypeop\_name2}\end{tabularx}
 
 \index[fn]{d--eftypeop\_name2 on c--lass2@\texttt{d{-}{-}eftypeop\_name2\ on 
c{-}{-}lass2}}%
 \begin{quote}
@@ -6411,8 +6411,8 @@ d--eftypemethod
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{data-type2\leavevmode{}\\name2 arguments2...}& [Function]
-\end{tabularx}
+\noindent\texttt{data-type2}& [Function]\\
+\texttt{name2 arguments2...}\end{tabularx}
 
 \index[fn]{name2@\texttt{name2}}%
 \begin{quote}
@@ -6424,8 +6424,8 @@ aaa2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypefn\_name2}& 
[c--ategory2]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2]\\
+\texttt{d{-}{-}eftypefn\_name2}\end{tabularx}
 
 \index[fn]{d--eftypefn\_name2@\texttt{d{-}{-}eftypefn\_name2}}%
 \begin{quote}
@@ -6437,8 +6437,8 @@ d--eftypefn no arg2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypeop\_name2 
a{-}{-}rguments2...}& [c--ategory2 on \texttt{c{-}{-}lass2}]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2 on \texttt{c{-}{-}lass2}]\\
+\texttt{d{-}{-}eftypeop\_name2 a{-}{-}rguments2...}\end{tabularx}
 
 \index[fn]{d--eftypeop\_name2 on c--lass2@\texttt{d{-}{-}eftypeop\_name2\ on 
c{-}{-}lass2}}%
 \begin{quote}
@@ -6450,8 +6450,8 @@ d--eftypeop2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypeop\_name2}& 
[c--ategory2 on \texttt{c{-}{-}lass2}]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2 on \texttt{c{-}{-}lass2}]\\
+\texttt{d{-}{-}eftypeop\_name2}\end{tabularx}
 
 \index[fn]{d--eftypeop\_name2 on c--lass2@\texttt{d{-}{-}eftypeop\_name2\ on 
c{-}{-}lass2}}%
 \begin{quote}
@@ -8661,8 +8661,8 @@ d{-}{-}eftypemethod
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{data-type2\leavevmode{}\\name2 arguments2...}& [Function]
-\end{tabularx}
+\noindent\texttt{data-type2}& [Function]\\
+\texttt{name2 arguments2...}\end{tabularx}
 
 \index[fn]{name2@\texttt{name2}}%
 \begin{quote}
@@ -8680,8 +8680,8 @@ aaa2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypefn\_name2}& 
[c--ategory2]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2]\\
+\texttt{d{-}{-}eftypefn\_name2}\end{tabularx}
 
 \index[fn]{d--eftypefn\_name2@\texttt{d{-}{-}eftypefn\_name2}}%
 \begin{quote}
@@ -8699,8 +8699,8 @@ d{-}{-}eftypefn no arg2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypeop\_name2 
a{-}{-}rguments2...}& [c--ategory2 on \texttt{c{-}{-}lass2}]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2 on \texttt{c{-}{-}lass2}]\\
+\texttt{d{-}{-}eftypeop\_name2 a{-}{-}rguments2...}\end{tabularx}
 
 \index[fn]{d--eftypeop\_name2 on c--lass2@\texttt{d{-}{-}eftypeop\_name2\ on 
c{-}{-}lass2}}%
 \begin{quote}
@@ -8718,8 +8718,8 @@ d{-}{-}eftypeop2
 \noindent\begin{tabularx}{\linewidth}{@{}Xr}
 \rightskip=5em plus 1 fill
 \hangindent=2em
-\noindent\texttt{t{-}{-}ype2\leavevmode{}\\d{-}{-}eftypeop\_name2}& 
[c--ategory2 on \texttt{c{-}{-}lass2}]
-\end{tabularx}
+\noindent\texttt{t{-}{-}ype2}& [c--ategory2 on \texttt{c{-}{-}lass2}]\\
+\texttt{d{-}{-}eftypeop\_name2}\end{tabularx}
 
 \index[fn]{d--eftypeop\_name2 on c--lass2@\texttt{d{-}{-}eftypeop\_name2\ on 
c{-}{-}lass2}}%
 \begin{quote}



reply via email to

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