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 gap in sectioning.
Date: Sat, 07 Sep 2024 18:18:56 -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 0c64d28248 * tp/ext/epub3.pm (epub_finish): fix nav file formatting 
with gap in sectioning.
0c64d28248 is described below

commit 0c64d28248fe3bc67f85a5e68c78f5baae6d5478
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Sep 8 00:17:20 2024 +0200

    * tp/ext/epub3.pm (epub_finish): fix nav file formatting with gap
    in sectioning.
    
    * tp/Makefile.tres, tp/t/html_tests.t (section_part_epub): add a test
    of epub, with @part and starting at @section, leading to a gap in
    sectioning.
---
 ChangeLog                                          |   9 +
 tp/Makefile.tres                                   |   2 +
 tp/ext/epub3.pm                                    |  17 +-
 tp/t/html_tests.t                                  |   7 +
 tp/t/results/html_tests/section_part_epub.pl       | 216 +++++++++++++++++++++
 .../EPUB/section_part_epub.opf                     |  17 ++
 .../EPUB/xhtml/nav_toc.xhtml                       |  20 ++
 .../EPUB/xhtml/part.xhtml                          |  29 +++
 .../EPUB/xhtml/section_part_epub.xhtml             |  25 +++
 .../META-INF/container.xml                         |   7 +
 .../section_part_epub_epub_package/mimetype        |   1 +
 11 files changed, 345 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3ad457c7dc..3ad9813392 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,15 @@
 
        * NEWS: add 7.1.1 release notice
 
+2024-09-07  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/ext/epub3.pm (epub_finish): fix nav file formatting with gap
+       in sectioning.
+
+       * tp/Makefile.tres, tp/t/html_tests.t (section_part_epub): add a test
+       of epub, with @part and starting at @section, leading to a gap in
+       sectioning.
+
 2024-09-07  Patrice Dumas  <pertusus@free.fr>
 
        * tp/ext/epub3.pm (epub_finish): fix nav file formatting with a
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index e713437b34..a37aa52f69 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -737,6 +737,8 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/html_tests/redirection_same_labels.pl \
   t/results/html_tests/redirection_same_labels/res_html \
   t/results/html_tests/ref_in_preformatted.pl \
+  t/results/html_tests/section_part_epub.pl \
+  t/results/html_tests/section_part_epub/res_html \
   t/results/html_tests/sectioning_check_menu_structure.pl \
   t/results/html_tests/sectioning_check_menu_structure/res_html \
   t/results/html_tests/set_unit_file_name_filepath.pl \
diff --git a/tp/ext/epub3.pm b/tp/ext/epub3.pm
index 6ce8d2ba70..b9c7ecd152 100644
--- a/tp/ext/epub3.pm
+++ b/tp/ext/epub3.pm
@@ -736,11 +736,18 @@ EOT
       next if ($section->{'cmdname'} eq 'part');
       my $section_level = $section->{'extra'}->{'section_level'};
       $section_level = 1 if ($section_level == 0);
-      # FIXME with gaps in sectioning there could be nesting issues?
       if ($level < $section_level) {
+        print $nav_fh "\n". " " x $level . "<ol>\n";
+        $level++;
         while ($level < $section_level) {
-          my $leading_spaces = '';
-          print $nav_fh "\n". " " x $level . "<ol>\n";
+          # case of gap in sectioning.  The Navigation document requirements
+          # in EPUB mandates a span (or a) after a <li>, and mandates that
+          # it is not empty.  We use a "0" for this text for a lack of
+          # anything better.
+          # There should be a warning/error emitted by texi2any for such a
+          # sectioning structure.
+          print $nav_fh " " x $level . "<li><span>0</span>\n"
+                             . " " x $level . "<ol>\n";
           $level++;
         }
       } elsif ($level > $section_level) {
@@ -748,7 +755,7 @@ EOT
         print $nav_fh "</li>\n". " " x ($level -1) . "</ol>\n";
         $level--;
         while ($level > $section_level) {
-          print $nav_fh " " x $level . "</li>\n". " " x ($level -1) . 
"</ol>\n";
+          print $nav_fh " " x $level . "</li>\n"." " x ($level -1) . "</ol>\n";
           $level--;
         }
         print $nav_fh " " x $level ."</li>\n";
@@ -770,7 +777,7 @@ EOT
       $level--;
     }
     while ($level > $root_level) {
-      print $nav_fh " " x $level . "</li>\n". " " x ($level -1) . "</ol>\n";
+      print $nav_fh " " x $level . "</li>\n"." " x ($level -1) . "</ol>\n";
       $level--;
     }
 
diff --git a/tp/t/html_tests.t b/tp/t/html_tests.t
index 88d103fef6..bb68503ecc 100644
--- a/tp/t/html_tests.t
+++ b/tp/t/html_tests.t
@@ -1552,6 +1552,13 @@ undef, {'test_file' => 
'simple_only_special_spaces_node.texi',
 @part part
 
 @top top
+', {'init_files' => ['epub3.pm']},
+   {'EPUB_CREATE_CONTAINER_FILE' => 0}],
+['section_part_epub',
+'@node Top
+@section section
+
+@part part
 ', {'init_files' => ['epub3.pm']},
    {'EPUB_CREATE_CONTAINER_FILE' => 0}],
 );
