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 (%preamble_commands


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/LaTeX.pm (%preamble_commands): use Texinfo::Common preamble commands, except for titlepage and shorttitlepage which need to be in the document content.
Date: Sun, 02 Jan 2022 07:17:11 -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 d075c3b85b * tp/Texinfo/Convert/LaTeX.pm (%preamble_commands): use 
Texinfo::Common preamble commands, except for titlepage and shorttitlepage 
which need to be in the document content.
d075c3b85b is described below

commit d075c3b85b22686a71da1e39a7813a9adc9a4073
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 2 13:16:04 2022 +0100

    * tp/Texinfo/Convert/LaTeX.pm (%preamble_commands): use Texinfo::Common
    preamble commands, except for titlepage and shorttitlepage which
    need to be in the document content.
    
    * tp/Texinfo/Convert/LaTeX.pm (_finish_front_cover_page, _convert):
    distinguish cover page formatting from titlepage formatting.
---
 ChangeLog                                          |  9 ++++
 tp/Texinfo/Convert/LaTeX.pm                        | 57 ++++++++++++----------
 .../custom_headings/res_latex/custom_headings.tex  |  2 +-
 tp/t/results/latex_tests/titlepage_classical.pl    |  2 +-
 .../res_latex/titlepage_classical.tex              |  2 +-
 .../titlepage_with_commands_classical.pl           |  2 +-
 .../titlepage_with_commands_classical.tex          |  2 +-
 7 files changed, 45 insertions(+), 31 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1d96e032e2..a3cf711551 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,15 @@
        * doc/texinfo.tex (\key): Unconditionally use (upright) typewriter
        font, regardless of whether @key is inside @kbd or not.
 
+2022-01-02  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/LaTeX.pm (%preamble_commands): use Texinfo::Common
+       preamble commands, except for titlepage and shorttitlepage which
+       need to be in the document content.
+
+       * tp/Texinfo/Convert/LaTeX.pm (_finish_front_cover_page, _convert):
+       distinguish cover page formatting from titlepage formatting.
+
 2022-01-02  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Common.pm (add_preamble_before_content): put code that
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index dc397114c7..2863f35e13 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -243,13 +243,10 @@ my %item_line_commands = 
%Texinfo::Common::item_line_commands;
 my %headings_specification_commands = 
%Texinfo::Common::headings_specification_commands;
 my %in_heading_commands = %Texinfo::Common::in_heading_commands;
 
-# commands that can appear in preamble, before \begin{document}
-my %preamble_commands;
-foreach my $preamble_command ('hyphenation', 'anchor', 'errormsg',
-       'inlineraw', '*', @informative_global_commands,
-       keys(%format_raw_commands), keys(%inline_commands)) {
-  $preamble_commands{$preamble_command} = 1;
-}
+my %preamble_commands = %Texinfo::Common::preamble_commands;
+
+delete $preamble_commands{'titlepage'};
+delete $preamble_commands{'shorttitlepage'};
 
 foreach my $kept_command (@informative_global_commands,
   keys(%default_index_commands),
@@ -910,6 +907,7 @@ sub associate_other_nodes_to_sections($$)
 # added in the tree where the \begin{document} should be,
 # after the @-commands in preamble
 my $latex_document_type = '_latex_document';
+#my $latex_document_type = 'preamble_before_content';
 
 sub output($$)
 {
@@ -1713,17 +1711,22 @@ sub _kbd_code_style($)
                    and 
$preformatted_code_commands{$self->{'formatting_context'}->[-1]->{'preformatted_context'}->[-1]}))));
 }
 
