texlive[66332] trunk: tex4ebook (3mar23)
commits+karl at tug.org
commits+karl at tug.org
Fri Mar 3 22:32:10 CET 2023
Revision: 66332
http://tug.org/svn/texlive?view=revision&revision=66332
Author: karl
Date: 2023-03-03 22:32:09 +0100 (Fri, 03 Mar 2023)
Log Message:
-----------
tex4ebook (3mar23)
Modified Paths:
--------------
trunk/Build/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook
trunk/Master/texmf-dist/doc/support/tex4ebook/README
trunk/Master/texmf-dist/doc/support/tex4ebook/changelog.tex
trunk/Master/texmf-dist/doc/support/tex4ebook/readme.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_epub.lua
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 2023-03-03 21:31:54 UTC (rev 66331)
+++ trunk/Build/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook 2023-03-03 21:32:09 UTC (rev 66332)
@@ -43,7 +43,7 @@
-j,--jobname (default nil) Set the jobname
-l,--lua Use lualatex for document compilation
-m,--mode (default default) Switch which can be used in the makefile
- -r,--resolution (default 167)
+ -r,--resolution (default nil) This option is obsolete, use build files instead!
-s,--shell-escape Enable shell escape in htlatex run
-t,--tidy Run html tidy on html output. May result in wrong spacing!
-x,--xetex Use xelatex for document compilation
@@ -67,7 +67,7 @@
end
if args.version then
- print "tex4ebook v0.3h"
+ print "tex4ebook v0.3i"
return
end
@@ -150,6 +150,11 @@
,packages="\\RequirePackage{tex4ebook}"
}
+if oldparams.resolution~="nil" then
+ log:warning("The resolution parameter is deprecated. Please use a build file")
+ log:warning("See information about Make:image() command in Make4ht documenation")
+end
+
-- extend params
for k,v in pairs(oldparams) do
params[k] = v
Modified: trunk/Master/texmf-dist/doc/support/tex4ebook/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/tex4ebook/README 2023-03-03 21:31:54 UTC (rev 66331)
+++ trunk/Master/texmf-dist/doc/support/tex4ebook/README 2023-03-03 21:32:09 UTC (rev 66332)
@@ -107,11 +107,6 @@
values are `default` and `draft`. In `draft` mode, document is compiled
only once, instead of three times.
-`-r,--resolution`
-
-: Resolution of generated images, for example math. It should meet resolution
- of target devices, which is usually about 167 ppi.
-
`-s,--shell-escape`
: Enable shell escape in the `htlatex` run. This is necessary for the execution of the external
@@ -119,7 +114,7 @@
`-t,--tidy`
-: process output html files with `HTML tidy` command^[It needs to be installed separately].
+: clean-up output HTML files using the `HTML tidy` command^[if it is available on your system].
`-x,--xetex`
@@ -256,9 +251,27 @@
equivalent HTML code needs to be inserted. `UTF8` is not recognized at that place.
- `UTF8` characters may be used in the `OpfMetadata` sections.
+## \TeX4ht options
+\TeX4ht supports lot of options, that change produced HTML code without need to
+use configurations. Their list is available in the [\TeX4ht
+documentation](https://www.kodymirus.cz/tex4ht-doc/texfourhtOptions.html).
+You can pass options to `tex4ebook` in the argument that follows filename:
+ tex4ebook filename.tex "option1,option2"
+Alternatively, they can be put in the `\Preamble` command in the config file:
+
+ \Preamble{xhtml,option1,option2}
+
+### Options provided by `tex4ebook`
+
+`no-cut`
+
+: By default `tex4ebook` splits document to separate HTML pages on `\chapter` command when it is available.
+ Othervise, it splits on `\section`. This can be changed using the `\CutAt` command or numeric options, but
+ you need to use the `no-cut` option to prevent fatal error.
+
## Commands available in the config file
`\OpfRegisterFile[filename]`
@@ -279,13 +292,42 @@
## Build files
`tex4ebook` uses `make4ht`^[https://github.com/michal-h21/make4ht] as a build
-system. See `make4ht` documentation for details on build files.
+system. It provides support for build files written in Lua. These build files
+can be used to call additional commands, like Bib\TeX\ or Makeindex, post-process
+generated HTML files, change the way how images are created, or to modify
+parameters of the conversion.
+Sample build file can look like this:
+
+ if mode=="draft" then
+ Make:htlatex {}
+ else
+ Make:htlatex {}
+ Make:htlatex {}
+ Make:htlatex {}
+ end
+
+ Make:image("png$",
+ "dvipng -bg Transparent -T tight -o ${output} -D 170 -pp ${page} ${source}")
+
+The `mode` variable holds value of the `--mode` argument to `tex4ebook`. The `draft`
+mode is used for faster compilation, it calls LaTeX only once.
+
+The `Make:image` function can configure handling of images created by extraction from the
+DVI file. It can be complex math, TikZ or PSTricks pictures, and so on. The `${<name>}`
+placeholders are filled by `tex4ebook` with parameters like current page number of
+the image DVI file, or output image name.
+
+You can compile your document with a build file using the `-e` option:
+
+ tex4ebook -m draft -e build.lua filename.tex
+
+See `make4ht` documentation for more details on configuration files.
+
## `.tex4ebook` configuration file
-It is possible to globally modify the build settings using the configuration
-file. New compilation commands can be added, extensions can be loaded or
-disabled and settings can be set.
+`tex4ebook` supports a default build file, which is loaded automatically
+without need to use the `-e` option.
### Location
Modified: trunk/Master/texmf-dist/doc/support/tex4ebook/changelog.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/tex4ebook/changelog.tex 2023-03-03 21:31:54 UTC (rev 66331)
+++ trunk/Master/texmf-dist/doc/support/tex4ebook/changelog.tex 2023-03-03 21:32:09 UTC (rev 66332)
@@ -3,6 +3,95 @@
\begin{itemize}
\item
+ 2023/03/02
+
+ \begin{itemize}
+ \tightlist
+ \item
+ released verision \texttt{0.3i}
+ \item
+ check if file with TOC exists before processing.
+ \end{itemize}
+\item
+ 2023/01/12
+
+ \begin{itemize}
+ \tightlist
+ \item
+ added all mimetypes supported in Epub.
+ \end{itemize}
+\item
+ 2023/01/09
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed handling of metadata for filenames with accented characters.
+ \end{itemize}
+\item
+ 2022/12/15
+
+ \begin{itemize}
+ \tightlist
+ \item
+ use lower case file extensions for mimetype matching.
+ \end{itemize}
+\item
+ 2022/12/01
+
+ \begin{itemize}
+ \tightlist
+ \item
+ set destinations for \texttt{\textbackslash{}label} used inside of
+ footnotes.
+ \item
+ fixed handling of multiple tables of contents in Epub 3.
+ \end{itemize}
+\item
+ 2022/11/20
+
+ \begin{itemize}
+ \tightlist
+ \item
+ added support for the \texttt{fn-in} option in the Epub 3 output.
+ \end{itemize}
+\item
+ 2022/03/29
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed support for \TeX~filenames that contain dot.
+ \item
+ removed spurious comma that was introduced earlier.
+ \end{itemize}
+\item
+ 2022/03/28
+
+ \begin{itemize}
+ \tightlist
+ \item
+ documented the \texttt{no-cut} option.
+ \end{itemize}
+\item
+ 2022/02/23
+
+ \begin{itemize}
+ \tightlist
+ \item
+ extended the documentation about build files.
+ \item
+ deprecated the \texttt{-\/-resolution} CLI argument.
+ \end{itemize}
+\item
+ 2022/02/22
+
+ \begin{itemize}
+ \tightlist
+ \item
+ print \texttt{\textbackslash{}subsubsection} in the Epub TOC.
+ \end{itemize}
+\item
2022/02/18
\begin{itemize}
Modified: trunk/Master/texmf-dist/doc/support/tex4ebook/readme.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/tex4ebook/readme.tex 2023-03-03 21:31:54 UTC (rev 66331)
+++ trunk/Master/texmf-dist/doc/support/tex4ebook/readme.tex 2023-03-03 21:32:09 UTC (rev 66332)
@@ -115,15 +115,12 @@
supported values are \texttt{default} and \texttt{draft}. In
\texttt{draft} mode, document is compiled only once, instead of three
times.
-\item[\texttt{-r,-\/-resolution}]
-Resolution of generated images, for example math. It should meet
-resolution of target devices, which is usually about 167 ppi.
\item[\texttt{-s,-\/-shell-escape}]
Enable shell escape in the \texttt{htlatex} run. This is necessary for
the execution of the external commands from your source files.
\item[\texttt{-t,-\/-tidy}]
-process output html files with \texttt{HTML\ tidy} command\footnote{It
- needs to be installed separately}.
+clean-up output HTML files using the \texttt{HTML\ tidy}
+command\footnote{if it is available on your system}.
\item[\texttt{-x,-\/-xetex}]
Use xelatex for document compilation
\item[\texttt{-v,-\/-version}]
@@ -304,6 +301,41 @@
sections.
\end{itemize}
+\hypertarget{ht-options}{%
+\subsection{\texorpdfstring{\TeX4ht
+options}{4ht options}}\label{ht-options}}
+
+\TeX4ht supports lot of options, that change produced HTML code without
+need to use configurations. Their list is available in the
+\href{https://www.kodymirus.cz/tex4ht-doc/texfourhtOptions.html}{\TeX4ht
+documentation}. You can pass options to \texttt{tex4ebook} in the
+argument that follows filename:
+
+\begin{verbatim}
+tex4ebook filename.tex "option1,option2"
+\end{verbatim}
+
+Alternatively, they can be put in the \texttt{\textbackslash{}Preamble}
+command in the config file:
+
+\begin{verbatim}
+\Preamble{xhtml,option1,option2}
+\end{verbatim}
+
+\hypertarget{options-provided-by-tex4ebook}{%
+\subsubsection{\texorpdfstring{Options provided by
+\texttt{tex4ebook}}{Options provided by tex4ebook}}\label{options-provided-by-tex4ebook}}
+
+\begin{description}
+\item[\texttt{no-cut}]
+By default \texttt{tex4ebook} splits document to separate HTML pages on
+\texttt{\textbackslash{}chapter} command when it is available.
+Othervise, it splits on \texttt{\textbackslash{}section}. This can be
+changed using the \texttt{\textbackslash{}CutAt} command or numeric
+options, but you need to use the \texttt{no-cut} option to prevent fatal
+error.
+\end{description}
+
\hypertarget{commands-available-in-the-config-file}{%
\subsection{Commands available in the config
file}\label{commands-available-in-the-config-file}}
@@ -328,16 +360,53 @@
\subsection{Build files}\label{build-files}}
\texttt{tex4ebook} uses \texttt{make4ht}\footnote{\url{https://github.com/michal-h21/make4ht}}
-as a build system. See \texttt{make4ht} documentation for details on
-build files.
+as a build system. It provides support for build files written in Lua.
+These build files can be used to call additional commands, like
+Bib\TeX~or Makeindex, post-process generated HTML files, change the way
+how images are created, or to modify parameters of the conversion.
+Sample build file can look like this:
+
+\begin{verbatim}
+if mode=="draft" then
+ Make:htlatex {}
+else
+ Make:htlatex {}
+ Make:htlatex {}
+ Make:htlatex {}
+end
+
+Make:image("png$",
+"dvipng -bg Transparent -T tight -o ${output} -D 170 -pp ${page} ${source}")
+\end{verbatim}
+
+The \texttt{mode} variable holds value of the \texttt{-\/-mode} argument
+to \texttt{tex4ebook}. The \texttt{draft} mode is used for faster
+compilation, it calls LaTeX only once.
+
+The \texttt{Make:image} function can configure handling of images
+created by extraction from the DVI file. It can be complex math, TikZ or
+PSTricks pictures, and so on. The
+\texttt{\$\{\textless{}name\textgreater{}\}} placeholders are filled by
+\texttt{tex4ebook} with parameters like current page number of the image
+DVI file, or output image name.
+
+You can compile your document with a build file using the \texttt{-e}
+option:
+
+\begin{verbatim}
+tex4ebook -m draft -e build.lua filename.tex
+\end{verbatim}
+
+See \texttt{make4ht} documentation for more details on configuration
+files.
+
\hypertarget{tex4ebook-configuration-file}{%
\subsection{\texorpdfstring{\texttt{.tex4ebook} configuration
file}{.tex4ebook configuration file}}\label{tex4ebook-configuration-file}}
-It is possible to globally modify the build settings using the
-configuration file. New compilation commands can be added, extensions
-can be loaded or disabled and settings can be set.
+\texttt{tex4ebook} supports a default build file, which is loaded
+automatically without need to use the \texttt{-e} option.
\hypertarget{location}{%
\subsubsection{Location}\label{location}}
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 2023-03-03 21:31:54 UTC (rev 66331)
+++ trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook 2023-03-03 21:32:09 UTC (rev 66332)
@@ -43,7 +43,7 @@
-j,--jobname (default nil) Set the jobname
-l,--lua Use lualatex for document compilation
-m,--mode (default default) Switch which can be used in the makefile
- -r,--resolution (default 167)
+ -r,--resolution (default nil) This option is obsolete, use build files instead!
-s,--shell-escape Enable shell escape in htlatex run
-t,--tidy Run html tidy on html output. May result in wrong spacing!
-x,--xetex Use xelatex for document compilation
@@ -67,7 +67,7 @@
end
if args.version then
- print "tex4ebook v0.3h"
+ print "tex4ebook v0.3i"
return
end
@@ -150,6 +150,11 @@
,packages="\\RequirePackage{tex4ebook}"
}
+if oldparams.resolution~="nil" then
+ log:warning("The resolution parameter is deprecated. Please use a build file")
+ log:warning("See information about Make:image() command in Make4ht documenation")
+end
+
-- extend params
for k,v in pairs(oldparams) do
params[k] = v
Modified: trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub.lua 2023-03-03 21:31:54 UTC (rev 66331)
+++ trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub.lua 2023-03-03 21:32:09 UTC (rev 66332)
@@ -127,17 +127,23 @@
css = "text/css",
png = "image/png",
jpg = "image/jpeg",
+ jpeg = "image/jpeg",
gif = "image/gif",
svg = "image/svg+xml",
html= "application/xhtml+xml",
xhtml= "application/xhtml+xml",
ncx = "application/x-dtbncx+xml",
- otf = "application/opentype",
- ttf = "application/truetype",
+ otf = "application/font-sfnt",
+ ttf = "application/font-sfnt",
woff = "application/font-woff",
+ woff2 = "font/woff2",
js = "text/javascript",
mp3 = "audio/mpeg",
- smil = "application/smil+xml"
+ mp4 = "audio/mp4",
+ avi = "video/x-msvideo",
+ mkv = "video/x-matroska",
+ smil = "application/smil+xml",
+ pls = "application/pls+xml"
}
function remove_empty_guide(content)
@@ -144,14 +150,18 @@
return content:gsub("<guide>%s*</guide>","")
end
+
+
function make_opf()
-- Join files content.opf and content-part2.opf
-- make item record for every converted image
local lg_item = function(item)
-- Find mimetype and make item tag for each converted file in the lg file
- local fname,ext = item:match("([%a%d%_%-]*)%p([%a%d]*)$")
- local mimetype = mimetypes[ext] or ""
- if mimetype == "" then log:info("Mimetype for "..ext.." is not registered"); return nil end
+ local fname,ext = item:match("([^%/^%.]*)%.([%a%d]*)$")
+ if not ext then return nil end
+ local lower_ext = string.lower(ext)
+ local mimetype = mimetypes[lower_ext] or ""
+ if mimetype == "" then log:info("Mimetype for the "..ext.." extension is not registered"); return nil end
local dir_part = item:split("/")
table.remove(dir_part,#dir_part)
local id=table.concat(dir_part,"-")..fname.."_"..ext
@@ -158,18 +168,22 @@
-- remove invalid characters from id start
id = id:gsub("^[%.%-]*","")
-- remove colons
- id = id:gsub(":", "_")
+ id = id:gsub("[:%(%)]", "_")
-- id cannot start by number, add trailing "x" character
id = id:gsub("^([%d])", "x%1")
return "<item id='"..id .. "' href='"..item.."' media-type='"..mimetype.."' />",id
end
local find_all_files= function(s,r)
- local r = r or "([%a%d%_%-]*)%.([x]?html)"
+ -- find files that had been declared in the OPF file using \Configure{OpfMetadata}
+ local r = r or "(.*)%.([x]?html)"
local files = {}
- for i, ext in s:gmatch(r) do
- --local i, ext = s:match(r)-- do
- ext = ext or "true"
- files[i] = ext
+ for item in s:gmatch("href=\"(.-)\"") do
+ local i, ext = item:match(r)
+ if i then
+ --local i, ext = s:match(r)-- do
+ ext = ext or "true"
+ files[item] = ext
+ end
end
return files
end
@@ -188,7 +202,8 @@
local h_second = io.open(opf_second_part,"r")
local opf_complete = {}
table.insert(opf_complete,h_first:read("*all"))
- local used_html = find_all_files(opf_complete[1])
+ -- we used to detect all declared HTML files, but this table wasn't used anymore, so I deprecate this use
+ -- local used_html = find_all_files(opf_complete[1])
-- local lg_file = ebookutils.parse_lg(outputfilename..".lg")
-- The lg_file has been already loaded by make4ht, it doesn't make sense to load it again
-- Furthermore, it is now possible to add new files from Lua build files
@@ -196,12 +211,10 @@
local used_files = {}
for _,filename in ipairs(lg_file["files"]) do
-- we need to test the filenames in order to prevent duplicates
- -- filenames are tested without paths, so there may be issues if
- -- the same filename is used in different directories. Is that a problem?
used_files[filename] = true
end
local outside_spine = {}
- local all_used_files = find_all_files(opf_complete[1],"([%a%d%-%_]+%.[%a%d]+)")
+ local all_used_files = find_all_files(opf_complete[1],"(.+)%.(.+)")
local used_paths = {}
local used_ids = {}
for _,k in ipairs(lg_file["files"]) do
@@ -212,8 +225,6 @@
table.remove(parts,#parts)
--table.insert(parts,1,"OEBPS")
table.insert(parts,1,outputdir)
- -- print("SSSSS "..fn.." ext .." .. ext)
- --if string.find("jpg gif png", ext) and not all_used_files[k] then
local item,id = lg_item(k)
if item then
local path = table.concat(parts)
@@ -232,7 +243,7 @@
end
if not used_ids[id] then
ebookutils.copy(k, outputdir .. "/"..k)
- if not all_used_files[fn] then
+ if not all_used_files[k] then
table.insert(opf_complete,item)
if allow_in_spine[ext] then
table.insert(outside_spine,id)
Modified: trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua 2023-03-03 21:31:54 UTC (rev 66331)
+++ trunk/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua 2023-03-03 21:32:09 UTC (rev 66332)
@@ -186,6 +186,10 @@
if filename then
filename = outputdir .. "/" .. filename
local f = io.open(filename, "r")
+ if not f then
+ log:warning("Cannot open TOC file for clean-up: " .. filename)
+ return nil
+ end
local t = f:read("*all")
f:close()
local tocdom = dom.parse(t)
Modified: trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht 2023-03-03 21:31:54 UTC (rev 66331)
+++ trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht 2023-03-03 21:32:09 UTC (rev 66332)
@@ -24,9 +24,10 @@
\Configure{toTocLink}{}{}
}{\b:NavMap}{}{}{}
%%%%%%%%%%%
-\Configure{NavMap}{\ifvmode\IgnorePar\fi\EndP\boolfalse{tocnoempty}\HCode{<nav id="toc" epub:type="toc">\Hnewline<ol>}%
+\newcount\:toccount
+\Configure{NavMap}{\ifvmode\IgnorePar\fi\EndP\boolfalse{tocnoempty}\global\advance\:toccount by1\HCode{<nav id="toc\the\:toccount" \ifnum\:toccount<2 epub:type="toc"\fi>\Hnewline<ol>}%
\opf:registerfilename{\FileName}
-\opf:add:property{nav}
+\ifnum\:toccount<2 \opf:add:property{nav}\fi
}{\usetoclevels{part,appendix,chapter,section,subsection,subsubsection}%
\ifbool{tocnoempty}{}{\HCode{<li><a href="\jobname.\:html">Document</a></li>}}
\HCode{</ol></nav>}}
@@ -76,6 +77,9 @@
% Structural elements
+\:CheckOption{fn-in}
+\if:Option
+\else
% Foootnote configuration for epub3
% Footnotes are printed directly after the paragraph they appeared in
% footnotebox - configure box in which footnotes are printed
@@ -91,7 +95,7 @@
\ifvoid\footnotebox\else\unvbox\footnotebox\fi%
\IgnorePar%
\bgroup%
- \fnlink{}{fn\FNnum x\minipageNum}\Tg<p>%
+ \fnlink{}{fn\FNnum x\minipageNum}\Tg<p>\AnchorLabel%
}{\EndNoFonts}
{%
\HCode{</p>\Hnewline}
@@ -114,3 +118,4 @@
\Css{.footnote{font-size:small;}}
\Css{.footnotes hr{width:30\%;margin:0 auto 0 0;}}
+\fi
Modified: trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht 2023-03-03 21:31:54 UTC (rev 66331)
+++ trunk/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht 2023-03-03 21:32:09 UTC (rev 66332)
@@ -391,7 +391,7 @@
\ncx:head%
% Book title
\ncx:title%
-\tableofcontents[part,appendix,chapter,likechapter,appendixsec,section,likesection,appendixsubsec,subsection,likesubsection]%
+\tableofcontents[part,appendix,chapter,likechapter,appendixsec,section,likesection,appendixsubsec,subsection,likesubsection,subsubsection,likesubsubsection]%
%Hack to get close tag working
\HCode{</ncx>}%
\EndNoFonts
More information about the tex-live-commits
mailing list.