diff --git a/tp/t/results/html_tests/section_part_epub.pl 
b/tp/t/results/html_tests/section_part_epub.pl
new file mode 100644
index 0000000000..b21a40911f
--- /dev/null
+++ b/tp/t/results/html_tests/section_part_epub.pl
@@ -0,0 +1,216 @@
+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{'section_part_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',
+      'extra' => {
+        'is_target' => 1,
+        'normalized' => 'Top'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 1
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'section'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'section',
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        }
+      ],
+      'extra' => {
+        'section_number' => '1'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 2
+      }
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'part'
+            }
+          ],
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'part',
+      'extra' => {},
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 4
+      }
+    }
+  ],
+  'type' => 'document_root'
+};
+
+$result_texis{'section_part_epub'} = '@node Top
+@section section
+
+@part part
+';
+
+
+$result_texts{'section_part_epub'} = '1 section
+=========
+
+part
+****
+';
+
+$result_sectioning{'section_part_epub'} = {
+  'extra' => {
+    'section_childs' => [
+      {
+        'cmdname' => 'section',
+        'extra' => {
+          'associated_node' => {
+            'cmdname' => 'node',
+            'extra' => {
+              'normalized' => 'Top'
+            }
+          },
+          'section_level' => 2,
+          'section_number' => '1',
+          'sectioning_root' => {}
+        }
+      },
+      {
+        'cmdname' => 'part',
+        'extra' => {
+          'section_level' => 0
+        }
+      }
+    ],
+    'section_level' => -1
+  }
+};
+$result_sectioning{'section_part_epub'}{'extra'}{'section_childs'}[0]{'extra'}{'sectioning_root'}
 = $result_sectioning{'section_part_epub'};
+
+$result_nodes{'section_part_epub'} = [
+  {
+    'cmdname' => 'node',
+    'extra' => {
+      'associated_section' => {
+        'cmdname' => 'section',
+        'extra' => {
+          'section_number' => '1'
+        }
+      },
+      'normalized' => 'Top'
+    }
+  }
+];
+
+$result_menus{'section_part_epub'} = [
+  {
+    'extra' => {
+      'normalized' => 'Top'
+    }
+  }
+];
+
+$result_errors{'section_part_epub'} = [
+  {
+    'error_line' => 'warning: no chapter-level command before @part
+',
+    'line_nr' => 4,
+    'text' => 'no chapter-level command before @part',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: no sectioning command associated with @part
+',
+    'line_nr' => 4,
+    'text' => 'no sectioning command associated with @part',
+    'type' => 'warning'
+  }
+];
+
+
+$result_floats{'section_part_epub'} = {};
+
+
+$result_converted_errors{'file_html'}->{'section_part_epub'} = [
+  {
+    'error_line' => 'warning: must specify a title with a title command or @top
+',
+    'file_name' => 'section_part_epub.texi',
+    'text' => 'must specify a title with a title command or @top',
+    'type' => 'warning'
+  }
+];
+
+
+1;
diff --git 
a/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/section_part_epub.opf
 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/section_part_epub.opf
new file mode 100644
index 0000000000..1589605c92
--- /dev/null
+++ 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/section_part_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:section_part_epub</dc:identifier>
+      <dc:title>Untitled Document</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/section_part_epub.xhtml"/>
+      <item id="unit2" media-type="application/xhtml+xml" 
href="xhtml/part.xhtml"/>
+   </manifest>
+   <spine>
+      <itemref idref="unit1"/>
+      <itemref idref="unit2"/>
+   </spine>
+</package>
diff --git 
a/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/xhtml/nav_toc.xhtml
 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/xhtml/nav_toc.xhtml
new file mode 100644
index 0000000000..b3a87b2107
--- /dev/null
+++ 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/xhtml/nav_toc.xhtml
@@ -0,0 +1,20 @@
+<?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>Untitled Document - Table of contents</title>
+</head>
+<body>
+<nav epub:type="toc" id="nav">
+<h1>Table of contents</h1>
+
+<ol>
+ <li><span>0</span>
+ <ol>
+  <li><a href="section_part_epub.xhtml">1 section</a></li>
+ </ol>
+ </li>
+</ol>
+</nav>
+</body>
+</html>
diff --git 
a/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/xhtml/part.xhtml
 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/xhtml/part.xhtml
new file mode 100644
index 0000000000..c3a2e287ae
--- /dev/null
+++ 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/xhtml/part.xhtml
@@ -0,0 +1,29 @@
+<?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>part (Untitled Document)</title>
+
+<meta name="description" content="part (Untitled Document)"/>
+<meta name="keywords" content="part (Untitled Document)"/>
+<meta name="resource-type" content="document"/>
+<meta name="distribution" content="global"/>
+<meta name="viewport" content="width=device-width,initial-scale=1"/>
+
+<link href="section_part_epub.xhtml" rel="start" title="1 section"/>
+
+
+</head>
+
+<body lang="en">
+<div class="part-level-extent" id="part">
+
+<h1 class="part">part</h1>
+</div>
+
+
+
+</body>
+</html>
diff --git 
a/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/xhtml/section_part_epub.xhtml
 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/xhtml/section_part_epub.xhtml
new file mode 100644
index 0000000000..5ce31a43cf
--- /dev/null
+++ 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/EPUB/xhtml/section_part_epub.xhtml
@@ -0,0 +1,25 @@
+<?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 section (Untitled Document)</title>
+
+<meta name="description" content="1 section (Untitled Document)"/>
+<meta name="keywords" content="1 section (Untitled Document)"/>
+<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="1 section"/>
+
+
+</head>
+
+<body lang="en">
+<a class="node" id="Top"></a><a class="section" id="section"></a>
+
+
+</body>
+</html>
diff --git 
a/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/META-INF/container.xml
 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/META-INF/container.xml
new file mode 100644
index 0000000000..1ca83bda10
--- /dev/null
+++ 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_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/section_part_epub.opf"
+            media-type="application/oebps-package+xml" />      
+    </rootfiles>
+</container>
diff --git 
a/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/mimetype
 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_epub_epub_package/mimetype
new file mode 100644
index 0000000000..57ef03f24a
--- /dev/null
+++ 
b/tp/t/results/html_tests/section_part_epub/res_html/section_part_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]