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 (_convert), tp/Te


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/HTML.pm (_convert_heading_command), tp/Texinfo/Convert/LaTeX.pm (output) (_convert): stop skipping node Top output at a @part.
Date: Sat, 09 Apr 2022 17:30:32 -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 2a8a8f94a3 * tp/Texinfo/Convert/DocBook.pm (_convert), 
tp/Texinfo/Convert/HTML.pm (_convert_heading_command), 
tp/Texinfo/Convert/LaTeX.pm (output) (_convert): stop skipping node Top output 
at a @part.
2a8a8f94a3 is described below

commit 2a8a8f94a356d88e22087d5acb26acefbfbfc6a9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Apr 9 23:25:59 2022 +0200

    * tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/HTML.pm
    (_convert_heading_command), tp/Texinfo/Convert/LaTeX.pm (output)
    (_convert): stop skipping node Top output at a @part.
    
    * tp/Texinfo/Convert/DocBook.pm (_convert): process non output commands
    when skipping Top node, in particular put the same lang on top of
    lang_stack.
---
 ChangeLog                                          |  10 ++
 tp/Texinfo/Convert/DocBook.pm                      | 101 +++++++++++----------
 tp/Texinfo/Convert/HTML.pm                         |   4 +-
 tp/Texinfo/Convert/LaTeX.pm                        |   7 +-
 tp/t/30sectioning.t                                |   8 +-
 tp/t/results/converters_tests/non_empty_part.pl    |  18 +++-
 .../non_empty_part_no_top_node_output.pl           |  15 ++-
 tp/t/results/sectioning/top_node_part_top.pl       |  92 ++++++++++++++++++-
 8 files changed, 196 insertions(+), 59 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a3c3304b53..f2476de060 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-04-09  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/HTML.pm
+       (_convert_heading_command), tp/Texinfo/Convert/LaTeX.pm (output)
+       (_convert): stop skipping node Top output at a @part.
+
+       * tp/Texinfo/Convert/DocBook.pm (_convert): process non output commands
+       when skipping Top node, in particular put the same lang on top of
+       lang_stack.
+
 2022-04-09  Gavin Smith  <gavinsmith0123@gmail.com>
 
        user- prefix for @example args
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 5d5b798f5f..c51df5def8 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -799,10 +799,10 @@ sub _convert($$;$)
                    and $element->{'extra'}->{'part_following_node'}) {
               $node_element = $element->{'extra'}->{'part_following_node'};
             }
