summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-03-03 03:05:02 +0000
committerNorbert Preining <norbert@preining.info>2023-03-03 03:05:02 +0000
commitc000ad35f0ce69cc0466ad24b0647c1e295c0259 (patch)
tree6c64b429a374b5d60b67c2f728c71acb110c775c /support
parentfe8af26a7b8f32a0cc1b761e3ffb95ed0867a845 (diff)
CTAN sync 202303030305
Diffstat (limited to 'support')
-rw-r--r--support/tex4ebook/README62
-rw-r--r--support/tex4ebook/changelog.tex89
-rw-r--r--support/tex4ebook/readme.tex89
-rwxr-xr-xsupport/tex4ebook/tex4ebook9
-rw-r--r--support/tex4ebook/tex4ebook-doc.pdfbin85759 -> 90419 bytes
-rw-r--r--support/tex4ebook/tex4ebook-epub3.4ht11
-rw-r--r--support/tex4ebook/tex4ebook-exec_epub.lua49
-rw-r--r--support/tex4ebook/tex4ebook-exec_epub3.lua4
-rw-r--r--support/tex4ebook/tex4ebook.4ht2
9 files changed, 270 insertions, 45 deletions
diff --git a/support/tex4ebook/README b/support/tex4ebook/README
index 8339341c51..95c60088ee 100644
--- a/support/tex4ebook/README
+++ b/support/tex4ebook/README
@@ -107,11 +107,6 @@ For example:
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 @@ For example:
`-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,8 +251,26 @@ Remarks:
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
@@ -279,13 +292,42 @@ Remarks:
## 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
diff --git a/support/tex4ebook/changelog.tex b/support/tex4ebook/changelog.tex
index 7eaa4c85ec..92ec689690 100644
--- a/support/tex4ebook/changelog.tex
+++ b/support/tex4ebook/changelog.tex
@@ -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}
diff --git a/support/tex4ebook/readme.tex b/support/tex4ebook/readme.tex
index 52982d65c4..e144238178 100644
--- a/support/tex4ebook/readme.tex
+++ b/support/tex4ebook/readme.tex
@@ -115,15 +115,12 @@ This set \texttt{mode} variable, accessible in the build file. Default
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 @@ Remarks:
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 @@ deprecated in \texttt{EPUB\ 3}.
\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}}
diff --git a/support/tex4ebook/tex4ebook b/support/tex4ebook/tex4ebook
index 8f6c8aa3f7..0bde98c9e0 100755
--- a/support/tex4ebook/tex4ebook
+++ b/support/tex4ebook/tex4ebook
@@ -43,7 +43,7 @@ tex4ebook [switches] filename ["tex4ht.sty op."] ["tex4ht op."] ["t4ht op"] ["la
-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 @@ else
end
if args.version then
- print "tex4ebook v0.3h"
+ print "tex4ebook v0.3i"
return
end
@@ -150,6 +150,11 @@ local oldparams = {
,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
diff --git a/support/tex4ebook/tex4ebook-doc.pdf b/support/tex4ebook/tex4ebook-doc.pdf
index 7e8386af7a..bbc6b2da3f 100644
--- a/support/tex4ebook/tex4ebook-doc.pdf
+++ b/support/tex4ebook/tex4ebook-doc.pdf
Binary files differ
diff --git a/support/tex4ebook/tex4ebook-epub3.4ht b/support/tex4ebook/tex4ebook-epub3.4ht
index 9d49b624e6..0e1bcd85db 100644
--- a/support/tex4ebook/tex4ebook-epub3.4ht
+++ b/support/tex4ebook/tex4ebook-epub3.4ht
@@ -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
diff --git a/support/tex4ebook/tex4ebook-exec_epub.lua b/support/tex4ebook/tex4ebook-exec_epub.lua
index 539cf930ab..539e9b19ba 100644
--- a/support/tex4ebook/tex4ebook-exec_epub.lua
+++ b/support/tex4ebook/tex4ebook-exec_epub.lua
@@ -127,49 +127,63 @@ local mimetypes = {
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)
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
-- 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 @@ function make_opf()
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 @@ function make_opf()
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 @@ function make_opf()
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 @@ function make_opf()
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)
diff --git a/support/tex4ebook/tex4ebook-exec_epub3.lua b/support/tex4ebook/tex4ebook-exec_epub3.lua
index 328acaae37..bf66548e2c 100644
--- a/support/tex4ebook/tex4ebook-exec_epub3.lua
+++ b/support/tex4ebook/tex4ebook-exec_epub3.lua
@@ -186,6 +186,10 @@ local function cleanTOC(content)
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)
diff --git a/support/tex4ebook/tex4ebook.4ht b/support/tex4ebook/tex4ebook.4ht
index 8686c2932f..ae550e9832 100644
--- a/support/tex4ebook/tex4ebook.4ht
+++ b/support/tex4ebook/tex4ebook.4ht
@@ -391,7 +391,7 @@ href="#1" media-type="\a:CoverMimeType" />}}
\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