texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/ext/epub3.pm (epub_finish): fix nav file for


From: Patrice Dumas
Subject: branch master updated: * tp/ext/epub3.pm (epub_finish): fix nav file formatting with a command with a zero section level not appearing first, by consistently using $section_level.
Date: Sat, 07 Sep 2024 14:39:11 -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 38119c67dc * tp/ext/epub3.pm (epub_finish): fix nav file formatting 
with a command with a zero section level not appearing first, by consistently 
using $section_level.
38119c67dc is described below

commit 38119c67dc7268ee4b4a6326069b8ee1efc34269
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Sep 7 20:39:10 2024 +0200

    * tp/ext/epub3.pm (epub_finish): fix nav file formatting with a
    command with a zero section level not appearing first, by consistently
    using $section_level.
    
    * tp/Makefile.tres, tp/t/html_tests.t (chapter_before_top_epub): test
    chapter before top in epub for nav file formatting.
    
    * tp/maintain/check_epubcheck_texi_t.sh: show the command used to
    generate EPUB in log.
---
 ChangeLog                                          |  12 +
 tp/Makefile.tres                                   |   2 +
 tp/ext/epub3.pm                                    |   2 +-
 tp/maintain/check_epubcheck_texi_t.sh              |   4 +-
 tp/t/html_tests.t                                  |  12 +
 tp/t/results/html_tests/chapter_before_top_epub.pl | 313 +++++++++++++++++++++
 .../EPUB/chapter_before_top_epub.opf               |  17 ++
 .../EPUB/xhtml/chapter_before_top_epub.xhtml       |  30 ++
 .../EPUB/xhtml/nav_toc.xhtml                       |  17 ++
 .../EPUB/xhtml/top.xhtml                           |  32 +++
 .../META-INF/container.xml                         |   7 +
 .../chapter_before_top_epub_epub_package/mimetype  |   1 +
 12 files changed, 447 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5f8da3efe4..030c6b90e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-09-07  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/ext/epub3.pm (epub_finish): fix nav file formatting with a
+       command with a zero section level not appearing first, by consistently
+       using $section_level.
+
+       * tp/Makefile.tres, tp/t/html_tests.t (chapter_before_top_epub): test
+       chapter before top in epub for nav file formatting.
+
+       * tp/maintain/check_epubcheck_texi_t.sh: show the command used to
+       generate EPUB in log.
+
 2024-09-07  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/HTML.pm (_convert_xref_commands),
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 7075766b5c..e713437b34 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -571,6 +571,8 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/html_tests/automatic_menus.pl \
   t/results/html_tests/base_for_css_info_in_init_test.pl \
   t/results/html_tests/base_for_css_info_in_init_test/res_html \
+  t/results/html_tests/chapter_before_top_epub.pl \
+  t/results/html_tests/chapter_before_top_epub/res_html \
   t/results/html_tests/character_number_leading_toc_stoc.pl \
   t/results/html_tests/check_htmlxref.pl \
   t/results/html_tests/check_htmlxref_ignore_ref_top_up.pl \
diff --git a/tp/ext/epub3.pm b/tp/ext/epub3.pm
index 7ad4b66d49..6ce8d2ba70 100644
--- a/tp/ext/epub3.pm
+++ b/tp/ext/epub3.pm
@@ -743,7 +743,7 @@ EOT
           print $nav_fh "\n". " " x $level . "<ol>\n";
           $level++;
         }
