texlive[62076] trunk: tex4ebook (18feb22)

commits+karl at tug.org commits+karl at tug.org
Fri Feb 18 23:12:39 CET 2022


Revision: 62076
          http://tug.org/svn/texlive?view=revision&revision=62076
Author:   karl
Date:     2022-02-18 23:12:39 +0100 (Fri, 18 Feb 2022)
Log Message:
-----------
tex4ebook (18feb22)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook
    trunk/Master/texmf-dist/doc/support/tex4ebook/changelog.tex
    trunk/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf
    trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook
    trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua
    trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht
    trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht

Modified: trunk/Build/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook	2022-02-18 22:12:02 UTC (rev 62075)
+++ trunk/Build/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook	2022-02-18 22:12:39 UTC (rev 62076)
@@ -67,7 +67,7 @@
 end
 
 if args.version then
-  print "tex4ebook v0.3g"
+  print "tex4ebook v0.3h"
   return 
 end
 

Modified: trunk/Master/texmf-dist/doc/support/tex4ebook/changelog.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/tex4ebook/changelog.tex	2022-02-18 22:12:02 UTC (rev 62075)
+++ trunk/Master/texmf-dist/doc/support/tex4ebook/changelog.tex	2022-02-18 22:12:39 UTC (rev 62076)
@@ -3,6 +3,43 @@
 
 \begin{itemize}
 \item
+  2022/02/18
+
+  \begin{itemize}
+  \tightlist
+  \item
+    released version \texttt{0.3h}.
+  \end{itemize}
+\item
+  2022/01/13
+
+  \begin{itemize}
+  \tightlist
+  \item
+    fixed issue where child TOC elements were inserted into
+    \texttt{\textless{}a\textgreater{}} element.
+  \end{itemize}
+\item
+  2021/12/07
+
+  \begin{itemize}
+  \tightlist
+  \item
+    print space after section number in Epub 3 TOC.
+  \item
+    keep original elements in Epub 3 TOC.
+  \end{itemize}
+\item
+  2021/12/04
+
+  \begin{itemize}
+  \tightlist
+  \item
+    fixed support for
+    \href{https://github.com/michal-h21/tex4ebook/issues/85}{appendix
+    chapters in Epub 3}.
+  \end{itemize}
+\item
   2021/11/08
 
   \begin{itemize}

Modified: trunk/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook
===================================================================
--- trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook	2022-02-18 22:12:02 UTC (rev 62075)
+++ trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook	2022-02-18 22:12:39 UTC (rev 62076)
@@ -67,7 +67,7 @@
 end
 
 if args.version then
-  print "tex4ebook v0.3g"
+  print "tex4ebook v0.3h"
   return 
 end
 

Modified: trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua	2022-02-18 22:12:02 UTC (rev 62075)
+++ trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua	2022-02-18 22:12:39 UTC (rev 62076)
@@ -113,6 +113,12 @@
 end
 
 
+-- elements that shouldn't be put inside <a> in TOC
+local stop_toc_processing_elements = {
+  ol = true,
+  ul = true
+}
+
 local function remove_spurious_TOC_elements(tocdom)
   local function count_child_elements(el)
     -- count children elements of the current element
@@ -127,36 +133,44 @@
   for _, el in ipairs(tocdom:query_selector("ol")) do
     if count_child_elements(el) == 0 then 
       el:remove_node()
-      -- local newli = el:create_element("li")
-      -- local newspan = newli:create_element("span")
-      -- newli:add_child_node(newspan)
-      -- el:add_child_node(newli)
     end
   end
   -- place child elements of the <li> elements to an <a> element, epubcheck reports 
   -- error for text nodes that are direct child of <li>
   for _, el in ipairs(tocdom:query_selector("li")) do
-    local text = {}
-    local link  -- save the <a> element
+
+    local newa = el:create_element("a")
+    local newchildren = {newa}
+    -- we want to stop putting content as child of <a> when it 
+    -- finds child TOC entries
+    local keep_processing = true
     for i, child in ipairs(el._children) do
