texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: @set txidefnamenospace in LaTeX


From: Gavin D. Smith
Subject: branch master updated: @set txidefnamenospace in LaTeX
Date: Wed, 27 Jul 2022 15:36:27 -0400

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 69d902f9b1 @set txidefnamenospace in LaTeX
69d902f9b1 is described below

commit 69d902f9b1142eac8b8753891477dd061ed4c013
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Wed Jul 27 20:36:17 2022 +0100

    @set txidefnamenospace in LaTeX
    
    * tp/Texinfo/Convert/LaTeX.pm (_convert) <@def*>:
    Implement txidefnamenospace flag to omit space between def
    name and arguments.  This rearranges and condenses the code,
    and uses gdt much less.
---
 ChangeLog                          |   9 +++
 tp/Texinfo/Convert/LaTeX.pm        | 133 +++++++++++--------------------------
 tp/t/19def.t                       |   3 +-
 tp/t/results/def/omit_def_space.pl |  62 +++++++++++++++++
 4 files changed, 112 insertions(+), 95 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 163db3eb46..0cdb5e1797 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-07-27  Gavin Smith  <gavinsmith0123@gmail.com>
+
+       @set txidefnamenospace in LaTeX
+
+       * tp/Texinfo/Convert/LaTeX.pm (_convert) <@def*>:
+       Implement txidefnamenospace flag to omit space between def
+       name and arguments.  This rearranges and condenses the code,
+       and uses gdt much less.
+
 2022-07-27  Gavin Smith  <gavinsmith0123@gmail.com>
 
        Save txidefnamenospace
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 12ca33393c..b9a5d2b5f3 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -3412,7 +3412,6 @@ sub _convert($$)
              and %{$element->{'extra'}->{'def_parsed_hash'}}) {
         my $arguments
             = Texinfo::Convert::Utils::definition_arguments_content($element);
-        my $tree;
         my $command;
         if 
($Texinfo::Common::def_aliases{$element->{'extra'}->{'def_command'}}) {
           $command
@@ -3426,106 +3425,52 @@ sub _convert($$)
         } else {
           $name = '';
         }
-        $result .= '\noindent\texttt{';
+        my $def_space = ' ';
+        if ($self->{'values'}->{'txidefnamenospace'}) {
+          $def_space = '';
+        }
 
-       my $strings = {
-          'name' => $name,
-          'type' => $element->{'extra'}->{'def_parsed_hash'}->{'type'},
-       };
-       $strings->{'arguments'} = _only_slanted_no_code_contents($arguments)
-          if ($arguments);
+        $result .= '\noindent\texttt{';
+        # the def* line except for the category is converted in code context
+        $self->{'formatting_context'}->[-1]->{'code'} += 1;
 
-        my $category = $element->{'extra'}->{'def_parsed_hash'}->{'category'};
-        
-        if ($command eq 'deffn'
-            or $command eq 'defvr'
-            or $command eq 'deftp'
-            or (($command eq 'deftypefn'
-                 or $command eq 'deftypevr')
-                and !$element->{'extra'}->{'def_parsed_hash'}->{'type'})) {
-          if ($arguments) {
-            $tree = $self->gdt('{name} {arguments}', $strings);
-          } else {
-            $tree = $self->gdt("{name}", $strings);
-          }
-        } elsif ($command eq 'deftypefn'
-                 or $command eq 'deftypevr') {
-          if ($arguments) {
-            if ($self->get_conf('deftypefnnewline') eq 'on') {
-              $tree = $self->gdt("{type}\@*{name} {arguments}", $strings);
-            } else {
-              $tree = $self->gdt('{type} {name} {arguments}', $strings);
-            }
-          } else {
-            if ($self->get_conf('deftypefnnewline') eq 'on') {
-              $tree = $self->gdt('{type}@*{name}', $strings);
-            } else {
-              $tree = $self->gdt('{type} {name}', $strings);
-            }
-          }
-        } elsif ($command eq 'defcv'
-                 or ($command eq 'deftypecv'
-                     and !$element->{'extra'}->{'def_parsed_hash'}->{'type'})) 
{
-          $category
-           = $self->gdt('{category} of @code{{class}}',
-            { 'category' => 
$element->{'extra'}->{'def_parsed_hash'}->{'category'},
-              'class' => $element->{'extra'}->{'def_parsed_hash'}->{'class'} } 
);
-          if ($arguments) {
-            $tree = $self->gdt('{name} {arguments}', $strings);
-          } else {
-            $tree = $self->gdt("{name}", $strings);
-          }
-        } elsif ($command eq 'defop'
-                 or ($command eq 'deftypeop'
-                     and !$element->{'extra'}->{'def_parsed_hash'}->{'type'})) 
{
-          $category =  $self->gdt('{category} on @code{{class}}',
-                { 'category' => 
$element->{'extra'}->{'def_parsed_hash'}->{'category'},
-                  'class' => 
$element->{'extra'}->{'def_parsed_hash'}->{'class'} } );
-          if ($arguments) {
-            $tree = $self->gdt('{name} {arguments}', $strings);
-          } else {
-            $tree = $self->gdt('{name}', $strings);
-          }
-        } elsif ($command eq 'deftypeop') {
-          $category =  $self->gdt('{category} on @code{{class}}',
-             { 'category' => 
$element->{'extra'}->{'def_parsed_hash'}->{'category'},
-               'class' => $element->{'extra'}->{'def_parsed_hash'}->{'class'} 
} );
-          if ($arguments) {
-            if ($self->get_conf('deftypefnnewline') eq 'on') {
-              $tree = $self->gdt('{type}@*{name} {arguments}', $strings);
-            } else {
-              $tree = $self->gdt('{type} {name} {arguments}', $strings);
-            }
+        if ($element->{'extra'}->{'def_parsed_hash'}->{'type'}) {
+          $result .=  _convert($self,
+            $element->{'extra'}->{'def_parsed_hash'}->{'type'});
+          if ($self->get_conf('deftypefnnewline') eq 'on') {
+            $result .= '\\leavevmode{}\\\\'; # should be same as @*
           } else {
-            if ($self->get_conf('deftypefnnewline') eq 'on') {
-              $tree = $self->gdt('{type}@*{name}', $strings);
-            } else {
-              $tree = $self->gdt('{type} {name}', $strings);
-            }
-          }
-        } elsif ($command eq 'deftypecv') {
-          $category =  $self->gdt('{category} of @code{{class}}',
-            { 'category' => 
$element->{'extra'}->{'def_parsed_hash'}->{'category'},
-              'class' => $element->{'extra'}->{'def_parsed_hash'}->{'class'} } 
);
-          if ($arguments) {
-            if ($self->get_conf('deftypefnnewline') eq 'on') {
-              $tree = $self->gdt('{type}@*{name} {arguments}', $strings);
-            } else {
-              $tree = $self->gdt('{type} {name} {arguments}', $strings);
-            }
-          } else {
-            if ($self->get_conf('deftypefnnewline') eq 'on') {
-              $tree = $self->gdt('{type}@*{name}', $strings);
-            } else {
-              $tree = $self->gdt('{type} {name}', $strings);
-            }
+            $result .= ' ';
           }
         }
-        # the def* line except for the category is converted in code context
-        $self->{'formatting_context'}->[-1]->{'code'} += 1;
-        $result .= _convert($self, {'contents' => [$tree]});
+        $result .= _convert($self, $name) if $name;
+        if ($arguments) {
+          $result .= $def_space;
+          $result .=  _convert($self,
+                               _only_slanted_no_code_contents($arguments));
+        }
+
         $self->{'formatting_context'}->[-1]->{'code'} -= 1;
         $result .= '}'; # \texttt
+
+        my $category;
+        if ($command eq 'defcv' or $command eq 'deftypecv') {
+          $category = $self->gdt('{category} of @code{{class}}',
+            { 'category'
+                 => $element->{'extra'}->{'def_parsed_hash'}->{'category'},
+              'class'
+                 => $element->{'extra'}->{'def_parsed_hash'}->{'class'}
+            });
+        } elsif ($command eq 'defop' or $command eq 'deftypeop') {
+          $category =  $self->gdt('{category} on @code{{class}}',
+            { 'category'
+                 => $element->{'extra'}->{'def_parsed_hash'}->{'category'},
+              'class'
+                 => $element->{'extra'}->{'def_parsed_hash'}->{'class'}
+            });
+        } else {
+          $category = $element->{'extra'}->{'def_parsed_hash'}->{'category'};
+        }
         if (defined($category)) {
           # category is converted in normal text context
           my $converted = _convert($self, $category);
diff --git a/tp/t/19def.t b/tp/t/19def.t
index 755a0b69aa..0d752fe844 100644
--- a/tp/t/19def.t
+++ b/tp/t/19def.t
@@ -563,7 +563,8 @@ Documentation of @code{foo}.
 @defun function (arg1, arg2)
 explain
 @end defun
-']
+',
+{'test_formats' => ['plaintext', 'html', 'latex']}],
 );
 
 my @test_printindex = ();
diff --git a/tp/t/results/def/omit_def_space.pl 
b/tp/t/results/def/omit_def_space.pl
index 2d1d37257a..c7c9b3633a 100644
--- a/tp/t/results/def/omit_def_space.pl
+++ b/tp/t/results/def/omit_def_space.pl
@@ -309,4 +309,66 @@ $result_indices_sort_strings{'omit_def_space'} = {
 };
 
 
+
+$result_converted{'plaintext'}->{'omit_def_space'} = ' -- Function: function 
(arg1, arg2)
+     explain
+';
+
+
+$result_converted{'html'}->{'omit_def_space'} = '<!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">
+
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+span:hover a.copiable-link {visibility: visible}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+
+<dl class="first-deffn first-defun-alias-first-deffn">
+<dt class="deffn defun-alias-deffn" id="index-function"><span 
class="category-def">Function: </span><span><strong 
class="strong">function</strong> <em class="emph">(arg1, arg2)</em><a 
class="copiable-link" href=\'#index-function\'> &para;</a></span></dt>
+<dd><p>explain
+</p></dd></dl>
+
+
+
+</body>
+</html>
+';
+
+$result_converted_errors{'html'}->{'omit_def_space'} = [
+  {
+    'error_line' => 'warning: must specify a title with a title command or @top
+',
+    'text' => 'must specify a title with a title command or @top',
+    'type' => 'warning'
+  }
+];
+
+
+
+$result_converted{'latex'}->{'omit_def_space'} = '
+\\noindent\\texttt{function \\bgroup{}\\normalfont{}\\textsl{(arg1, 
arg2)}\\egroup{}}\\hfill[Function]
+
+
+
+\\index[fn]{function@\\texttt{function}}%
+explain
+';
+
 1;



reply via email to

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