-      } elsif ($level > $section->{'extra'}->{'section_level'}) {
+      } elsif ($level > $section_level) {
         # on the same line as the a element for the first </li>
         print $nav_fh "</li>\n". " " x ($level -1) . "</ol>\n";
         $level--;
diff --git a/tp/maintain/check_epubcheck_texi_t.sh 
b/tp/maintain/check_epubcheck_texi_t.sh
index fa9fdafe06..60ca859410 100755
--- a/tp/maintain/check_epubcheck_texi_t.sh
+++ b/tp/maintain/check_epubcheck_texi_t.sh
@@ -85,7 +85,9 @@ for dir in `find t_texis/ -type d` ; do
       continue
     fi
     echo "    -> $file: EPUB"
-    ${srcdir}/texi2any.pl --epub --force --error=100000 -o 
$mdir/epubcheck_EPUB/$bdir/$bfile.epub -c 
SUBDIR=$mdir/epubcheck_package/$bdir/${bfile}_epub_package -c EPUB_STRICT=1 -c 
EPUB_KEEP_CONTAINER_FOLDER=1 -c NO_TOP_NODE_OUTPUT=0 -c SHOW_TITLE=1 $file
+    cmd="${srcdir}/texi2any.pl --epub --force --error=100000 -o 
$mdir/epubcheck_EPUB/$bdir/$bfile.epub -c 
SUBDIR=$mdir/epubcheck_package/$bdir/${bfile}_epub_package -c EPUB_STRICT=1 -c 
EPUB_KEEP_CONTAINER_FOLDER=1 -c NO_TOP_NODE_OUTPUT=0 -c SHOW_TITLE=1 $file"
+    echo $cmd
+    $cmd
     echo "              epubcheck"
     epubcheck $mdir/epubcheck_EPUB/$bdir/$bfile.epub 
2>$mdir/epubcheck_check/$bdir/$bfile.out
   done
diff --git a/tp/t/html_tests.t b/tp/t/html_tests.t
index 7113da6f37..88d103fef6 100644
--- a/tp/t/html_tests.t
+++ b/tp/t/html_tests.t
@@ -1542,6 +1542,18 @@ undef, {'test_file' => 
'simple_only_special_spaces_node.texi',
 ', {'init_files' => ['epub3.pm'],
     'test_input_file_name' => 'very badly placed setfilename.texi'},
    {'EPUB_CREATE_CONTAINER_FILE' => 0}],
+# test for the nav file
+['chapter_before_top_epub',
+'@node Top
+
+@node chapter
+@chapter chapter
+
+@part part
+
+@top top
+', {'init_files' => ['epub3.pm']},
+   {'EPUB_CREATE_CONTAINER_FILE' => 0}],
 );
 
 
diff --git a/tp/t/results/html_tests/chapter_before_top_epub.pl 
b/tp/t/results/html_tests/chapter_before_top_epub.pl
new file mode 100644
index 0000000000..9a00c90af0
--- /dev/null
+++ b/tp/t/results/html_tests/chapter_before_top_epub.pl
@@ -0,0 +1,313 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'chapter_before_top_epub'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'type' => 'preamble_before_content'
+        }
+      ],
+      'type' => 'before_node_section'
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'Top'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'node',
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        }
+      ],
+      'extra' => {
+        'is_target' => 1,
+        'normalized' => 'Top'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 1
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'chapter'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'node',
+      'extra' => {
+        'is_target' => 1,
+        'normalized' => 'chapter'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 3
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'chapter'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'chapter',
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        }
+      ],
+      'extra' => {
+        'section_number' => '1'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 4
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'part'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'part',
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        }
+      ],
+      'extra' => {},
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 6
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'top'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'top',
+      'extra' => {
+        'associated_part' => {}
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 8
+      }
+    }
+  ],
+  'type' => 'document_root'
+};
+$result_trees{'chapter_before_top_epub'}{'contents'}[5]{'extra'}{'associated_part'}
 = $result_trees{'chapter_before_top_epub'}{'contents'}[4];
