texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/init/book.pm (book_in_contents_button, @book


From: Patrice Dumas
Subject: branch master updated: * tp/init/book.pm (book_in_contents_button, @book_contents_buttons) (@book_output_unit_buttons): for regular output units (not for Top or special output units), have the Contents button link to the section location in table of contents, similarly with TOC_LINKS, but for a button. Based on Rudolf Adamkovič idea.
Date: Tue, 15 Oct 2024 18:13:47 -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 7dbdd8573d * tp/init/book.pm (book_in_contents_button, 
@book_contents_buttons) (@book_output_unit_buttons): for regular output units 
(not for Top or special output units), have the Contents button link to the 
section location in table of contents, similarly with TOC_LINKS, but for a 
button.  Based on Rudolf Adamkovič idea.
7dbdd8573d is described below

commit 7dbdd8573d70679faa88f308330c3d5be9178497
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Oct 16 00:11:39 2024 +0200

    * tp/init/book.pm (book_in_contents_button, @book_contents_buttons)
    (@book_output_unit_buttons): for regular output units (not for Top or
    special output units), have the Contents button link to the section
    location in table of contents, similarly with TOC_LINKS, but for
    a button.  Based on Rudolf Adamkovič idea.
---
 ChangeLog                                          |  8 ++++++
 tp/TODO                                            |  2 ++
 tp/init/book.pm                                    | 32 ++++++++++++++++++++--
 .../res_html/double_contents.html                  |  4 +--
 .../double_contents.html                           |  4 +--
 .../double_contents_1.html                         |  4 +--
 .../double_contents_book/double_contents.html      |  4 +--
 7 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 68da96c5cb..48f5ed8143 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-10-15  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/init/book.pm (book_in_contents_button, @book_contents_buttons)
+       (@book_output_unit_buttons): for regular output units (not for Top or
+       special output units), have the Contents button link to the section
+       location in table of contents, similarly with TOC_LINKS, but for
+       a button.  Based on Rudolf Adamkovič idea.
+
 2024-10-15  Gavin Smith <gavinsmith0123@gmail.com>
 
        Fix install-info memory leak
diff --git a/tp/TODO b/tp/TODO
index a2eef0353e..e6e8ddc8ae 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -10,6 +10,8 @@ This is the todo list for texi2any
 Before next release
 ===================
 
+$srcdir/texi2any.pl --html --init=$srcdir/init/book.pm 
$srcdir/../doc/texinfo.texi -c documentlanguage fr
+
 
 Update search directories in C codes for the XDG Base Directory Specification
 based on what is done in Perl.  Need to wait to be clear on what is done
diff --git a/tp/init/book.pm b/tp/init/book.pm
index 6f71c2b003..ebe4b4558a 100644
--- a/tp/init/book.pm
+++ b/tp/init/book.pm
@@ -24,6 +24,8 @@ use strict;
 # To check if there is no erroneous autovivification
 #no autovivification qw(fetch delete exists store strict);
 
+#use Carp qw(cluck);
+
 use Texinfo::Commands;
 use Texinfo::Common;
 use Texinfo::Convert::Texinfo;
@@ -36,10 +38,34 @@ texinfo_set_from_init_file('contents', 1);
 texinfo_set_from_init_file('CONTENTS_OUTPUT_LOCATION', 'inline');
 texinfo_set_from_init_file('NO_TOP_NODE_OUTPUT', 1);
 
-my @book_buttons = ('Back', 'Forward', ' ', 'Contents', 'Index', 'About');
+# Following Rudolf Adamkovič idea, have Contents button for regular output
+# units link to the section in table of contents.
+sub book_in_contents_button {
+  my ($self, $direction, $element) = @_;
+
+  if ($element->{'extra'}->{'associated_section'}) {
+    $element = $element->{'extra'}->{'associated_section'};
+  }
+
+  my $href = $self->command_contents_href($element, 'contents');
+
+  # Call direction_string to have Contents translated.
+  return ("[<a href=\"$href\">".
+           $self->direction_string('Contents', 'text')."</a>]", 0);
+}
+
+my @book_contents_buttons = ('Back', 'Forward', ' ', 'Contents', 'Index', 
'About');
+
+foreach my $buttons ('TOP_BUTTONS') {
+  texinfo_set_from_init_file($buttons, \@book_contents_buttons);
+}
+
+my @book_output_unit_buttons = ('Back', 'Forward', ' ',
+                                ['This', \&book_in_contents_button],
+                                'Index', 'About');
 
-foreach my $buttons ('SECTION_BUTTONS', 'CHAPTER_BUTTONS', 'TOP_BUTTONS') {
-  texinfo_set_from_init_file($buttons, \@book_buttons);
+foreach my $buttons ('SECTION_BUTTONS', 'CHAPTER_BUTTONS') {
+  texinfo_set_from_init_file($buttons, \@book_output_unit_buttons);
 }
 
 my @book_footer_buttons = ('Contents', 'Index', 'About');
diff --git 
a/tp/t/results/html_tests/double_contents_book/res_html/double_contents.html 
b/tp/t/results/html_tests/double_contents_book/res_html/double_contents.html
index 4ea6e04808..ad701a5862 100644
--- a/tp/t/results/html_tests/double_contents_book/res_html/double_contents.html
+++ b/tp/t/results/html_tests/double_contents_book/res_html/double_contents.html
@@ -53,7 +53,7 @@ ul.toc-numbered-mark {list-style: none}
 <div class="chapter-level-extent" id="chapter">
 <div class="nav-panel">
 <p>
-[<a href="#Top" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>][<a href="#section" title="Next section in reading order" 
accesskey="n" rel="next"> &gt; </a>] &nbsp; [<a href="#SEC_Contents" 
title="Table of contents" rel="contents">Contents</a>]</p>
+[<a href="#Top" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>][<a href="#section" title="Next section in reading order" 
accesskey="n" rel="next"> &gt; </a>] &nbsp; [<a 
href="#toc-Chapter-1">Contents</a>]</p>
 </div>
 <h2 class="chapter" id="Chapter-1"><span>1 Chapter 1<a class="copiable-link" 
href="#Chapter-1"> &para;</a></span></h2>
 <ul class="toc-numbered-mark">
@@ -80,7 +80,7 @@ ul.toc-numbered-mark {list-style: none}
 <div class="section-level-extent" id="section">
 <div class="nav-panel">
 <p>
-[<a href="#chapter" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>] &nbsp; [<a href="#SEC_Contents" title="Table of 
contents" rel="contents">Contents</a>]</p>
+[<a href="#chapter" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>] &nbsp; [<a 
href="#toc-section-with-contents">Contents</a>]</p>
 </div>
 <h3 class="section" id="section-with-contents"><span>1.1 section with 
contents<a class="copiable-link" href="#section-with-contents"> 
&para;</a></span></h3>
 <div class="region-contents" id="SEC_Contents">
diff --git 
a/tp/tests/customization/res_parser/double_contents_after_title_book/double_contents.html
 
b/tp/tests/customization/res_parser/double_contents_after_title_book/double_contents.html
index 7bccdb454f..52f8ead27a 100644
--- 
a/tp/tests/customization/res_parser/double_contents_after_title_book/double_contents.html
+++ 
b/tp/tests/customization/res_parser/double_contents_after_title_book/double_contents.html
@@ -49,7 +49,7 @@ ul.toc-numbered-mark {list-style: none}
 <div class="chapter-level-extent" id="chapter">
 <div class="nav-panel">
 <p>
-[<a href="#Top" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>][<a href="#section" title="Next section in reading order" 
accesskey="n" rel="next"> &gt; </a>] &nbsp; [<a href="#SEC_Contents" 
title="Table of contents" rel="contents">Contents</a>]</p>
+[<a href="#Top" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>][<a href="#section" title="Next section in reading order" 
accesskey="n" rel="next"> &gt; </a>] &nbsp; [<a 
href="#toc-Chapter-1">Contents</a>]</p>
 </div>
 <h2 class="chapter" id="Chapter-1"><span>1 Chapter 1<a class="copiable-link" 
href="#Chapter-1"> &para;</a></span></h2>
 <ul class="toc-numbered-mark">
@@ -63,7 +63,7 @@ ul.toc-numbered-mark {list-style: none}
 <div class="section-level-extent" id="section">
 <div class="nav-panel">
 <p>
-[<a href="#chapter" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>] &nbsp; [<a href="#SEC_Contents" title="Table of 
contents" rel="contents">Contents</a>]</p>
+[<a href="#chapter" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>] &nbsp; [<a 
href="#toc-section-with-contents">Contents</a>]</p>
 </div>
 <h3 class="section" id="section-with-contents"><span>1.1 section with 
contents<a class="copiable-link" href="#section-with-contents"> 
&para;</a></span></h3>
 
diff --git 
a/tp/tests/customization/res_parser/double_contents_after_title_book_chapter/double_contents_1.html
 
b/tp/tests/customization/res_parser/double_contents_after_title_book_chapter/double_contents_1.html
index 9b7ce8c861..7272c7a6ac 100644
--- 
a/tp/tests/customization/res_parser/double_contents_after_title_book_chapter/double_contents_1.html
+++ 
b/tp/tests/customization/res_parser/double_contents_after_title_book_chapter/double_contents_1.html
@@ -33,7 +33,7 @@ ul.toc-numbered-mark {list-style: none}
 </ul>
 <div class="nav-panel">
 <p>
-[<a href="double_contents_top.html" title="Previous section in reading order" 
accesskey="p" rel="prev"> &lt; </a>][<a href="#section" title="Next section in 
reading order" accesskey="n" rel="next"> &gt; </a>] &nbsp; [<a 
href="double_contents_top.html#SEC_Contents" title="Table of contents" 
rel="contents">Contents</a>]</p>
+[<a href="double_contents_top.html" title="Previous section in reading order" 
accesskey="p" rel="prev"> &lt; </a>][<a href="#section" title="Next section in 
reading order" accesskey="n" rel="next"> &gt; </a>] &nbsp; [<a 
href="double_contents_top.html#toc-Chapter-1">Contents</a>]</p>
 </div>
 <h2 class="chapter" id="Chapter-1"><span>1 Chapter 1<a class="copiable-link" 
href="#Chapter-1"> &para;</a></span></h2>
 <ul class="toc-numbered-mark">
@@ -47,7 +47,7 @@ ul.toc-numbered-mark {list-style: none}
 <div class="section-level-extent" id="section">
 <div class="nav-panel">
 <p>
-[<a href="#chapter" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>] &nbsp; [<a href="double_contents_top.html#SEC_Contents" 
title="Table of contents" rel="contents">Contents</a>]</p>
+[<a href="#chapter" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>] &nbsp; [<a 
href="double_contents_top.html#toc-section-with-contents">Contents</a>]</p>
 </div>
 <h3 class="section" id="section-with-contents"><span>1.1 section with 
contents<a class="copiable-link" href="#section-with-contents"> 
&para;</a></span></h3>
 
diff --git 
a/tp/tests/customization/res_parser/double_contents_book/double_contents.html 
b/tp/tests/customization/res_parser/double_contents_book/double_contents.html
index c954ea8f0e..1118a45bfe 100644
--- 
a/tp/tests/customization/res_parser/double_contents_book/double_contents.html
+++ 
b/tp/tests/customization/res_parser/double_contents_book/double_contents.html
@@ -54,7 +54,7 @@ ul.toc-numbered-mark {list-style: none}
 <div class="chapter-level-extent" id="chapter">
 <div class="nav-panel">
 <p>
-[<a href="#Top" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>][<a href="#section" title="Next section in reading order" 
accesskey="n" rel="next"> &gt; </a>] &nbsp; [<a href="#SEC_Contents" 
title="Table of contents" rel="contents">Contents</a>]</p>
+[<a href="#Top" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>][<a href="#section" title="Next section in reading order" 
accesskey="n" rel="next"> &gt; </a>] &nbsp; [<a 
href="#toc-Chapter-1">Contents</a>]</p>
 </div>
 <h2 class="chapter" id="Chapter-1"><span>1 Chapter 1<a class="copiable-link" 
href="#Chapter-1"> &para;</a></span></h2>
 <ul class="toc-numbered-mark">
@@ -81,7 +81,7 @@ ul.toc-numbered-mark {list-style: none}
 <div class="section-level-extent" id="section">
 <div class="nav-panel">
 <p>
-[<a href="#chapter" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>] &nbsp; [<a href="#SEC_Contents" title="Table of 
contents" rel="contents">Contents</a>]</p>
+[<a href="#chapter" title="Previous section in reading order" accesskey="p" 
rel="prev"> &lt; </a>] &nbsp; [<a 
href="#toc-section-with-contents">Contents</a>]</p>
 </div>
 <h3 class="section" id="section-with-contents"><span>1.1 section with 
contents<a class="copiable-link" href="#section-with-contents"> 
&para;</a></span></h3>
 <div class="region-contents" id="SEC_Contents">



reply via email to

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