-            if ($node_element) {
+            if ($node_element or $element->{'cmdname'} eq 'part') {
               # $node_element->{'extra'}->{'normalized'} not defined happens 
for
               # empty nodes
-              if ($node_element->{'extra'}
+              if ($node_element and $node_element->{'extra'}
                   and $node_element->{'extra'}->{'normalized'}
                   and $node_element->{'extra'}->{'normalized'} eq 'Top') {
                 $self->{'in_skipped_node_top'} = 1;
@@ -845,55 +845,62 @@ sub _convert($$;$)
               push @opened_elements, $part if $part;
               if ($section_element) {
                 push @opened_elements, $section_element;
-                $sectioning_commands_done{$section_element} = 1;
               }
             }
             foreach my $opened_element (@opened_elements) {
-              my $section_attribute = '';
-              # FIXME it is not clear that a label should be set for
-              # @appendix* or @chapter/@*section as the formatter should be
-              # able to figure it out.  For @unnumbered or if ! NUMBER_SECTIONS
-              # having a label (empty) is important.
-              my $label = '';
-              if (defined($opened_element->{'structure'}->{'section_number'})
-                and ($self->get_conf('NUMBER_SECTIONS')
-                     or !defined($self->get_conf('NUMBER_SECTIONS')))) {
-                # Looking at docbook2html output, Appendix is appended in the
-                # section title, so only the letter is used.
-                $label = $opened_element->{'structure'}->{'section_number'};
-              }
-              my $docbook_sectioning_element
-                 = $self->_docbook_section_element($opened_element);
-              if (! $docbook_special_unnumbered{$docbook_sectioning_element}) {
-                $section_attribute .= " label=\"$label\"";
-              }
-              if ($opened_element->{'extra'} and 
$opened_element->{'extra'}->{'associated_node'}) {
-                $section_attribute
-                 .= " 
id=\"$opened_element->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'}\"";
-              }
-              my $language = '';
-              if (defined($self->get_conf('documentlanguage'))) {
-                $language = $self->get_conf('documentlanguage');
-                if ($self->{'lang_stack'}->[-1] ne 
$self->get_conf('documentlanguage')) {
-                  $section_attribute .= ' 
lang="'.$self->get_conf('documentlanguage').'"';
+              if (not (defined($self->{'in_skipped_node_top'})
+                       and $self->{'in_skipped_node_top'} == 1)) {
+                if ($section_element and $opened_element eq $section_element) {
+                  $sectioning_commands_done{$section_element} = 1;
                 }
-              }
-              push @{$self->{'lang_stack'}}, $language;
-              $result .= "<$docbook_sectioning_element${section_attribute}>\n";
-              if ($opened_element->{'args'} and 
$opened_element->{'args'}->[0]) {
-                my ($arg, $end_line) = 
$self->_convert_argument_and_end_line($opened_element);
-                $result .= "<title>$arg</title>$end_line";
-                chomp ($result);
-                $result .= "\n";
-              }
-              # if associated with a sectioning element, the part is opened 
before the
-              # sectioning element, such that the part content appears after 
the sectioning
-              # command opening, no need for partintro.
-              if ($docbook_sectioning_element eq 'part'
-                  and not ($opened_element->{'extra'}
-                           and 
$opened_element->{'extra'}->{'part_associated_section'})
-                  and !Texinfo::Common::is_content_empty($opened_element)) {
-                $result .= "<partintro>\n";
+                my $section_attribute = '';
+                # FIXME it is not clear that a label should be set for
+                # @appendix* or @chapter/@*section as the formatter should be
+                # able to figure it out.  For @unnumbered or if ! 
NUMBER_SECTIONS
+                # having a label (empty) is important.
+                my $label = '';
+                if (defined($opened_element->{'structure'}->{'section_number'})
+                  and ($self->get_conf('NUMBER_SECTIONS')
+                       or !defined($self->get_conf('NUMBER_SECTIONS')))) {
+                  # Looking at docbook2html output, Appendix is appended in the
+                  # section title, so only the letter is used.
+                  $label = $opened_element->{'structure'}->{'section_number'};
+                }
+                my $docbook_sectioning_element
+                   = $self->_docbook_section_element($opened_element);
+                if (! 
$docbook_special_unnumbered{$docbook_sectioning_element}) {
+                  $section_attribute .= " label=\"$label\"";
+                }
+                if ($opened_element->{'extra'} and 
$opened_element->{'extra'}->{'associated_node'}) {
+                  $section_attribute
+                   .= " 
id=\"$opened_element->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'}\"";
+                }
+                my $language = '';
+                if (defined($self->get_conf('documentlanguage'))) {
+                  $language = $self->get_conf('documentlanguage');
+                  if ($self->{'lang_stack'}->[-1] ne $language) {
+                    $section_attribute .= ' lang="'.$language.'"';
+                  }
+                }
+                push @{$self->{'lang_stack'}}, $language;
+                $result .= 
"<$docbook_sectioning_element${section_attribute}>\n";
+                if ($opened_element->{'args'} and 
$opened_element->{'args'}->[0]) {
+                  my ($arg, $end_line) = 
$self->_convert_argument_and_end_line($opened_element);
+                  $result .= "<title>$arg</title>$end_line";
+                  chomp ($result);
+                  $result .= "\n";
+                }
+                # if associated with a sectioning element, the part is opened 
before the
+                # sectioning element, such that the part content appears after 
the sectioning
+                # command opening, no need for partintro.
+                if ($docbook_sectioning_element eq 'part'
+                    and not ($opened_element->{'extra'}
+                             and 
$opened_element->{'extra'}->{'part_associated_section'})
+                    and !Texinfo::Common::is_content_empty($opened_element)) {
+                  $result .= "<partintro>\n";
+                }
+              } else {
+                push @{$self->{'lang_stack'}}, $self->{'lang_stack'}->[-1];
               }
             }
           }
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 7ef3359b1a..949075a918 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -3599,8 +3599,8 @@ sub _convert_heading_command($$$$$)
              and $element->{'extra'}->{'part_following_node'}) {
       $node_element = $element->{'extra'}->{'part_following_node'};
     }
-    if ($node_element) {
-      if ($node_element->{'extra'}
+    if ($node_element or $cmdname eq 'part') {
+      if ($node_element and $node_element->{'extra'}
           and $node_element->{'extra'}->{'normalized'}
           and $node_element->{'extra'}->{'normalized'} eq 'Top') {
         $$in_skipped_node_top = 1;
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 9e2f09ab2b..8a4db9d4cf 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -903,7 +903,7 @@ sub _associate_other_nodes_to_sections($$)
     = $additional_node_section_associations;
 }
 
-# mark in the tree where the \begin{document} should be,
+# this type marks where the \begin{document} should be,
 # after the @-commands in preamble.  It is not setup
 # when using parse_texi_piece only.
 my $latex_document_type = 'preamble_before_content';
@@ -953,7 +953,7 @@ sub output($$)
                and $element_content->{'extra'}->{'part_following_node'}) {
         $node_element = $element_content->{'extra'}->{'part_following_node'};
       }
-      if ($node_element) {
+      if ($node_element or $cmdname eq 'part') {
         if ($node_element->{'extra'}
             and $node_element->{'extra'}->{'normalized'}
             and $node_element->{'extra'}->{'normalized'} eq 'Top') {
@@ -2076,7 +2076,8 @@ sub _convert($$)
          and not ($node_element->{'extra'}
                   and $node_element->{'extra'}->{'normalized'}
                   and $node_element->{'extra'}->{'normalized'} eq 'Top'))
-         or (defined($type) and $type eq 'ignored_top_node_paragraph')) {
+         or (defined($type) and $type eq 'ignored_top_node_paragraph')
+        or (defined($cmdname) and $cmdname eq 'part')) {
       delete $self->{'formatting_context'}->[-1]->{'in_skipped_node_top'};
     } elsif (! defined($cmdname)
              or (not ($informative_commands{$cmdname}
diff --git a/tp/t/30sectioning.t b/tp/t/30sectioning.t
index b94f3e0fb0..bc7ac6cd3f 100644
--- a/tp/t/30sectioning.t
+++ b/tp/t/30sectioning.t
@@ -1122,6 +1122,9 @@ Top node
 
 @part part
 '],
+# FIXME in DocBook the nesting is incorrect, part is opened before chapter
+# and is closed first too.  This is not an important bug, however, as
+# this construct is not normal, and @top has no equivalent in DocBook.
 ['top_node_part_top',
 '@node Top
 
@@ -2116,12 +2119,13 @@ my @docbook_tests_info_tests = (
 my @latex_tests_info_tests = ('chapter_between_nodes',
   'section_before_after_top_node_last_node',
   'section_before_after_top_node',
-  'section_chapter_before_top_nodes', 'unnumbered_top_without_node_sections');
+  'section_chapter_before_top_nodes', 'unnumbered_top_without_node_sections',
+  'top_node_part_top');
 
 my @file_latex_tests_info_tests = ('chapter_between_nodes',
   'section_before_after_top_node_last_node',
   'section_before_after_top_node',
-  'section_chapter_before_top_nodes');
+  'section_chapter_before_top_nodes', 'top_node_part_top');
 
 foreach my $test (@tests_info) {
   push @{$test->[2]->{'test_formats'}}, 'info';
diff --git a/tp/t/results/converters_tests/non_empty_part.pl 
b/tp/t/results/converters_tests/non_empty_part.pl
index ca82965c9b..bce99ef4cd 100644
--- a/tp/t/results/converters_tests/non_empty_part.pl
+++ b/tp/t/results/converters_tests/non_empty_part.pl
@@ -1718,6 +1718,16 @@ $result_converted{'xml'}->{'non_empty_part'} = '<part 
spaces=" "><sectiontitle>p
 
 
 $result_converted{'docbook'}->{'non_empty_part'} = '<part label="">
+<title>part I</title>
+<chapter label="1">
+<title>chap in Top node</title>
+
+<para>Content I
+</para>
+
+</chapter>
+</part>
+<part label="">
 <title>Part II</title>
 <partintro>
 
@@ -1767,7 +1777,13 @@ $result_converted{'docbook'}->{'non_empty_part'} = 
'<part label="">
 ';
 
 
-$result_converted{'latex'}->{'non_empty_part'} = '\\part{Part II}
+$result_converted{'latex'}->{'non_empty_part'} = '\\part{part I}
+
+Content I
+
+\\chapter{chap in Top node}
+
+\\part{Part II}
 
 Content II
 
diff --git a/tp/t/results/converters_tests/non_empty_part_no_top_node_output.pl 
b/tp/t/results/converters_tests/non_empty_part_no_top_node_output.pl
index 8c8347f627..2520c4a6b8 100644
--- a/tp/t/results/converters_tests/non_empty_part_no_top_node_output.pl
+++ b/tp/t/results/converters_tests/non_empty_part_no_top_node_output.pl
@@ -1527,10 +1527,21 @@ 
$result_converted{'html_text'}->{'non_empty_part_no_top_node_output'} = '<a clas
 <p>
  &nbsp; </p>
 </div>
-<a class="node" id="Top"></a><a class="top" id="top"></a><a class="part" 
id="part-I"></a><ul class="mini-toc">
+<a class="node" id="Top"></a><a class="top" id="top"></a><div 
class="part-level-extent" id="part-I">
+<h1 class="part">part I</h1>
+<hr>
+
+<p>Content I
+</p>
+<ul class="mini-toc">
 <li><a href="#chap-in-Top-node" accesskey="1">chap in Top node</a></li>
 </ul>
-<a class="chapter" id="chap-in-Top-node"></a><hr>
+<div class="chapter-level-extent" id="chap-in-Top-node">
+<h2 class="chapter">1 chap in Top node</h2>
+
+<hr>
+</div>
+</div>
 <div class="part-level-extent" id="Part-II">
 <div class="nav-panel">
 <p>
diff --git a/tp/t/results/sectioning/top_node_part_top.pl 
b/tp/t/results/sectioning/top_node_part_top.pl
index 94ce90c151..fcd7fc1cb1 100644
--- a/tp/t/results/sectioning/top_node_part_top.pl
+++ b/tp/t/results/sectioning/top_node_part_top.pl
@@ -9,7 +9,13 @@ $result_trees{'top_node_part_top'} = [
   {
     'contents' => [
       {
-        'contents' => [],
+        'contents' => [
+          {
+            'contents' => [],
+            'parent' => {},
+            'type' => 'preamble_before_content'
+          }
+        ],
         'parent' => {
           'contents' => [
             {},
@@ -142,6 +148,7 @@ $result_trees{'top_node_part_top'} = [
     'type' => 'unit'
   }
 ];
+$result_trees{'top_node_part_top'}[0]{'contents'}[0]{'contents'}[0]{'parent'} 
= $result_trees{'top_node_part_top'}[0]{'contents'}[0];
 $result_trees{'top_node_part_top'}[0]{'contents'}[0]{'parent'}{'contents'}[0] 
= $result_trees{'top_node_part_top'}[0]{'contents'}[0];
 
$result_trees{'top_node_part_top'}[0]{'contents'}[0]{'parent'}{'contents'}[1]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'top_node_part_top'}[0]{'contents'}[0]{'parent'}{'contents'}[1]{'args'}[0];
 
$result_trees{'top_node_part_top'}[0]{'contents'}[0]{'parent'}{'contents'}[1]{'args'}[0]{'parent'}
 = 
$result_trees{'top_node_part_top'}[0]{'contents'}[0]{'parent'}{'contents'}[1];
@@ -444,6 +451,87 @@ $result_converted{'xml'}->{'top_node_part_top'} = '<node 
name="Top" spaces=" "><
 ';
 
 
-$result_converted{'docbook'}->{'top_node_part_top'} = '';
+$result_converted{'docbook'}->{'top_node_part_top'} = '<part label="">
+<title>part</title>
+<chapter label="" id="Top">
+<title>top</title>
+
+</part>
+</chapter>
+';
+
+
+$result_converted{'latex'}->{'top_node_part_top'} = '\\begin{document}
+\\part{part}
+
+\\part*{top}
+\\label{anchor:Top}%
+';
+
+
+$result_converted{'file_latex'}->{'top_node_part_top'} = '\\documentclass{book}
+\\usepackage{amsfonts}
+\\usepackage{amsmath}
+\\usepackage[gen]{eurosym}
+\\usepackage[T1]{fontenc}
+\\usepackage{textcomp}
+\\usepackage{graphicx}
+\\usepackage{etoolbox}
+\\usepackage{titleps}
+\\usepackage{float}
+% use hidelinks to remove boxes around links to be similar with Texinfo TeX
+\\usepackage[hidelinks]{hyperref}
+\\usepackage[utf8]{inputenc}
+
+\\newcommand{\\GNUTexinfosettitle}{No Title}%
+
+% redefine the \\mainmatter command such that it does not clear page
+% as if in double page
+\\makeatletter
+\\renewcommand\\mainmatter{\\clearpage\\@mainmattertrue\\pagenumbering{arabic}}
+\\makeatother
+% add command aliases to use the same command in book and report
+\\newcommand\\GNUTexinfomainmatter{\\mainmatter}
+\\newcommand\\GNUTexinfofrontmatter{\\frontmatter}
+% command that does nothing used to help with substitutions in commands
+\\newcommand{\\GNUTexinfoplaceholder}[1]{}
+
+% plain page style, for part and chapter, which call \\thispagestyle{plain}
+\\renewpagestyle{plain}{\\sethead[\\thepage{}][][]
+                             {}{}{\\thepage{}}}
+
+% single header
+\\newpagestyle{single}{\\sethead[\\chaptername{} \\thechapter{} 
\\chaptertitle{}][][\\thepage]
+                              {\\chaptername{} \\thechapter{} 
\\chaptertitle{}}{}{\\thepage}}
+
+% called when setting single headers
+\\newcommand{\\GNUTexinfosetsingleheader}{\\pagestyle{single}}
+
+% double header
+\\newpagestyle{double}{\\sethead[\\thepage{}][][\\GNUTexinfosettitle]
+                              {\\chaptername{} \\thechapter{} 
\\chaptertitle{}}{}{\\thepage}}
+
+% called when setting double headers
+\\newcommand{\\GNUTexinfosetdoubleheader}{\\pagestyle{double}}
+
+
+% avoid pagebreak and headings setting for a sectionning command
+\\newcommand{\\GNUTexinfonopagebreakheading}[2]{\\let\\clearpage\\relax 
\\let\\cleardoublepage\\relax \\let\\thispagestyle\\GNUTexinfoplaceholder 
#1{#2}}
+
+\\renewcommand{\\includegraphics}[1]{\\fbox{FIG #1}}
+
+% set default for @setchapternewpage
+\\makeatletter
+\\patchcmd{\\chapter}{\\if@openright\\cleardoublepage\\else\\clearpage\\fi}{\\GNUTexinfoplaceholder{setchapternewpage
 placeholder}\\clearpage}{}{}
+\\makeatother
+\\GNUTexinfosetsingleheader{}%
+
+\\begin{document}
+\\part{part}
+
+\\part*{top}
+\\label{anchor:Top}%
+\\end{document}
+';
 
 1;



reply via email to

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