+
+$result_texis{'chapter_before_top_epub'} = '@node Top
+
+@node chapter
+@chapter chapter
+
+@part part
+
+@top top
+';
+
+
+$result_texts{'chapter_before_top_epub'} = '
+1 chapter
+*********
+
+part
+****
+
+top
+***
+';
+
+$result_sectioning{'chapter_before_top_epub'} = {
+  'extra' => {
+    'section_childs' => [
+      {
+        'cmdname' => 'chapter',
+        'extra' => {
+          'associated_node' => {
+            'cmdname' => 'node',
+            'extra' => {
+              'normalized' => 'chapter'
+            }
+          },
+          'section_level' => 1,
+          'section_number' => '1',
+          'sectioning_root' => {},
+          'toplevel_directions' => {}
+        }
+      },
+      {
+        'cmdname' => 'part',
+        'extra' => {
+          'part_associated_section' => {
+            'cmdname' => 'top',
+            'extra' => {
+              'associated_part' => {},
+              'section_directions' => {
+                'prev' => {}
+              },
+              'section_level' => 0,
+              'toplevel_directions' => {
+                'prev' => {}
+              }
+            }
+          },
+          'section_directions' => {},
+          'section_level' => 0
+        }
+      },
+      {}
+    ],
+    'section_level' => -1
+  }
+};
+$result_sectioning{'chapter_before_top_epub'}{'extra'}{'section_childs'}[0]{'extra'}{'sectioning_root'}
 = $result_sectioning{'chapter_before_top_epub'};
+$result_sectioning{'chapter_before_top_epub'}{'extra'}{'section_childs'}[1]{'extra'}{'part_associated_section'}{'extra'}{'associated_part'}
 = $result_sectioning{'chapter_before_top_epub'}{'extra'}{'section_childs'}[1];
+$result_sectioning{'chapter_before_top_epub'}{'extra'}{'section_childs'}[1]{'extra'}{'part_associated_section'}{'extra'}{'section_directions'}{'prev'}
 = $result_sectioning{'chapter_before_top_epub'}{'extra'}{'section_childs'}[1];
+$result_sectioning{'chapter_before_top_epub'}{'extra'}{'section_childs'}[1]{'extra'}{'part_associated_section'}{'extra'}{'toplevel_directions'}{'prev'}
 = $result_sectioning{'chapter_before_top_epub'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'chapter_before_top_epub'}{'extra'}{'section_childs'}[2] = 
$result_sectioning{'chapter_before_top_epub'}{'extra'}{'section_childs'}[1]{'extra'}{'part_associated_section'};
+
+$result_nodes{'chapter_before_top_epub'} = [
+  {
+    'cmdname' => 'node',
+    'extra' => {
+      'normalized' => 'Top'
+    }
+  },
+  {
+    'cmdname' => 'node',
+    'extra' => {
+      'associated_section' => {
+        'cmdname' => 'chapter',
+        'extra' => {
+          'section_number' => '1'
+        }
+      },
+      'normalized' => 'chapter'
+    }
+  }
+];
+
+$result_menus{'chapter_before_top_epub'} = [
+  {
+    'extra' => {
+      'normalized' => 'Top'
+    }
+  },
+  {
+    'extra' => {
+      'normalized' => 'chapter'
+    }
+  }
+];
+
+$result_errors{'chapter_before_top_epub'} = [
+  {
+    'error_line' => 'warning: @part should not be associated with @top
+',
+    'line_nr' => 6,
+    'text' => '@part should not be associated with @top',
+    'type' => 'warning'
+  }
+];
+
+
+$result_floats{'chapter_before_top_epub'} = {};
+
+
+1;
diff --git 
a/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/chapter_before_top_epub.opf
 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/chapter_before_top_epub.opf