-sub _end_title_page($)
+sub _finish_front_cover_page($)
 {
   my $self = shift;
-  # add a rule if there was a @title (same as in Texinfo TeX)
-  if ($self->{'titlepage_formatting'}->{'title'}) {
-    delete $self->{'titlepage_formatting'}->{'title'};
-    return '\vskip4pt \hrule height 2pt width \hsize
+  my $result = '';
+  if ($self->{'titlepage_formatting'}->{'in_front_cover'}) {
+    # add a rule if there was a @title (same as in Texinfo TeX)
+    if ($self->{'titlepage_formatting'}->{'title'}) {
+      delete $self->{'titlepage_formatting'}->{'title'};
+      $result .= '\vskip4pt \hrule height 2pt width \hsize
   \vskip\titlepagebottomglue
 ';
+    }
+    $result .= "\\endgroup\n";
+    $self->{'titlepage_formatting'}->{'in_front_cover'} = 0;
   }
-  return '';
+  return $result;
 }
 
 sub _tree_anchor_label {
@@ -1840,11 +1843,15 @@ sub _index_entry($$)
 
 sub _convert($$);
 
-# Convert the Texinfo tree under $ROOT
+# Convert the Texinfo tree under $ELEMENT
 sub _convert($$)
 {
   my ($self, $element) = @_;
 
+  if ($self->{'debug'}) {
+    print STDERR "CONVLTX 
".Texinfo::Common::debug_print_element_short($element)."\n";
+  }
+
   my $type = $element->{'type'};
   my $cmdname = $element->{'cmdname'};
 
@@ -2570,7 +2577,7 @@ sub _convert($$)
         if ($self->{'to_utf8'}) {
           my $possible_conversion
             = Texinfo::Convert::Unicode::check_unicode_point_conversion($arg,
-                                                             $self->{'DEBUG'});
+                                                             $self->{'debug'});
           if ($possible_conversion) {
             $res = chr(hex($arg)); # ok to call chr
           } else {
@@ -2613,8 +2620,8 @@ sub _convert($$)
         push @{$self->{'formatting_context'}->[-1]->{'table_command_format'}},
                 $description_command_format;
       } elsif ($cmdname eq 'titlepage') {
-        # start a group such that the changes are forgotten when closed
-        # define glues dimensions that are used in titlepage formatting.
+        # start a group such that the changes are forgotten when front cover 
is done
+        # define glues dimensions that are used in front cover formatting.
         # Taken from Texinfo TeX.
         # FIXME replace \\newskip by \\newlen?
         $result .= "\\begingroup
@@ -2623,7 +2630,7 @@ sub _convert($$)
 \\setlength{\\parindent}{0pt}\n";
         $result .= "% Leave some space at the very top of the page.
     \\vglue\\titlepagetopglue\n";
-        $self->{'titlepage_formatting'} = {'in_titlepage' => 1};
+        $self->{'titlepage_formatting'} = {'in_front_cover' => 1};
       }
 
       if ($cmdname eq 'quotation' or $cmdname eq 'smallquotation') {
@@ -2825,7 +2832,7 @@ sub _convert($$)
       }
       return $result;
     } elsif ($cmdname eq 'page') {
-      $result .= _end_title_page($self);
+      $result .= _finish_front_cover_page($self);
       # the phantom is added such that successive new pages create blank pages
       $result .= "\\newpage{}%\n\\phantom{blabla}%\n";
       return $result;
@@ -2872,9 +2879,6 @@ sub _convert($$)
       return $result;
     } elsif ($cmdname eq 'title') {
       my $title_text = _title_font($self, $element);
-      #$result .= "\\begin{flushleft}\n";
-      #$result .= $title_text."\n";
-      #$result .= "\\end{flushleft}\n";
       # FIXME In Texinfo TeX the interline space seems more even
       $result .= "{\\raggedright $title_text}\n";
       # same formatting for the rule as in Texinfo TeX
@@ -2889,7 +2893,7 @@ sub _convert($$)
       #$result .= "\\end{flushright}\n";
       $result .= "\\rightline{$subtitle_text}\n";
     } elsif ($cmdname eq 'author') {
-      if ($self->{'titlepage_formatting'}->{'in_titlepage'}
+      if ($self->{'titlepage_formatting'}->{'in_front_cover'}
           and not $self->{'formatting_context'}->[-1]->{'in_quotation'}) {
         if (not $self->{'titlepage_formatting'}->{'author'}) {
           # first author, add space before
@@ -3256,15 +3260,16 @@ sub _convert($$)
       }
     } elsif ($type eq 'row') {
       # ...
+    #} elsif ($type eq $latex_document_type) {
+    #  # special type inserted where the document begins
+    #  $result .= _begin_document($self);
     }
   }
 
   # close commands
   if ($cmdname) {
     if ($cmdname eq 'titlepage') {
-      $result .= _end_title_page($self);
-      $result .= "\\endgroup\n";
-      $self->{'titlepage_formatting'}->{'in_titlepage'} = 0;
+      $result .= _finish_front_cover_page($self);
     } elsif ($item_line_commands{$cmdname}) {
       pop @{$self->{'formatting_context'}->[-1]->{'table_command_format'}};
     }
diff --git 
a/tp/t/results/latex_tests/custom_headings/res_latex/custom_headings.tex 
b/tp/t/results/latex_tests/custom_headings/res_latex/custom_headings.tex
index 27941dbd68..7a03735e39 100644
--- a/tp/t/results/latex_tests/custom_headings/res_latex/custom_headings.tex
+++ b/tp/t/results/latex_tests/custom_headings/res_latex/custom_headings.tex
@@ -111,7 +111,6 @@ roundcorner=10pt}
 \GNUTexinfosetsingleheader{}%
 
 
-\begin{document}
 \newpagestyle{custom}{%
 \sethead[\thepage{} \sectiontitle{}][\thesection{} Section \thesection{} 
\sectiontitle{}][\chaptertitle{} \thechapter{}]%
 {}{}{}%
@@ -125,6 +124,7 @@ roundcorner=10pt}
 }%
 \pagestyle{custom}%
 
+\begin{document}
 \chapter{ch--ap}
 \label{anchor:chapter}%
 
diff --git a/tp/t/results/latex_tests/titlepage_classical.pl 
b/tp/t/results/latex_tests/titlepage_classical.pl
index f145070835..1b3f398de0 100644
--- a/tp/t/results/latex_tests/titlepage_classical.pl
+++ b/tp/t/results/latex_tests/titlepage_classical.pl
@@ -812,13 +812,13 @@ $result_converted{'latex'}->{'titlepage_classical'} = '
 
 \\vskip4pt \\hrule height 2pt width \\hsize
   \\vskip\\titlepagebottomglue
+\\endgroup
 \\newpage{}%
 \\phantom{blabla}%
 \\newpage{}%
 \\phantom{blabla}%
 \\vskip 0pt plus 1filll
 in Copying
-\\endgroup
 \\end{titlepage}
 \\GNUTexinfosetsingleheader{}%
 \\GNUTexinfomainmatter
diff --git 
a/tp/t/results/latex_tests/titlepage_classical/res_latex/titlepage_classical.tex
 
b/tp/t/results/latex_tests/titlepage_classical/res_latex/titlepage_classical.tex
index d13a0b8048..f3d44846ce 100644
--- 
a/tp/t/results/latex_tests/titlepage_classical/res_latex/titlepage_classical.tex
+++ 
b/tp/t/results/latex_tests/titlepage_classical/res_latex/titlepage_classical.tex
@@ -134,13 +134,13 @@ roundcorner=10pt}
 
 \vskip4pt \hrule height 2pt width \hsize
   \vskip\titlepagebottomglue
+\endgroup
 \newpage{}%
 \phantom{blabla}%
 \newpage{}%
 \phantom{blabla}%
 \vskip 0pt plus 1filll
 in Copying
-\endgroup
 \end{titlepage}
 \GNUTexinfosetsingleheader{}%
 \GNUTexinfomainmatter
diff --git a/tp/t/results/latex_tests/titlepage_with_commands_classical.pl 
b/tp/t/results/latex_tests/titlepage_with_commands_classical.pl
index 3ca8ca21e0..409a0d51b4 100644
--- a/tp/t/results/latex_tests/titlepage_with_commands_classical.pl
+++ b/tp/t/results/latex_tests/titlepage_with_commands_classical.pl
@@ -1041,13 +1041,13 @@ $$
 }}%
 \\vskip4pt \\hrule height 2pt width \\hsize
   \\vskip\\titlepagebottomglue