-      if child:is_text()  then 
-        -- trim spurious spaces
-        local childtext = child._text:gsub("^%s*",""):gsub("%s*$","")
-        -- save the text for the later use
-        table.insert(text, childtext)
-        child:remove_node()
-      elseif child:is_element() and child:get_element_name() == "a"  then
-        link = child
-        table.insert(text, child:get_text())
+      child_name = child:get_element_name()
+      -- put contents of <li> to a new <a> element
+      if child:is_element() and child_name == "a"  then
+        -- set id and href of the new <a> element, if it isn't set already
+        if not newa:get_attribute("href") then
+          local id   = child:get_attribute("id") 
+          local href = child:get_attribute("href")
+          newa:set_attribute("id", id)
+          newa:set_attribute("href", href)
+        end
+        -- copy <a> contents to the new <a> element
+        for _, x in ipairs(child._children or {}) do newa:add_child_node(x:copy_node()) end
+
+      elseif stop_toc_processing_elements[child_name] then
+        -- don't put child toc entries to the new <a>
+        keep_processing = false
+        newchildren[#newchildren+1] = child
+      elseif keep_processing == true then
+        -- put every node before <ol> or <ul> into the new <a>
+        newa:add_child_node(child:copy_node())
+      else
+        newchildren[#newchildren+1] = child
       end
     end
-    if link then
-      local content = table.concat(text, " ")
-      -- remove the original text
-      link._children = {}
-      local text = link:create_text_node(content)
-      link:add_child_node(text)
-    end
+    -- set contents of <li> to be the new <a>
+    el._children = newchildren
   end
   return tocdom
 

Modified: trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht	2022-02-18 22:12:02 UTC (rev 62075)
+++ trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht	2022-02-18 22:12:39 UTC (rev 62076)
@@ -13,9 +13,10 @@
 %%%%%%%%%%%%%%%%%%%%%%%
 \Configure{tableofcontents}{
   \a:NavMap
-  \resettoclevels{part,chapter,section,subsection,subsubsection}
-  \navsection{part}{part,chapter,section,subsection,subsubsection}
-  \navsection{chapter}{chapter,section,subsection,subsubsection}
+  \resettoclevels{part,appendix,chapter,section,subsection,subsubsection}
+  \navsection{part}{part,appendix,chapter,section,subsection,subsubsection}
+  \navsection{appendix}{appendix,chapter,section,subsection,subsubsection}
+  \navsection{chapter}{appendix,chapter,section,subsection,subsubsection}
   \navsection{section}{section,subsection,subsubsection}
   \navsection{subsection}{subsection,subsubsection}
   \navsection{subsubsection}{subsubsection}
@@ -26,13 +27,13 @@
 \Configure{NavMap}{\ifvmode\IgnorePar\fi\EndP\boolfalse{tocnoempty}\HCode{<nav id="toc" epub:type="toc">\Hnewline<ol>}%
 \opf:registerfilename{\FileName}
 \opf:add:property{nav}
-}{\usetoclevels{part,chapter,section,subsection,subsubsection}%
+}{\usetoclevels{part,appendix,chapter,section,subsection,subsubsection}%
 	\ifbool{tocnoempty}{}{\HCode{<li><a href="\jobname.\:html">Document</a></li>}}
 	\HCode{</ol></nav>}}
 %%%%%%%%%%%
 \Configure{NavSection}{%
 	\booltrue{tocnoempty}
-	\HCode{<li>}}{\HCode{<ol>\Hnewline}}{}{\Tg</ol>\Tg</li>}
+	\HCode{<li>}}{\HCode{<ol>\Hnewline}}{\ }{\Tg</ol>\Tg</li>}
 % Disable numbering of the TOC by the reading system, numbers are added by tex4ht
 \Css{nav\#toc ol{list-style: none;}}
 %%%% End toc nav configuration

Modified: trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht	2022-02-18 22:12:02 UTC (rev 62075)
+++ trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht	2022-02-18 22:12:39 UTC (rev 62076)
@@ -342,7 +342,7 @@
 
 % define toc levels which should be included in the NCX file
 \NewConfigure{resettoclevels}{1}
-\Configure{resettoclevels}{part,chapter,section,subsection,subsubsection,paragraph}
+\Configure{resettoclevels}{part,appendix,chapter,section,subsection,subsubsection,paragraph}
 
 \def\:tempa{%
 \EndP%



More information about the tex-live-commits mailing list.