new file mode 100644
index 0000000000..cf1152d435
--- /dev/null
+++ 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/chapter_before_top_epub.opf
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package xmlns="http://www.idpf.org/2007/opf"; version="3.0" 
unique-identifier="texi-uid">
+   <metadata xmlns:dc="http://purl.org/dc/elements/1.1/";>
+      <dc:identifier 
id="texi-uid">texinfo:chapter_before_top_epub</dc:identifier>
+      <dc:title>top</dc:title>
+      <dc:language>en</dc:language>
+   </metadata>
+   <manifest>
+      <item id="nav" properties="nav" media-type="application/xhtml+xml" 
href="xhtml/nav_toc.xhtml"/>
+      <item id="unit1" media-type="application/xhtml+xml" 
href="xhtml/chapter_before_top_epub.xhtml"/>
+      <item id="unit2" media-type="application/xhtml+xml" 
href="xhtml/top.xhtml"/>
+   </manifest>
+   <spine>
+      <itemref idref="unit1"/>
+      <itemref idref="unit2"/>
+   </spine>
+</package>
diff --git 
a/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/xhtml/chapter_before_top_epub.xhtml
 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/xhtml/chapter_before_top_epub.xhtml
new file mode 100644
index 0000000000..c0a1c57645
--- /dev/null
+++ 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/xhtml/chapter_before_top_epub.xhtml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+<title>1 chapter (top)</title>
+
+<meta name="description" content="1 chapter (top)"/>
+<meta name="keywords" content="1 chapter (top)"/>
+<meta name="resource-type" content="document"/>
+<meta name="distribution" content="global"/>
+<meta name="viewport" content="width=device-width,initial-scale=1"/>
+
+<link href="top.xhtml" rel="start" title="top"/>
+
+
+</head>
+
+<body lang="en">
+<a class="node" id="Top"></a>
+<div class="chapter-level-extent" id="chapter">
+<h2 class="chapter" id="chapter-1">1 chapter</h2>
+
+</div>
+
+
+
+</body>
+</html>
diff --git 
a/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/xhtml/nav_toc.xhtml
 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/xhtml/nav_toc.xhtml
new file mode 100644
index 0000000000..e7da2f21b4
--- /dev/null
+++ 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/xhtml/nav_toc.xhtml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml"; 
xmlns:epub="http://www.idpf.org/2007/ops";>
+<head>
+<meta charset="utf-8" />
+<title>top - Table of contents</title>
+</head>
+<body>
+<nav epub:type="toc" id="nav">
+<h1>Table of contents</h1>
+
+<ol>
+ <li><a href="chapter_before_top_epub.xhtml">1 chapter</a></li>
+ <li><a href="top.xhtml">top</a></li>
+</ol>
+</nav>
+</body>
+</html>
diff --git 
a/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/xhtml/top.xhtml
 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/xhtml/top.xhtml
new file mode 100644
index 0000000000..ab2d96eefa
--- /dev/null
+++ 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/EPUB/xhtml/top.xhtml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+<title>top</title>
+
+<meta name="description" content="top"/>
+<meta name="keywords" content="top"/>
+<meta name="resource-type" content="document"/>
+<meta name="distribution" content="global"/>
+<meta name="viewport" content="width=device-width,initial-scale=1"/>
+
+<link href="#top" rel="start" title="top"/>
+
+
+</head>
+
+<body lang="en">
+<div class="part-level-extent" id="part">
+<h1 class="part">part</h1>
+
+</div>
+<div class="top-level-extent" id="top">
+<h1 class="top">top</h1>
+</div>
+
+
+
+</body>
+</html>
diff --git 
a/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/META-INF/container.xml
 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/META-INF/container.xml
new file mode 100644
index 0000000000..804e37d201
--- /dev/null
+++ 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/META-INF/container.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<container version="1.0" 
xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
+    <rootfiles>
+        <rootfile full-path="EPUB/chapter_before_top_epub.opf"
+            media-type="application/oebps-package+xml" />      
+    </rootfiles>
+</container>
diff --git 
a/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/mimetype
 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/mimetype
new file mode 100644
index 0000000000..57ef03f24a
--- /dev/null
+++ 
b/tp/t/results/html_tests/chapter_before_top_epub/res_html/chapter_before_top_epub_epub_package/mimetype
@@ -0,0 +1 @@
+application/epub+zip
\ No newline at end of file



reply via email to

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