+\\endgroup
 \\newpage{}%
 \\phantom{blabla}%
 \\newpage{}%
 \\phantom{blabla}%
 \\vskip 0pt plus 1filll
 in Copying
-\\endgroup
 \\end{titlepage}
 \\GNUTexinfosetsingleheader{}%
 \\GNUTexinfomainmatter
diff --git 
a/tp/t/results/latex_tests/titlepage_with_commands_classical/res_latex/titlepage_with_commands_classical.tex
 
b/tp/t/results/latex_tests/titlepage_with_commands_classical/res_latex/titlepage_with_commands_classical.tex
index 5118f09a08..b47359f8d9 100644
--- 
a/tp/t/results/latex_tests/titlepage_with_commands_classical/res_latex/titlepage_with_commands_classical.tex
+++ 
b/tp/t/results/latex_tests/titlepage_with_commands_classical/res_latex/titlepage_with_commands_classical.tex
@@ -140,13 +140,13 @@ $$
 }}%
 \vskip4pt \hrule height 2pt width \hsize
   \vskip\titlepagebottomglue
+\endgroup
 \newpage{}%
 \phantom{blabla}%
 \newpage{}%
 \phantom{blabla}%
 \vskip 0pt plus 1filll
 in Copying
-\endgroup
 \end{titlepage}
 \GNUTexinfosetsingleheader{}%
 \GNUTexinfomainmatter



reply via email to

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