summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/support/tex4ebook/README.md264
-rw-r--r--Master/texmf-dist/doc/support/tex4ebook/changelog.tex115
-rw-r--r--Master/texmf-dist/doc/support/tex4ebook/readme.tex326
-rw-r--r--Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdfbin0 -> 49430 bytes
-rw-r--r--Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.tex24
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/config-t4e.lua19
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/exec_epub.lua300
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/exec_epub3.lua92
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/exec_mobi.lua20
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/list-fonts.lua145
-rw-r--r--Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht113
-rw-r--r--Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht404
-rw-r--r--Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.sty113
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rwxr-xr-xMaster/tlpkg/libexec/ctan2tds1
-rw-r--r--Master/tlpkg/tlpsrc/collection-binextra.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/tex4ebook.tlpsrc0
17 files changed, 1938 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/support/tex4ebook/README.md b/Master/texmf-dist/doc/support/tex4ebook/README.md
new file mode 100644
index 00000000000..86f7c8ee09a
--- /dev/null
+++ b/Master/texmf-dist/doc/support/tex4ebook/README.md
@@ -0,0 +1,264 @@
+# Introduction
+
+`TeX4ebook` is bundle of lua scripts and `LaTeX` packages for conversion of
+LaTeX files to ebook formats, for example `epub`, `mobi` and `epub3`. `tex4ht`
+is used as conversion engine.
+
+Note that while `mobi` is supported by Amazon Kindle, most widespread ebook
+reader, it doesn't support `mathml` and this means that math must re represented
+as images. The same is true for `epub`. This is not a good thing, especially
+for inline math, as you may experience wrong baselines. If your ebook contains
+math, the only correct solution is to produce `epub3`, as it supports `mathml`.
+The issue with `epub3` is, that majority of `e-ink` ebook readers doesn't
+support this format, reader applications exists mainly for Android and Apple
+devices. For books which contains mainly prose, all formats should be suitable,
+but `epub3` supports most features from web standards, such as `CSS`.
+
+As with `tex4ht`, the emphasis is on conversion of document's logical structure
+and metadata, basic visual appearance is preserved as well, but you should use
+custom configurations if you want to make the document more visually appealing.
+You can include custom `CSS` or fonts in configuration files.
+
+## License
+
+Permission is granted to copy, distribute and/or modify this software
+under the terms of the LaTeX Project Public License, version 1.3.
+
+
+# Usage
+
+
+Run on the command line:
+
+ tex4ebook [options] filename
+
+You don't have to modify your source files unless you want to use commands
+defined by `tex4ebook` in the document, or when your document uses some
+unsupported package like `fontspec` (see details bellow how to solve this
+issue).
+
+If you want to use `tex4ebook` commands, add this line to your document
+preamble:
+
+ \usepackage{tex4ebook}
+
+but it is optional. You shouldn't need to modify your \TeX\ files
+
+## Available commands
+
+- `\coverimage{coverimage.name}` - include cover image to the document.
+
+# Command line options
+
+-c,--config
+
+: specify custom config file for `tex4ht`
+
+ **example config file**: File `sample.cfg`
+
+
+ \Preamble{xhtml}
+ \CutAt{section}
+ \begin{document}
+ \EndPreamble
+
+ run
+
+ tex4ebook -c sample filename.tex
+
+ This config file will create `xhtml` file for every section. Note that this
+ behaviour is default.
+
+-e,--build-file (default nil)
+
+: Specify [make4ht build file](https://github.com/michal-h21/make4ht#build-file).
+ Defaulf build file filename is `filename.mk4`, use this option when it has
+ different filename.
+
+-f,--format (default epub)
+
+: Output format. epub, epub3 and mobi are supported.
+
+-l,--lua
+
+: Runs htlualatex instead of htlatex.
+
+-m,--mode (default default)
+
+: This set `mode` variable, accessible in the build file. Default supported
+ 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 htlatex run. This may be needed if you run external
+ commands from your source files.
+
+t,--tidy
+
+: Run tidy on output html files.
+
+
+# Configuration
+
+`tex4ebook` uses [tex4ht](http://www.tug.org/tex4ht/) for conversion from LaTeX
+to html. `tex4ht` is highly configurable using config files. Basic config file
+structure is
+
+ \Preamble{xhtml, comma separated list of options}
+ ...
+ \begin{document}
+ ...
+ \EndPreamble
+
+Basic info about command configurations can be found in a work-in-progres
+[tex4ht tutorial](https://github.com/michal-h21/helpers4ht/wiki/tex4ht-tutorial)
+, [tex4ht documentation](http://www.tug.org/applications/tex4ht/mn11.html),
+and in series of blogposts on CV Radhakrishnan's blog:
+[Configure part 1](http://www.cvr.cc/?p=323),
+[Configure part 2](http://www.cvr.cc/?p=362),
+[Low level commands](http://www.cvr.cc/?p=482).
+Available options for `\Preamble` command are listed in the article
+[TeX4ht: options](http://www.cvr.cc/?p=504).
+
+Great source of tips for `tex4ht` configuring is [tex4ht tag on TeX.sx](http://tex.stackexchange.com/questions/tagged/tex4ht), there is also a [tag for tex4ebook](http://tex.stackexchange.com/questions/tagged/tex4ebook).
+
+Examples of interesting questions are
+[including images and fonts in ebooks](including images and fonts in ebooks)
+or [setting image size in em units instead of pt](http://tex.stackexchange.com/a/195718/2891).
+
+## Provided configurations
+
+`tex4ebook` provides some configurations for your usage:
+
+ \Configure{UniqueIdentifier}{identifier}
+
+
+Every epub file should have unique identifier, like ISBN, DOI, URI etc.
+Default identifier is URI, with value `http://example.com/\jobname`.
+
+ \Configure{OpfScheme}{URI}
+
+Type of unique identifier, default type is URI. It is
+used only in epub, it is deprecated for `epub3`
+
+ \Configure{CoverImage}{before cover image}{after cover image}
+
+By default, cover image is inserted in `<div class="cover-image">` element,
+you may use this configuration option to insert different markup,
+or even to place the cover image to standalone page.
+
+
+ \Configure{CoverMimeType}{mime type of cover image}
+
+Default value is `image/png`, change this value if you use other image
+type than `png`.
+
+If you don't want to include the cover image in the document, use command
+
+ \CoverMetadata{filename}
+
+in the config file.
+
+ \Configure{OpfMetadata}{item element}
+
+Add item to `<metadata>` section in the `OPF` file.
+
+ \Configure{OpfManifest}{maifest element}
+
+Add item to `<manifest>` section in the `OPF` file.
+
+ \Configure{xmlns}{prefix}{uri}
+
+Add xml name space to `xhtml` files. Useful in `EPUB 3`
+
+
+
+## Commands available in config files
+
+`\OpfRegisterFile[filename]`
+
+: register file in the `OPF` file. Current output file is added by default.
+
+`\OpfAddProperty{property type}`
+
+: add `EPUB3` property for the current file. See [EPUB3 spec](http://www.idpf.org/epub/301/spec/epub-publications.html#sec-item-property-values)
+
+`\OpfGuide[filename]{title}{type}`
+
+: Add file to the `<guide>` section in the `OPF` file. See [Where do you start an ePUB and what is the `<guide>` section of the .OPF file?](http://epubsecrets.com/where-do-you-start-an-epub-and-what-is-the-guide-section-of-the-opf-file.php) for some details. Note that `<guide>` is deprecated in `EPUB 3`.
+
+## Build files
+
+`tex4ebook` uses [make4ht](https://github.com/michal-h21/make4ht) as a build
+system. See `make4ht` documentation for details on build files.
+
+# Troubleshooting
+
+When compilation of the document breaks with error during `LaTeX` run, it may
+be caused by some problem in `tex4ht` configuration. Comment out line
+`\usepackage{tex4ebook}` in your source file and run command:
+
+ htlatex filename
+
+if same error as in `tex4ebook` run arises, the problem is in some `tex4ht`
+configuration. Try to identify the source of problem and if you cannot find the
+solution, make minimal example showing the error and ask for help either on
+[tex4ht mailinglist](http://tug.org/mailman/listinfo/tex4ht) or on
+[TeX-sx](http://tex.stackexchange.com/).
+
+## Fontspec
+
+`tex4ht` currently doesn't support `fontspec` and open type fonts. At this
+moment, workaround for this is to modify your source file and conditionaly
+include fontspec and any other conflicting packages only when document is not
+processed with `tex4ht`.
+
+Sample:
+
+ \documentclass{article}
+ \makeatletter
+ \@ifpackageloaded{tex4ht}{%
+ % Packages for tex4ht unicode support
+ \usepackage[utf8]{inputenc}
+ \usepackage[T1]{fontenc}
+ \usepackage[english,czech]{babel}
+ }{%
+ % Packages for xelatex
+ \usepackage{fontspec}
+ \usepackage{polyglossia}
+ \setmainfont{Latin Modern Roman}
+ }
+ \makeatother
+
+Drawback is that not all characters of unicode range are supported with
+`inputenc`. For some solutions of this limitation, see a thread on [tex4ht
+mailinglist](http://tug.org/pipermail/tex4ht/2013q1/000719.html)
+
+## Validation
+
+In case of successful compilation, use command line tool `epubcheck` to check
+whether your document doesn't contain any errors.
+
+Type
+
+ epubcheck filename.epub
+
+### Common validation issues:
+
+- WARNING: filename.epub: item (OEBPS/foo.boo) exists in the zip file, but is
+not declared in the OPF file
+
+ Delete the `filename-(epub|epub3|mobi)` folder and `filename.epub`. Then
+ run `tex4ebook` again.
+
+- WARNING(ACC-009): hsmmt10t.epub/OEBPS/hsmmt10tch17.xhtml(235,15): MathML should either have an alt text attribute or annotation-xml child element.
+
+ This is accessibility message. Unless you use some macro with annotations for
+ each math instance, you will get lot of these messages. Try to use
+ `epubcheck -e` to print only serious errors.
diff --git a/Master/texmf-dist/doc/support/tex4ebook/changelog.tex b/Master/texmf-dist/doc/support/tex4ebook/changelog.tex
new file mode 100644
index 00000000000..8748dde1b4a
--- /dev/null
+++ b/Master/texmf-dist/doc/support/tex4ebook/changelog.tex
@@ -0,0 +1,115 @@
+\section{Changes}\label{changes}
+
+\begin{itemize}
+\item
+ 29/06/2015 Version 0.1
+
+ \begin{itemize}
+ \itemsep1pt\parskip0pt\parsep0pt
+ \item
+ fixes in documentation
+ \end{itemize}
+\item
+ 22/06/2015
+
+ \begin{itemize}
+ \itemsep1pt\parskip0pt\parsep0pt
+ \item
+ changes moved from README.md to CHANGELOG.md
+ \end{itemize}
+\item
+ 18/06/2015
+
+ \begin{itemize}
+ \itemsep1pt\parskip0pt\parsep0pt
+ \item
+ replaced \texttt{-{}-mathml} option with \texttt{-{}-mode}. For
+ \texttt{mathml} support, use\texttt{mathml} option for
+ \texttt{tex4ht.sty}.
+ \item
+ lot of stuff was fixed in \texttt{epub3} support.
+ \item
+ new command \texttt{\textbackslash{}OpfAddProperty}
+ \end{itemize}
+\item
+ 14/01/2015
+
+ \begin{itemize}
+ \itemsep1pt\parskip0pt\parsep0pt
+ \item
+ thanks Volker Gottwald for guide on
+ \href{https://d800fotos.wordpress.com/2015/01/19/create-e-books-from-latex-tex-files-ebook-aus-latex-tex-dateien-erstellen/}{installing
+ and using tex4ebook} on Windows
+ \end{itemize}
+\item
+ 23/11/2014
+
+ \begin{itemize}
+ \item
+ added new command \texttt{\textbackslash{}OpfGuide}, for adding
+ items to \texttt{\textless{}guide\textgreater{}} section in the
+ \texttt{opf} file. This is useful for \texttt{epub} and
+ \texttt{mobi} formats.
+
+ Usage:
+
+\begin{verbatim}
+ \OpfGuide[filename]{title}{reference type}
+\end{verbatim}
+
+ \texttt{filename} is optional, current file name is used when empty.
+ See
+ \href{http://epubsecrets.com/where-do-you-start-an-epub-and-what-is-the-guide-section-of-the-opf-file.php}{epub
+ secrets} article
+ \end{itemize}
+\item
+ 20/10/2014
+
+ \begin{itemize}
+ \item
+ fixed issues with starred sections
+ \item
+ files created with starred sectioning commands
+ (\texttt{\textbackslash{}chapter*},
+ \texttt{\textbackslash{}section*}) should be included in correct
+ reading order now
+ \end{itemize}
+\item
+ 16/09/2014
+
+ \begin{itemize}
+ \itemsep1pt\parskip0pt\parsep0pt
+ \item
+ new features added
+ \item
+ new configuration file for \texttt{-{}-tidy} option, mathml and
+ html5 elements are supported. This means that many validation errors
+ in \texttt{mathml} output can be fixed with \texttt{-{}-tidy} option
+ \item
+ added configuration for all languages supported by \texttt{babel}
+ \item
+ \texttt{woff} and \texttt{ttf} fonts are supported
+ \item
+ added inline footlines in \texttt{epub3} format
+ \item
+ added \texttt{no-cut} command line option for breaking sections and
+ chapters into standalone pages
+ \item
+ Please support
+ \href{http://www.ulule.com/mathematics-ebooks/}{iniciative for
+ improving mathml support} in Gecko and Webkit engines. This will
+ hopefully improve also Epub3 readers.
+ \end{itemize}
+\item
+ 10/08/2013
+
+ \begin{itemize}
+ \itemsep1pt\parskip0pt\parsep0pt
+ \item
+ \href{https://github.com/michal-h21/make4ht}{\texttt{make4ht}} is
+ now standalone application which \texttt{tex4ebook} depends on. You
+ must
+ \href{https://github.com/michal-h21/make4ht\#instalation}{install
+ it} in order to use current \texttt{tex4ebook} version.
+ \end{itemize}
+\end{itemize}
diff --git a/Master/texmf-dist/doc/support/tex4ebook/readme.tex b/Master/texmf-dist/doc/support/tex4ebook/readme.tex
new file mode 100644
index 00000000000..cf8a11c0b1c
--- /dev/null
+++ b/Master/texmf-dist/doc/support/tex4ebook/readme.tex
@@ -0,0 +1,326 @@
+\section{Introduction}\label{introduction}
+
+\texttt{TeX4ebook} is bundle of lua scripts and \texttt{LaTeX} packages
+for conversion of LaTeX files to ebook formats, for example
+\texttt{epub}, \texttt{mobi} and \texttt{epub3}. \texttt{tex4ht} is used
+as conversion engine.
+
+Note that while \texttt{mobi} is supported by Amazon Kindle, most
+widespread ebook reader, it doesn't support \texttt{mathml} and this
+means that math must re represented as images. The same is true for
+\texttt{epub}. This is not a good thing, especially for inline math, as
+you may experience wrong baselines. If your ebook contains math, the
+only correct solution is to produce \texttt{epub3}, as it supports
+\texttt{mathml}. The issue with \texttt{epub3} is, that majority of
+\texttt{e-ink} ebook readers doesn't support this format, reader
+applications exists mainly for Android and Apple devices. For books
+which contains mainly prose, all formats should be suitable, but
+\texttt{epub3} supports most features from web standards, such as
+\texttt{CSS}.
+
+As with \texttt{tex4ht}, the emphasis is on conversion of document's
+logical structure and metadata, basic visual appearance is preserved as
+well, but you should use custom configurations if you want to make the
+document more visually appealing. You can include custom \texttt{CSS} or
+fonts in configuration files.
+
+\subsection{License}\label{license}
+
+Permission is granted to copy, distribute and/or modify this software
+under the terms of the LaTeX Project Public License, version 1.3.
+
+\section{Usage}\label{usage}
+
+Run on the command line:
+
+\begin{verbatim}
+tex4ebook [options] filename
+\end{verbatim}
+
+You don't have to modify your source files unless you want to use
+commands defined by \texttt{tex4ebook} in the document, or when your
+document uses some unsupported package like \texttt{fontspec} (see
+details bellow how to solve this issue).
+
+If you want to use \texttt{tex4ebook} commands, add this line to your
+document preamble:
+
+\begin{verbatim}
+\usepackage{tex4ebook}
+\end{verbatim}
+
+but it is optional. You shouldn't need to modify your \TeX~files
+
+\subsection{Available commands}\label{available-commands}
+
+\begin{itemize}
+\itemsep1pt\parskip0pt\parsep0pt
+\item
+ \texttt{\textbackslash{}coverimage\{coverimage.name\}} - include cover
+ image to the document.
+\end{itemize}
+
+\section{Command line options}\label{command-line-options}
+
+\begin{description}
+\itemsep1pt\parskip0pt\parsep0pt
+\item[-c,--config]
+specify custom config file for \texttt{tex4ht}
+\end{description}
+
+\textbf{example config file}: File \texttt{sample.cfg}
+
+\begin{verbatim}
+ \Preamble{xhtml}
+ \CutAt{section}
+ \begin{document}
+ \EndPreamble
+\end{verbatim}
+
+run
+
+\begin{verbatim}
+ tex4ebook -c sample filename.tex
+\end{verbatim}
+
+This config file will create \texttt{xhtml} file for every section. Note
+that this behaviour is default.
+
+\begin{description}
+\item[-e,--build-file (default nil)]
+Specify \href{https://github.com/michal-h21/make4ht\#build-file}{make4ht
+build file}. Defaulf build file filename is \texttt{filename.mk4}, use
+this option when it has different filename.
+\item[-f,--format (default epub)]
+Output format. epub, epub3 and mobi are supported.
+\item[-l,--lua]
+Runs htlualatex instead of htlatex.
+\item[-m,--mode (default default)]
+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[-r,--resolution]
+Resolution of generated images, for example math. It should meet
+resolution of target devices, which is usually about 167 ppi.
+\item[-s,--shell-escape]
+Enable shell escape in htlatex run. This may be needed if you run
+external commands from your source files.
+\item[t,--tidy]
+Run tidy on output html files.
+\end{description}
+
+\section{Configuration}\label{configuration}
+
+\texttt{tex4ebook} uses \href{http://www.tug.org/tex4ht/}{tex4ht} for
+conversion from LaTeX to html. \texttt{tex4ht} is highly configurable
+using config files. Basic config file structure is
+
+\begin{verbatim}
+\Preamble{xhtml, comma separated list of options}
+...
+\begin{document}
+...
+\EndPreamble
+\end{verbatim}
+
+Basic info about command configurations can be found in a
+work-in-progres
+\href{https://github.com/michal-h21/helpers4ht/wiki/tex4ht-tutorial}{tex4ht
+tutorial} ,
+\href{http://www.tug.org/applications/tex4ht/mn11.html}{tex4ht
+documentation}, and in series of blogposts on CV Radhakrishnan's blog:
+\href{http://www.cvr.cc/?p=323}{Configure part 1},
+\href{http://www.cvr.cc/?p=362}{Configure part 2},
+\href{http://www.cvr.cc/?p=482}{Low level commands}. Available options
+for \texttt{\textbackslash{}Preamble} command are listed in the article
+\href{http://www.cvr.cc/?p=504}{TeX4ht: options}.
+
+Great source of tips for \texttt{tex4ht} configuring is
+\href{http://tex.stackexchange.com/questions/tagged/tex4ht}{tex4ht tag
+on TeX.sx}, there is also a
+\href{http://tex.stackexchange.com/questions/tagged/tex4ebook}{tag for
+tex4ebook}.
+
+Examples of interesting questions are
+\href{including\%20images\%20and\%20fonts\%20in\%20ebooks}{including
+images and fonts in ebooks} or
+\href{http://tex.stackexchange.com/a/195718/2891}{setting image size in
+em units instead of pt}.
+
+\subsection{Provided configurations}\label{provided-configurations}
+
+\texttt{tex4ebook} provides some configurations for your usage:
+
+\begin{verbatim}
+\Configure{UniqueIdentifier}{identifier}
+\end{verbatim}
+
+Every epub file should have unique identifier, like ISBN, DOI, URI etc.
+Default identifier is URI, with value
+\texttt{http://example.com/\textbackslash{}jobname}.
+
+\begin{verbatim}
+\Configure{OpfScheme}{URI}
+\end{verbatim}
+
+Type of unique identifier, default type is URI. It is used only in epub,
+it is deprecated for \texttt{epub3}
+
+\begin{verbatim}
+\Configure{CoverImage}{before cover image}{after cover image}
+\end{verbatim}
+
+By default, cover image is inserted in
+\texttt{\textless{}div class="cover-image"\textgreater{}} element, you
+may use this configuration option to insert different markup, or even to
+place the cover image to standalone page.
+
+\begin{verbatim}
+\Configure{CoverMimeType}{mime type of cover image}
+\end{verbatim}
+
+Default value is \texttt{image/png}, change this value if you use other
+image type than \texttt{png}.
+
+If you don't want to include the cover image in the document, use
+command
+
+\begin{verbatim}
+\CoverMetadata{filename}
+\end{verbatim}
+
+in the config file.
+
+\begin{verbatim}
+\Configure{OpfMetadata}{item element}
+\end{verbatim}
+
+Add item to \texttt{\textless{}metadata\textgreater{}} section in the
+\texttt{OPF} file.
+
+\begin{verbatim}
+\Configure{OpfManifest}{maifest element}
+\end{verbatim}
+
+Add item to \texttt{\textless{}manifest\textgreater{}} section in the
+\texttt{OPF} file.
+
+\begin{verbatim}
+\Configure{xmlns}{prefix}{uri}
+\end{verbatim}
+
+Add xml name space to \texttt{xhtml} files. Useful in \texttt{EPUB 3}
+
+\subsection{Commands available in config
+files}\label{commands-available-in-config-files}
+
+\begin{description}
+\item[\texttt{\textbackslash{}OpfRegisterFile{[}filename{]}}]
+register file in the \texttt{OPF} file. Current output file is added by
+default.
+\item[\texttt{\textbackslash{}OpfAddProperty\{property type\}}]
+add \texttt{EPUB3} property for the current file. See
+\href{http://www.idpf.org/epub/301/spec/epub-publications.html\#sec-item-property-values}{EPUB3
+spec}
+\item[\texttt{\textbackslash{}OpfGuide{[}filename{]}\{title\}\{type\}}]
+Add file to the \texttt{\textless{}guide\textgreater{}} section in the
+\texttt{OPF} file. See
+\href{http://epubsecrets.com/where-do-you-start-an-epub-and-what-is-the-guide-section-of-the-opf-file.php}{Where
+do you start an ePUB and what is the
+\texttt{\textless{}guide\textgreater{}} section of the .OPF file?} for
+some details. Note that \texttt{\textless{}guide\textgreater{}} is
+deprecated in \texttt{EPUB 3}.
+\end{description}
+
+\subsection{Build files}\label{build-files}
+
+\texttt{tex4ebook} uses
+\href{https://github.com/michal-h21/make4ht}{make4ht} as a build system.
+See \texttt{make4ht} documentation for details on build files.
+
+\section{Troubleshooting}\label{troubleshooting}
+
+When compilation of the document breaks with error during \texttt{LaTeX}
+run, it may be caused by some problem in \texttt{tex4ht} configuration.
+Comment out line \texttt{\textbackslash{}usepackage\{tex4ebook\}} in
+your source file and run command:
+
+\begin{verbatim}
+htlatex filename
+\end{verbatim}
+
+if same error as in \texttt{tex4ebook} run arises, the problem is in
+some \texttt{tex4ht} configuration. Try to identify the source of
+problem and if you cannot find the solution, make minimal example
+showing the error and ask for help either on
+\href{http://tug.org/mailman/listinfo/tex4ht}{tex4ht mailinglist} or on
+\href{http://tex.stackexchange.com/}{TeX-sx}.
+
+\subsection{Fontspec}\label{fontspec}
+
+\texttt{tex4ht} currently doesn't support \texttt{fontspec} and open
+type fonts. At this moment, workaround for this is to modify your source
+file and conditionaly include fontspec and any other conflicting
+packages only when document is not processed with \texttt{tex4ht}.
+
+Sample:
+
+\begin{verbatim}
+\documentclass{article}
+\makeatletter
+\@ifpackageloaded{tex4ht}{%
+% Packages for tex4ht unicode support
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage[english,czech]{babel}
+}{%
+% Packages for xelatex
+\usepackage{fontspec}
+\usepackage{polyglossia}
+\setmainfont{Latin Modern Roman}
+}
+\makeatother
+\end{verbatim}
+
+Drawback is that not all characters of unicode range are supported with
+\texttt{inputenc}. For some solutions of this limitation, see a thread
+on \href{http://tug.org/pipermail/tex4ht/2013q1/000719.html}{tex4ht
+mailinglist}
+
+\subsection{Validation}\label{validation}
+
+In case of successful compilation, use command line tool
+\texttt{epubcheck} to check whether your document doesn't contain any
+errors.
+
+Type
+
+\begin{verbatim}
+epubcheck filename.epub
+\end{verbatim}
+
+\subsubsection{Common validation
+issues:}\label{common-validation-issues}
+
+\begin{itemize}
+\itemsep1pt\parskip0pt\parsep0pt
+\item
+ WARNING: filename.epub: item (OEBPS/foo.boo) exists in the zip file,
+ but is not declared in the OPF file
+\end{itemize}
+
+Delete the \texttt{filename-(epub\textbar{}epub3\textbar{}mobi)} folder
+and \texttt{filename.epub}. Then run \texttt{tex4ebook} again.
+
+\begin{itemize}
+\itemsep1pt\parskip0pt\parsep0pt
+\item
+ WARNING(ACC-009): hsmmt10t.epub/OEBPS/hsmmt10tch17.xhtml(235,15):
+ MathML should either have an alt text attribute or annotation-xml
+ child element.
+\end{itemize}
+
+This is accessibility message. Unless you use some macro with
+annotations for each math instance, you will get lot of these messages.
+Try to use \texttt{epubcheck -e} to print only serious errors.
diff --git a/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf b/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf
new file mode 100644
index 00000000000..0eebc2fdf46
--- /dev/null
+++ b/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.tex b/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.tex
new file mode 100644
index 00000000000..b6c8bfcc4a1
--- /dev/null
+++ b/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.tex
@@ -0,0 +1,24 @@
+\documentclass{article}
+
+
+\usepackage[english]{babel}
+\usepackage{hyperref}
+\ifdefined\HCode
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\else
+\usepackage{fontspec}
+\setmainfont{TeX Gyre Schola}
+\fi
+\usepackage{microtype}
+
+\title{The \texttt{tex4ebook} package}
+\author{Michal Hoftich\footnote{\url{michal.h21@gmail.com}}}
+\date{Version 0.1\\29/06/2015}
+\begin{document}
+\maketitle
+\tableofcontents
+\input{readme}
+
+\input{changelog}
+\end{document}
diff --git a/Master/texmf-dist/scripts/tex4ebook/config-t4e.lua b/Master/texmf-dist/scripts/tex4ebook/config-t4e.lua
new file mode 100755
index 00000000000..9cc6681efec
--- /dev/null
+++ b/Master/texmf-dist/scripts/tex4ebook/config-t4e.lua
@@ -0,0 +1,19 @@
+-- Config file for tex4ebook
+
+-- Font config
+
+Font{
+ name = "cmr",
+ file = "lmroman10-regular.otf",
+ family = "Latin Modern",
+ weight = "normal",
+ style = "normal"
+}
+
+Font{
+ name = "cmmi",
+ file = "lmroman10-italic.otf",
+ family = "Latin Modern",
+ weight = "normal",
+ style = "italic"
+}
diff --git a/Master/texmf-dist/scripts/tex4ebook/exec_epub.lua b/Master/texmf-dist/scripts/tex4ebook/exec_epub.lua
new file mode 100755
index 00000000000..45977c2ee2f
--- /dev/null
+++ b/Master/texmf-dist/scripts/tex4ebook/exec_epub.lua
@@ -0,0 +1,300 @@
+module("exec_epub",package.seeall)
+local lfs = require("lfs")
+local os = require("os")
+local io = require("io")
+--local ebookutils = require("ebookutils")
+local ebookutils = require "mkutils"
+-- font loading doesn't work, font database format changes often
+-- and it is different between TL and Miktex
+-- local load_font = require("list-fonts")
+local outputdir_name="OEBPS"
+local metadir_name = "META-INF"
+local mimetype_name="mimetype"
+outputdir=""
+outputfile=""
+outputfilename=""
+basedir = ""
+tidy = false
+local include_fonts = false
+local metadir=""
+
+
+
+function prepare(params)
+ local randname=tostring(math.random(12000))
+ -- if not ebookutils.file_exists("tex4ht.env") then
+ -- local env_file = kpse.find_file("epub2.env")
+ --print("Local env file: "..env_file)
+ -- ebookutils.copy(env_file,"tex4ht.env")
+ -- end
+ local makedir= function(path)
+ local current = lfs.currentdir()
+ local dir = ebookutils.prepare_path(path .. "/")
+ if type(dir) == "table" then
+ local parts,msg = ebookutils.find_directories(dir)
+ if parts then
+ ebookutils.mkdirectories(parts)
+ end
+ end
+ lfs.chdir(current)
+ end
+ basedir = params.input.."-".. params.format
+ outputdir= basedir.."/"..outputdir_name --"outdir-"..randname --os.tmpdir()
+ makedir(outputdir)
+ -- lfs.mkdir(outputdir)
+ --ebookutils.mkdirectories(ebookutils.prepare_path(outputdir.."/"))
+ metadir = basedir .."/" .. metadir_name --"metadir-"..randname
+ makedir(metadir)
+ --local dd = ebookutils.prepare_path(metadir.."/")
+ --for _,d in pairs(dd) do print("metadir path: "..d) end
+ -- lfs.mkdir(metadir)
+ --local status, msg = ebookutils.mkdirectories(ebookutils.prepare_path(metadir.."/"))
+ --if not status then print("make mmetadir error:" ..msg) end
+ mimetype= basedir .. "/" ..mimetype_name --os.tmpname()
+ print(outputdir)
+ print(mimetype)
+ tidy = params.tidy
+ include_fonts = params.include_fonts
+ params["t4ht_par"] = params["t4ht_par"] -- + "-d"..string.format(params["t4ht_dir_format"],outputdir)
+ return(params)
+end
+
+function run(out,params)
+ --local currentdir=
+ outputfilename=out
+ outputfile = outputfilename..".epub"
+ print("Output file: "..outputfile)
+ --lfs.chdir(metadir)
+ local m= io.open(metadir.."/container.xml","w")
+ m:write([[
+<?xml version="1.0"?>
+<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
+<rootfiles>
+<rootfile full-path="OEBPS/content.opf"
+media-type="application/oebps-package+xml"/>
+</rootfiles>
+</container>
+ ]])
+ m:close()
+ --lfs.chdir("..")
+ m=io.open(mimetype,"w")
+ m:write("application/epub+zip")
+ m:close()
+ local htlatex_run = "${htlatex} ${input} \"${config}${tex4ht_sty_par}\" \"${tex4ht_par}\" \"${t4ht_par}\" \"${latex_par}\"" % params
+ print("Make4ht run")
+ print("-------------------")
+ params.config_file.Make.params = params
+ local mode = params.mode
+ if params.config_file.Make:length() < 1 then
+ if mode == "draft" then
+ params.config_file.Make:htlatex()
+ else
+ params.config_file.Make:htlatex()
+ params.config_file.Make:htlatex()
+ params.config_file.Make:htlatex()
+ end
+ end
+ if #params.config_file.Make.image_patterns > 0 then
+ params["t4ht_par"] = params["t4ht_par"] .." -p"
+ end
+ params.config_file.Make:tex4ht()
+ params.config_file.Make:t4ht()
+ params.config_file.Make:run()
+ print("-------------------")
+ --[[for k,v in pairs(params.config_file.Make) do
+ print(k.. " : "..type(v))
+ end--]]
+ --print(os.execute(htlatex_run))
+end
+
+local mimetypes = {
+ css = "text/css",
+ png = "image/png",
+ jpg = "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",
+ woff = "application/font-woff",
+ js = "text/javascript"
+}
+
+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 print("Mimetype for "..ext.." 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
+ 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)"
+ local files = {}
+ for i, ext in s:gmatch(r) do
+ --local i, ext = s:match(r)-- do
+ ext = ext or "true"
+ files[i] = ext
+ end
+ return files
+ end
+ local tidyconf = nil
+ if tidy then
+ tidyconf = kpse.find_file("tidyconf.conf")
+ end
+ --local opf_first_part = outputdir .. "/content.opf"
+ local opf_first_part = "content.opf"
+ local opf_second_part = "content-part2.opf"
+ --local opf_second_part = outputdir .. "/content-part2.opf"
+ if
+ ebookutils.file_exists(opf_first_part) and ebookutils.file_exists(opf_second_part)
+ then
+ local h_first = io.open(opf_first_part,"r")
+ 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])
+ local lg_file = ebookutils.parse_lg(outputfilename..".lg")
+ local used_files = lg_file["files"]
+ --[[for f in lfs.dir("./OEBPS") do
+ --table.insert(used_files,f)
+ --used_files[f] = true
+ end--]]
+ local all_html = find_all_files(table.concat(used_files,"\n"))
+ local outside_spine = {}
+ -- This was duplicated code
+ --[[for i, ext in pairs(all_html) do
+ if not used_html[i] then
+ print("Prvni insert: ".. i .."."..ext)
+ local item, id = lg_item(i.."."..ext)
+ table.insert(opf_complete,item)
+ table.insert(outside_spine,id)
+ end
+ end--]]
+ local all_used_files = find_all_files(opf_complete[1],"([%a%d%-%_]+%.[%a%d]+)")
+ local used_paths = {}
+ for _,k in ipairs(lg_file["files"]) do
+ local ext = k:match("%.([%a%d]*)$")
+ local parts = k:split "/"
+ local fn = parts[#parts]
+ local allow_in_spine = {html="",xhtml = "", xml = ""}
+ 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)
+ if not used_paths[path] then
+ ebookutils.mkdirectories(parts)
+ used_paths[path]=true
+ end
+ if allow_in_spine[ext] and tidy then
+ if tidyconf then
+ print("Tidy: "..k)
+ local run ="tidy -c -w 200 -q -utf8 -m -config " .. tidyconf .." " .. k
+ os.execute(run)
+ else
+ print "Tidy: Cannot load tidyconf.conf"
+ end
+ end
+ ebookutils.copy(k, outputdir .. "/"..k)
+ if not all_used_files[fn] then
+ table.insert(opf_complete,item)
+ if allow_in_spine[ext] then
+ table.insert(outside_spine,id)
+ end
+ end
+ end
+ end
+ for _,f in ipairs(lg_file["images"]) do
+ local f = f.output
+ local p = lg_item(f)
+ ebookutils.copy(f, outputdir .. "/"..f)
+ table.insert(opf_complete,p)
+ end
+ local end_opf = h_second:read("*all")
+ local spine_items = {}
+ for _,i in ipairs(outside_spine) do
+ table.insert(spine_items,
+ '<itemref idref="${idref}" linear="no" />' % {idref=i})
+ end
+ table.insert(opf_complete,end_opf % {spine = table.concat(spine_items,"\n")})
+ h_first:close()
+ h_second:close()
+ h_first = io.open(opf_first_part,"w")
+ local opf_completed = table.concat(opf_complete,"\n")
+ -- poor man's tidy: remove trailing whitespace befora xml tags
+ opf_completed = opf_completed:gsub("[ ]*<","<")
+ h_first:write(opf_completed)
+ h_first:close()
+ os.remove(opf_second_part)
+ --ebookutils.copy(outputfilename ..".css",outputdir.."/")
+ ebookutils.copy(opf_first_part,outputdir.."/"..opf_first_part)
+ --for c,v in pairs(lg_file["fonts"]) do
+ -- print(c, table.concat(v,", "))
+ --end
+ --print(table.concat(opf_complete,"\n"))
+ else
+ print("Missing opf file")
+ end
+ end
+ local function find_zip()
+ if io.popen("zip -v","r"):close() then
+ return "zip"
+ elseif io.popen("miktex-zip -v","r"):close() then
+ return "miktex-zip"
+ end
+ print "It appears you don't have zip command installed. I can't pack the ebook"
+ return "zip"
+ end
+
+ function pack_container()
+ if os.execute("tidy -v") > 0 then
+ print("Warning:\n tidy command seems missing, you need to install it" ..
+ " in order\n to make valid epub file")
+ else
+ print("Tidy ncx "..
+ os.execute("tidy -xml -i -q -utf8 -m " ..
+ outputdir .. "/" .. outputfilename .. ".ncx"))
+ print("Tidy opf "..
+ os.execute("tidy -xml -i -q -utf8 -m " ..
+ outputdir .. "/" .. "content.opf"))
+ end
+ print(mimetype)
+ local zip = find_zip()
+ print("Pack mimetype " .. os.execute("cd "..basedir.." && "..zip.." -q0X "..outputfile .." ".. mimetype_name))
+ print("Pack metadir " .. os.execute("cd "..basedir.." && "..zip.." -qXr9D " .. outputfile.." "..metadir_name))
+ print("Pack outputdir " .. os.execute("cd "..basedir.." && "..zip.." -qXr9D " .. outputfile.." "..outputdir_name))
+ print("Copy generated epub ")
+ ebookutils.cp(basedir .."/"..outputfile, outputfile)
+end
+
+
+ function writeContainer()
+ make_opf()
+ pack_container()
+ end
+ local function deldir(path)
+ for entry in lfs.dir(path) do
+ if entry~="." and entry~=".." then
+ os.remove(path.."/"..entry)
+ end
+ end
+ os.remove(path)
+ --]]
+ end
+
+ function clean()
+ --deldir(outputdir)
+ --deldir(metadir)
+ --os.remove(mimetype)
+ end
diff --git a/Master/texmf-dist/scripts/tex4ebook/exec_epub3.lua b/Master/texmf-dist/scripts/tex4ebook/exec_epub3.lua
new file mode 100755
index 00000000000..55f7f71c309
--- /dev/null
+++ b/Master/texmf-dist/scripts/tex4ebook/exec_epub3.lua
@@ -0,0 +1,92 @@
+module(...,package.seeall)
+local eb = require("exec_epub")
+
+local outputdir = nil
+local input = nil
+function prepare(params)
+ local basedir = params.input.."-".. params.format
+ local outputdir_name="OEBPS"
+ outputdir= basedir.."/"..outputdir_name
+ input = params.input
+ params.packages = params.packages .. "\\Configure{ext}{xhtml}"
+ return eb.prepare(params)
+end
+
+function run(out,params)
+ return eb.run(out, params)
+end
+
+
+local function makeTOC(document)
+ local template = [[
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:epub="http://www.idpf.org/2007/ops"
+>
+<head><title>TOC</title></head>
+<body>
+<nav id="pub-toc" epub:type="toc">
+ <h1>Table of contents</h1>
+ <ol class="toc" hidden="hidden">
+ <li>
+ <a href="${document}">Document</a>
+ </li>
+ </ol>
+</nav>
+</body>
+</html>
+]] % {document=document}
+ return template
+end
+
+local function cleanOPF()
+ -- in epub3, there must be table of contents
+ -- if there is no toc in the document, we must add generic one
+ local opf = "content.opf"
+ local f = io.open(opf,"r")
+ if not f then
+ print("Cannot open "..opf .. " for toc searching")
+ return nil
+ end
+ local content = f:read("*all")
+ f:close()
+ if content:find "properties[%s]*=[%s]*\"[^\"]*nav" then
+ print "TOC nav found"
+ else
+ print "no TOC, using generic one"
+ local pattern = input.."(%..?html)"
+ local ext = content:match(pattern)
+ local inputfile = input .. ext
+ print("Main file name", inputfile)
+ -- write toc file
+ local toc_name = "generic_toc" ..ext
+ local f = io.open(outputdir .. "/" .. toc_name, "w")
+ f:write(makeTOC(inputfile))
+ f:close()
+ -- add toc file to the conten.opf
+ content = content:gsub("<manifest>","<manifest>\n<item id='htmltoc'" ..
+ " properties=\"nav\" media-type=\"application/xhtml+xml\" href=\""..
+ toc_name .."\" />\n")
+ content = content:gsub("<spine([^>]*)>", "<spine%1>\n<itemref idref=\"htmltoc\" linear=\"no\"/>\n")
+ -- remove empty guide element
+ end
+ content = content:gsub("<guide>%s*</guide>","")
+ f = io.open(outputdir .. "/" ..opf,"w")
+ f:write(content)
+ f:close()
+ --makeTOC(inputfile)
+end
+
+
+
+function writeContainer()
+ --local ret = eb.writeContainer()
+ eb.make_opf()
+ cleanOPF()
+ local ret = eb.pack_container()
+ return ret
+end
+
+function clean()
+ return eb.clean()
+end
diff --git a/Master/texmf-dist/scripts/tex4ebook/exec_mobi.lua b/Master/texmf-dist/scripts/tex4ebook/exec_mobi.lua
new file mode 100755
index 00000000000..be9148b5a10
--- /dev/null
+++ b/Master/texmf-dist/scripts/tex4ebook/exec_mobi.lua
@@ -0,0 +1,20 @@
+module(...,package.seeall)
+local eb = require("exec_epub")
+
+function prepare(params)
+ return eb.prepare(params)
+end
+
+function run(out,params)
+ return eb.run(out, params)
+end
+
+function writeContainer()
+ local ret = eb.writeContainer()
+ print("Pack mobi "..os.execute("kindlegen " .. eb.outputfile))
+ return ret
+end
+
+function clean()
+ return eb.clean()
+end
diff --git a/Master/texmf-dist/scripts/tex4ebook/list-fonts.lua b/Master/texmf-dist/scripts/tex4ebook/list-fonts.lua
new file mode 100755
index 00000000000..9acd1665f60
--- /dev/null
+++ b/Master/texmf-dist/scripts/tex4ebook/list-fonts.lua
@@ -0,0 +1,145 @@
+kpse.set_program_name("luatex")
+local function exists(fn)
+ local f = io.open(fn,"r")
+ if f~=nil then io.close(f) return true else return false end
+end
+local function load_fontbase(pathtable)
+ -- path should point to possible location of luaotfload font database
+ -- pathtable should be array of strings
+ -- each path should not end with lua
+
+ local path = pathtable
+ if type(pathtable) =="string" then path = {pathtable} end
+ if #path == 0 then return nil end
+ local currentpath = table.remove(path,1)
+ if exists(currentpath ..".lua") then return require(currentpath)
+ else return load_fontbase(path) end
+end
+
+--local fontbase = require(kpse.expand_var("$TEXMFSYSVAR") .. "/luatex-cache/generic/names/luaotfload-names.lua")
+local sysvar = kpse.expand_var("$TEXMFSYSVAR")
+local var = kpse.expand_var("$TEXMFVAR")
+local namespath = "/luatex-cache/generic/names/"
+local oldnames = "otfl-names"
+local newnames = "luaotfload-names"
+local compose_path = function(path, name) return path .. namespath .. name end
+local fontbase_path = {
+ compose_path(sysvar, newnames),
+ compose_path(var, newnames),
+ compose_path(sysvar, oldnames),
+ compose_path(var,oldnames)
+}
+
+local fontbase = load_fontbase(fontbase_path) or {}
+fontbase.mappings = fontbase.mappings or {}
+-- assert(fontbase, "Cannot load font names")
+
+
+-- [[
+-- This is code for querying the database
+--
+local search = arg[1] or ""
+search = unicode.utf8.lower(search)
+--]]
+local fonts = {}
+for _,record in pairs(fontbase.mappings) do
+ local familyname = record.familyname
+ local styles = fonts[familyname] or {}
+ local sanitized = record.sanitized or record.names
+ local subfamily = sanitized.subfamily --record.sanitized.subfamily or record.names.subfamily
+ styles[subfamily] = record -- We add subfamily as key to prevent duplicates
+ fonts[familyname] = styles
+end
+
+local FontLoader = {}
+
+FontLoader.__index = FontLoader
+
+FontLoader.load_family = function(familyname)
+ local self = setmetatable({},FontLoader)
+ local family = fonts[familyname]
+ --[[ for _, record in pairs(fontbase.mappings) do
+ if record.familyname == familyname then
+ local style = record.sanitized.subfamily
+ family[style] = record
+ end
+ end
+ --]]
+ self.family = family
+ return self
+end
+FontLoader.get_path =function(self,style)
+ local rec = self.family[style]
+ local filename = rec.filename
+ if type(filename) == "table" then
+ filename = filename[1]
+ end
+ return kpse.find_file(filename,'opentype fonts') or kpse.find_file(filename,'truetype fonts')
+end
+
+
+FontLoader.list = function(self)
+ for style,rec in pairs(self.family) do
+ print(style, self:get_path(style))
+ end
+end
+
+
+local FontNames = {}
+FontNames.__index = FontNames
+
+FontNames.new = function()
+ self = setmetatable({},FontNames)
+ self.names = {}
+ return self
+end
+
+FontNames.add_family = function(self,properties)
+ local properties = properties or {}
+ return function(names)
+ local names = names or {}
+ for _,n in pairs(names) do
+ self.names[n] = properties
+ end
+ end
+end
+
+FontNames.list = function(self)
+ for name,prop in pairs(self.names) do
+ local p = {}
+ for k,v in pairs(prop) do
+ table.insert(p,k..'='..v)
+ end
+ print(name, table.concat(p))
+ end
+end
+
+--[[
+local fontnames = {}
+for fontname,_ in pairs(fonts) do
+ local lowername = unicode.utf8.lower(fontname)
+ if lowername:find(search) then
+ table.insert(fontnames, fontname)
+ end
+end
+
+table.sort(fontnames)
+--for fontname, styles in pairs (fonts) do
+for _, name in pairs(fontnames) do
+ local fontname = name
+ local styles = fonts[fontname]
+ local t = {}
+ for n,_ in pairs(styles) do table.insert(t,n) end
+ print(fontname, table.concat(t,', '))
+end
+--]]
+
+local testfont = FontLoader.load_family("math")
+--testfont:list()
+
+local n= FontNames.new()
+n:add_family {type = "serif", name = "LMMono10"} {"cmr"}
+n:add_family {type = "serif", name = "TeXGyreTermes"} {"ts1-qtmr", "ec-qtmr","ec-qtmri"}
+--n:list()
+
+return {FontLoader = FontLoader, FontNames = n}
diff --git a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht
new file mode 100644
index 00000000000..e7d75821123
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht
@@ -0,0 +1,113 @@
+%\typeout{!!!!!!!!!!!!!!!!!!!!!!!!!!!epub3!!!!!!!!!!!!}
+\Configure{NcxDoctype}{}
+\Configure{VERSION}{}
+
+% we must remove attributes from opf namespace
+\def\print:opf:scheme#1{}
+\Configure{OpfScheme}{}
+
+\Configure{OpfMetadata}{\HCode{<meta property="dcterms:modified">}\:iso:date\HCode{</meta>}}
+
+%%%%%%%%%%%%%%%%%%%%%%%
+%% Configure toc nav %%
+%%%%%%%%%%%%%%%%%%%%%%%
+\Configure{tableofcontents}{
+ \a:NavMap
+ \resettoclevels{part,chapter,section,subsection,subsubsection}
+ \navsection{part}{part,chapter,section,subsection,subsubsection}
+ \navsection{chapter}{chapter,section,subsection,subsubsection}
+ \navsection{section}{section,subsection,subsubsection}
+ \navsection{subsection}{subsection,subsubsection}
+ \navsection{subsubsection}{subsubsection}
+ %\HtmlParOff
+ \Configure{toTocLink}{}{}
+}{\b:NavMap}{}{}{}
+%%%%%%%%%%%
+\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}%
+ \ifbool{tocnoempty}{}{\HCode{<li><a href="\jobname.\:html">Document</a></li>}}
+ \HCode{</ol></nav>}}
+%%%%%%%%%%%
+\Configure{NavSection}{%
+ \booltrue{tocnoempty}
+ \HCode{<li>}\setbox0=\hbox\bgroup}{\HCode{<ol>\Hnewline}}{\egroup}{\Tg</ol>\Tg</li>}
+%%%% End toc nav configuration
+\def\CoverMetadata#1{%
+\special{t4ht+@File: #1}%
+\Configure{OpfManifest}{\HCode{<item id="cover-image" properties="cover-image" href="#1" media-type="\a:CoverMimeType" />}}%
+}
+%\Configure{CoverImage}{%
+% \HPage{}%
+% \Configure{OpfManifest}{\HCode{<item id="cover-image" properties="cover-image" href="}\CoverImageName\HCode{" media-type="\a:CoverMimeType" />}}%
+ %\box0=\hbox\bgroup
+% \ifvmode \IgnorePar\fi \EndP%
+% \HCode{<section epub:type="cover">\Hnewline}}
+%}
+% {%\ifvmode \IgnorePar\fi \EndP%
+ %\HCode{</section>\Hnewline}%
+ %\EndHPage{}
+ %\egroup
+%}
+%\:CheckOption{mathml}
+%\if:Option
+\apptocmd{\a:DviMath}{\opf:registerfilename{\FileName}\opf:add:property{mathml}}{}{}
+%\fi
+\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
+\Configure{xmlns}{}{http://www.w3.org/1999/xhtml}
+\Configure{xmlns}{epub}{http://www.idpf.org/2007/ops}
+%\Configure{xmlns}{m}{http://www.w3.org/1998/Math/MathML}
+%\Configure{HTML}{\HCode{<html\t4ht:xmlns lang=\"}\GetLanguage\HCode{">\Hnewline}}{\HCode{\Hnewline</html>}}
+\Configure{HTML}{\HCode{<html\t4ht:xmlns lang="}\NoFonts\GetLanguage\EndNoFonts
+\HCode{">\Hnewline}}{\HCode{\Hnewline</html>}}
+\Configure{@HEAD}{}
+\Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
+\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
+ (http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
+\Configure{@HEAD}{\HCode{<link
+ rel="stylesheet" type="text/css"
+ href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}
+\Configure{EpubVersion}{3.0}
+\Configure{OpfItemProperties}{properties="}{"}
+
+% Structural elements
+
+% Foootnote configuration for epub3
+% Footnotes are printed directly after the paragraph they appeared in
+% footnotebox - configure box in which footnotes are printed
+% default configuration doesn't work in ibooks, don't know why
+\NewConfigure{footnotebox}{2}
+\Configure{footnotebox}{\HCode{<section epub:type="footnotes" class="footnotes">\Hnewline}}
+{\HCode{\Hnewline</section>\Hnewline}}
+\newbox\footnotebox
+% We must create new link command, so footnote mark can link to footnote text
+\LinkCommand\fnlink{aside,href,id,class="footnote" epub:type="footnote"}
+\Configure{footnotemark}{\NoFonts\Link[ epub:type="noteref"]{fn\FNnum x\minipageNum}{}}{\EndLink\EndNoFonts}
+\Configure{footnotetext}{\global\setbox\footnotebox=\vtop\bgroup\NoFonts%
+ \ifvoid\footnotebox\else\unvbox\footnotebox\fi%
+ \IgnorePar%
+ \bgroup%
+ \fnlink{}{fn\FNnum x\minipageNum}\NoFonts\Tg<p>%
+}{\EndNoFonts}
+{%
+ \HCode{</p>\Hnewline}
+ \Endfnlink\egroup\egroup}%
+
+\def\printfn{%
+ \ifvoid\footnotebox\else%
+ \a:footnotebox%
+ \box\footnotebox%
+ \b:footnotebox%
+ \fi%
+}
+
+% configure HtmlPar to print footnotebox.
+\Configure{HtmlPar}
+{\EndP\HCode{<p class="noindent">}}
+{\EndP\HCode{<p class="indent">}}
+{\HCode{</p>\Hnewline}\printfn}
+{\HCode{</p>\Hnewline}\printfn}
+
+\Css{.footnote{font-size:small;}}
+\Css{.footnotes hr{width:30\%;margin:0 auto 0 0;}}
diff --git a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht
new file mode 100644
index 00000000000..81d137a8abb
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht
@@ -0,0 +1,404 @@
+%\NewConfigure{ncxtable}{}
+
+%Configure date meta info
+\def\:zeropadtwo#1{%
+ \ifnum #1<10 0\fi
+ #1% Then output the argument
+}% --- \zeroPadTwo ---
+\def\time:round:corr{\ifnum\the\numexpr\the\time-\the\time/60*60\relax<0 1\else 0\fi}
+\def\:iso:date{%
+ \the\year-%
+ \:zeropadtwo{\the\month}-%
+ \:zeropadtwo{\the\day}%
+ %Timestamp will be zero seconds
+ T\:zeropadtwo{\the\numexpr(\the\time/60)-\time:round:corr\relax}:%
+ \:zeropadtwo{\the\numexpr\the\time-((\the\time/60)-\time:round:corr)*60\relax}:%
+ 00Z}
+
+%General configuration
+\Configure{DOCTYPE}{\HCode{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">}}
+
+\NewConfigure{EpubVersion}{1}
+\Configure{EpubVersion}{2.0}
+
+\NewConfigure{UniqueIdentifier}{1}
+\Configure{UniqueIdentifier}{http://example.com/\jobname}
+
+
+\NewConfigure{OpfScheme}{1}
+\Configure{OpfScheme}{URI}
+
+\NewConfigure{OpfMetadata}[1]{
+ \ifx\relax#1\relax%
+ \edef\a:OpfMetadata{}
+ \else
+ \edef\a:OpfMetadata{\a:OpfMetadata\HCode{\Hnewline}#1}
+ \fi
+}
+\Configure{OpfMetadata}{}
+
+% This commands add filenames to opf item list and spine
+\edef\opf:htmlfiles{}
+\newcount\opf:htmlid
+\def\opf:registerfilename#1{%
+ \ifcsdef{opf:entry#1}{}{%
+ \global\advance\opf:htmlid by1\relax
+ %\ifcsdef{opf:entry#1}{}{\csxdef{opf:entry#1}{Neni opf}}
+ \csxdef{opf:entry#1}{file\the\opf:htmlid}
+ \xdef\opf:htmlfiles{\opf:htmlfiles, #1}
+ }
+}
+
+\newcommand\OpfRegisterFile[1][\FileName]{\opf:registerfilename{#1}}
+
+\NewConfigure{OpfManifest}[1]{%
+ \ifx\relax#1\relax%
+ \edef\a:OpfManifest{}
+ \else
+ \edef\a:OpfManifest{\a:OpfManifest\HCode{\Hnewline}#1}
+ \fi
+}
+\Configure{OpfManifest}{}
+
+% This is for add properties like toc or cover image in opf manifest
+% Property must be added from document usinf \opf:add:property, current output filename is used
+\NewConfigure{OpfItemProperties}{2}
+\Configure{OpfItemProperties}{}{}
+\def\opf:properties#1{%
+\ifcsdef{opf:properties:#1}{
+\a:OpfItemProperties\csuse{opf:properties:#1}\b:OpfItemProperties%
+}{}%
+}
+\def\opf:add:property#1{%
+ \ifcsdef{opf:properties:\FileName #1}{}{%
+ \csxdef{opf:properties:\FileName #1}{#1}%
+ \ifcsdef{opf:properties:\FileName}{%
+ \edef\:opf:prop:tmp{\csuse{opf:properties:\FileName}}
+ \csxdef{opf:properties:\FileName}{\:opf:prop:tmp\space #1}
+ }{\csxdef{opf:properties:\FileName}{#1}}
+ }
+}
+
+% enable simple configuration from the .cfg file
+\newcommand\OpfAddProperty[1]{\opf:add:property{#1}}
+
+%Set property only once
+\def\opf:set:property#1{}
+
+% This code will refister \maketitle page to the opf file list
+\let\oldmktl\a:mktl
+\def\a:mktl{\oldmktl\opf:registerfilename{\FileName}}
+
+% guide element is used in epub2, it is similar to epub3 properties
+% in epub3, it is deprecated, but it can be present
+\edef\opf:guide{\HCode{<guide>\Hnewline}}
+
+% register file to the guide. first argument is optional filename, current
+% output name is used when empty. second is title and third type
+
+\NewConfigure{OpfGuide}{4}
+\newcommand\OpfGuide[3][]{%
+ \ifx\relax#1\relax \let\opf:guide:file\FileName\else\def\opf:guide:file{#1}\fi
+ \edef\opf:guide{\opf:guide\a:OpfGuide#3\b:OpfGuide#2\c:OpfGuide\opf:guide:file\d:OpfGuide}
+}
+
+\Configure{OpfGuide}{\HCode{<reference type="}}{\HCode{" title="}}{\HCode{" href="}}{\HCode{" />\Hnewline}}
+
+% is NavMap used anywhere?
+\NewConfigure{NavMap}{2}
+\NewConfigure{NavSection}{4}
+%Interface for setting xmlns
+\edef\t4ht:xmlns{}
+\NewConfigure{xmlns}[2]{%
+ \ifx\relax#2\relax%
+ \edef\t4ht:xmlns{}%
+ \else%
+ %\def\:prefix:xmlns{\ifx\relax#1\relax\else:#1\fi}
+ \edef\t4ht:xmlns{\t4ht:xmlns xmlns\ifx\relax#1\relax\else :#1\fi="#2"}%
+ \fi%
+}
+
+\NewConfigure{CoverImage}{2}
+\Configure{CoverImage}{%
+\ifvmode\IgnorePar\fi\EndP\HCode{<div class="cover-image">\Hnewline}
+}{\HCode{</div>\Hnewline}\par}
+\def\CoverMetadata#1{%
+\special{t4ht+@File: #1}%
+\Configure{OpfMetadata}
+{\HCode{<meta name="cover" content="cover-image" />\Hnewline}}
+\Configure{OpfManifest}
+{\HCode{<item id="cover-image"
+href="#1" media-type="\a:CoverMimeType" />}}
+}
+\renewcommand\coverimage[2][]{%
+\edef\CoverImageName{#2}%
+\CoverMetadata{#2}
+\a:CoverImage%
+\includegraphics[#1]{#2}%
+\b:CoverImage%
+}
+
+\NewConfigure{CoverMimeType}{1}
+\Configure{CoverMimeType}{image/png}
+
+\TocAt-{part,chapter,section,subsection,subsubsection}
+\Configure{crosslinks*}{}
+
+\NewConfigure{NcxDoctype}{1}
+\Configure{NcxDoctype}{\HCode{<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"\Hnewline
+ "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">\Hnewline}}
+
+%Get sanitized value of \title
+%\def\Title{\Ref{TITLE+}}
+% If title contains macros, SafeTitle should be configured
+% in the custom cfg file
+\NewConfigure{SafeTitle}[1]{\gdef\Title{#1}}
+
+% add main html as first file in the OPF
+\opf:registerfilename{\jobname.\:html} %
+\:CheckOption{epub}
+\if:Option
+%\Configure{crosslinks+}{}{}{}{}
+
+% add explicit table of contents to OPF
+\let\old:toc\a:tableofcontents
+\def\a:tableofcontents{\old:toc\OpfRegisterFile}
+
+
+\def\patch:sec:register#1{%
+\csgappto{c:#1}{\OpfRegisterFile}%
+}
+\patch:sec:register{part}
+\patch:sec:register{chapter}
+\patch:sec:register{section}
+\patch:sec:register{subsection}
+\patch:sec:register{subsubsection}
+\patch:sec:register{likechapter}
+\patch:sec:register{likesection}
+\patch:sec:register{likesubsection}
+\patch:sec:register{likesubsubsection}
+
+% Support for SVG isn't ready
+%\Configure{Picture}{.svg}
+\Configure{Picture}{.png}
+\Configure{PicDisplay}
+ {\edef\MathPar{\ifvmode par-\fi}\IgnorePar\endgraf\EndP
+ \HCode{<div class="\MathPar math-display">}}
+ {\HCode{</div>}} {} {class="\MathPar math-display" }
+\Configure{()}{$}{$}
+\fi
+\:CheckOption{kindle} \if:Option
+\Configure{Picture}{.png}
+\fi
+
+%%
+% We must test, it tableofcontents is empty, if yes, we must take special care to navmap
+\newbool{tocnoempty}
+
+\newcount\navpoint
+\def\stepnavpoint{\advance\navpoint by1\relax\the\navpoint}
+
+% define points for breaking section units to html pages
+% we need to break long documents to smaller chunks, because e-readers are
+% generally pretty weak devices
+% use no-cut option if you don't want to break sections, or if you
+% use your own cutting scheme in your .cfg file
+\:CheckOption{no-cut}\if:Option\else
+\ifdef\chapter{%
+ %\CutAt{chapter}\CutAt{likechapter}
+ % copied from tex4ht-html4.tex
+ \CutAt{chapter,likechapter,appendix,part}
+ \CutAt{likechapter,appendix,part}
+ \CutAt{appendix,chapter,likechapter,part}
+}{%
+ %\CutAt{section}\CutAt{likesection}}
+ \CutAt{section,likesection,part}
+ \CutAt{likesection,part}
+
+}
+\fi
+
+% Commands for support of hiearchical table of contents
+% Support for: chapter, section, subsection
+
+\def\resettoclevels#1{%
+ \def\do##1{\csgdef{nav##1finish}{}}
+ \docsvlist{#1}
+}
+\def\usetoclevels#1{%
+ \def\do##1{\csuse{nav##1finish}}%
+ \docsvlist{#1}%
+}
+\def\finishtoclevel#1{%
+ \csgdef{nav#1finish}{\d:NavSection}
+}
+\def\closelevels#1{
+ \usetoclevels{#1}
+ \resettoclevels{#1}
+}
+% 1 - section type 2 - closed sections
+
+\def\navsection#1#2{
+ \ConfigureToc{#1}%
+ {\closelevels{#2}%
+ \a:NavSection\Ncx:Mark}
+ {\c:NavSection}
+ {}
+ {\b:NavSection%
+ \finishtoclevel{#1}%
+ }
+}
+
+% As reported by Nat Kuhn on http://tex.stackexchange.com/q/209312/2891
+% zeroes were printed as section numbers when secnumdepth counter was set to negative value
+% so just strip then out
+% \TitleMark does similar thing, but this solution is simpler, I hope it works correctly
+\def\Ncx:Mark#1{%
+ \edef\:temp{#1}
+ \def\z@ro{0}
+ \ifx\:temp\z@ro\else#1\fi
+}
+
+
+%
+\def\ncx:head{%
+\HCode{<head>\Hnewline}
+\HCode{<meta name="dtb:uid" content="\a:UniqueIdentifier"/>\Hnewline}
+\HCode{<meta name="dtb:depth" content="3"/>\Hnewline}
+\HCode{<meta name="dtb:totalPageCount" content="0"/>\Hnewline}
+\HCode{<meta name="dtb:maxPageNumber" content="0"/>\Hnewline}
+\HCode{</head>\Hnewline}
+}
+
+\def\ncx:title{%
+ \HCode{<docTitle>\Hnewline<text>}\Title\HCode{</text>\Hnewline</docTitle>\Hnewline}
+}
+
+% Get filename from tableofcontents anchor
+\def\ncx:hfile#1{\Ref{)F\Ref{)Q#1}F-}}
+
+\def\:tempa{%
+\EndP
+\HtmlParOff
+\setcounter{tocdepth}{3}
+\special{t4ht>\jobname.ncx}
+% We don't want crosslinks in xml
+% Basic sctructure of the ncx file
+\NoFonts
+{\HCode{<?xml version="1.0"?>\Hnewline}}
+{\a:NcxDoctype}
+{\Tg<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">}{}
+% To print document map, we customize the tableofcontents. We don't want TOC title,
+% so:
+\let\contentsname=\empty
+\Configure{tableofcontents}{\boolfalse{tocnoempty}\Tg<navMap>}{%
+ \usetoclevels{part,chapter,likechapter,section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}%
+ \ifbool{tocnoempty}{}%
+ {\HCode{<navPoint id="mainentry" playOrder=1>
+ <navLabel><text>Document</text></navLabel>
+ <content src="\jobname.\:html" />
+ </navPoint>}}%
+ \Tg</navMap>}{}{}{}
+% We need to configure TocLink
+% in navmapsrc is link to the file and anchor, where chapter or section is located
+\def\navmapsrc{}
+\Configure{TocLink}{\def\navmapsrc{\ncx:hfile{##2}\:sharp ##2}\opf:registerfilename{\ncx:hfile{##2}}##4}
+% Configuraion of entries
+\resettoclevels{part,chapter,section,subsection,subsubsection}
+\navsection{part}{part,chapter,likechapter,section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}
+\navsection{chapter}{chapter,likechapter,section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}
+\navsection{likechapter}{chapter,likechapter,section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}
+\navsection{section}{section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}
+\navsection{likesection}{section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}
+\navsection{subsection}{subsection,likesubsection,subsubsection,likesubsubsection}
+\navsection{likesubsection}{subsection,likesubsection,subsubsection,likesubsubsection}
+\navsection{subsubsection}{subsubsection,likesubsubsection}
+\navsection{likesubsubsection}{subsubsection,likesubsubsection}
+ \HtmlParOff
+ \Configure{toTocLink}{}{}
+ \Configure{NavSection}{\booltrue{tocnoempty}\HCode{\Hnewline<navPoint id="navPoint-}%
+ \stepnavpoint\HCode{" playOrder="}%
+ \the\navpoint\HCode{">\Hnewline<navLabel>\Hnewline<text>}%
+}{\HCode{</text>\Hnewline%
+ </navLabel>\Hnewline}%
+ \HCode{<content src="\navmapsrc" />}%
+}{ }{\HCode{</navPoint>\Hnewline}}
+% Meta inf
+\ncx:head
+% Book title
+\ncx:title
+\tableofcontents%[part,chapter,likechapter,section,likesection,subsection,likesubsection]%
+%Hack to get close tag working
+\HCode{</ncx>}
+\EndNoFonts
+\special{t4ht<\jobname.ncx}
+ \HtmlParOn
+}
+\let\ncxtable\:tempa
+%\else
+%\fi
+
+\def\print:opf:scheme#1{ opf:scheme="#1"}
+\def\:tempa{%
+\bgroup
+\setcounter{tocdepth}{3}
+% Basic sctructure of the opf file
+\special{t4ht>content.opf}
+\NoFonts
+\HtmlParOff
+{\HCode{<?xml version="1.0"?>\Hnewline}}
+\HCode{<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="dcidid"
+ version="\a:EpubVersion">\Hnewline}
+{\HCode{<metadata\Hnewline xmlns:dc="http://purl.org/dc/elements/1.1/"\Hnewline xmlns:opf="http://www.idpf.org/2007/opf">\Hnewline}}
+{\HCode{<dc:title>}\Title\HCode{</dc:title>\Hnewline}}
+{\HCode{<dc:language>}\GetLanguage\HCode{</dc:language>\Hnewline}}
+%Add interface for such things
+{\HCode{<dc:identifier id="dcidid" \print:opf:scheme\a:OpfScheme>\a:UniqueIdentifier}\HCode{</dc:identifier>\Hnewline}}
+\def\and{<\HCode{/dc:creator>\Hnewline<dc:creator>}}
+{\HCode{<dc:creator>}\Author\HCode{</dc:creator>\Hnewline}}
+%{\HCode{<dc:contributor>\HP:file</dc:contributor>\Hnewline}}
+{\HCode{<dc:date>}\:iso:date\HCode{</dc:date>}}
+\a:OpfMetadata
+\Tg</metadata>
+% To print document map, we customize the tableofcontents. We don't want TOC title,
+% so:
+\let\contentsname=\empty
+%\Configure{tableofcontents}{\Tg<navMap>}{\usetoclevels{part,chapter,section,subsection,subsubsection}\Tg</navMap>}{}{}{}
+% We need to configure TocLink
+% in navmapsrc is link to the file and anchor, where chapter or section is located
+\def\navmapsrc{}
+\HCode{\Hnewline<manifest>\Hnewline}
+\HCode{<item id="ncx" href="\jobname.ncx" media-type="application/x-dtbncx+xml" />\Hnewline}
+\HCode{<item id="stylesheet" href="\jobname.css" media-type="text/css"/>\Hnewline}
+\renewcommand\do[1]{\HCode{<item id="\csuse{opf:entry##1}" \opf:properties{##1} href="##1" media-type="application/xhtml+xml" />\Hnewline}}
+\expandafter\docsvlist\expandafter{\opf:htmlfiles}
+\a:OpfManifest
+%\Tg<manifest>
+\special{t4ht<content.opf}
+\special{t4ht>content-part2.opf}
+\HCode{</manifest>\Hnewline}
+\renewcommand\do[1]{\HCode{<itemref idref="\csuse{opf:entry##1}" />\Hnewline}}
+\HCode{\Hnewline<spine toc="ncx">\Hnewline}
+\expandafter\docsvlist\expandafter{\opf:htmlfiles}
+% Next line is pattern to be replaced by lua code
+\HCode{\Hnewline$\string{spine\string}\Hnewline}
+\HCode{</spine>\Hnewline}
+% insert guide
+\opf:guide
+\HCode{</guide>}
+% Hack to get close tag working
+\HCode{</package>}
+\special{t4ht<content-part2.opf}
+\HtmlParOn
+\EndNoFonts
+\egroup
+%Hack!!
+%\Configure{BODY}{}{\Tg</body>}
+%\Configure{HTML}{}{\HCode{\Hnewline</html>\Hnewline}}%<!-- -->\Hnewline}}
+}
+\let\opftable\:tempa
+
+\:CheckOption{epub3}
+\if:Option
+\input tex4ebook-epub3.4ht
+\fi
diff --git a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.sty b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.sty
new file mode 100644
index 00000000000..965a470bac5
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.sty
@@ -0,0 +1,113 @@
+\ProvidesPackage{tex4ebook}
+\RequirePackage{etoolbox}
+\RequirePackage{kvoptions}
+\RequirePackage{graphicx}
+% Command for generating NCX file. Hard work is odne in the file
+% tex4ebook.4ht
+\def\ncxtable{}
+% Command for generating OPF file
+\def\opftable{}
+
+%Declare RFC3066 language code for babel language name
+\def\DeclareLanguage#1#2{%
+\csgdef{rfclang#1}{#2}%
+}
+\def\GetLanguage{%
+\ifx\bbl@main@language\@undefined en-US%
+\else%
+\ifcsdef{rfclang\bbl@main@language}{\csuse{rfclang\bbl@main@language}}{}%
+\fi%
+}
+
+\DeclareLanguage{english}{en-US}
+\DeclareLanguage{czech}{cs-CZ}
+\DeclareLanguage{french}{fr}
+\DeclareLanguage{polish}{pl-PL}
+\DeclareLanguage{german}{de}
+\DeclareLanguage{bulgarian}{bg}
+\DeclareLanguage{catalan}{ca}
+\DeclareLanguage{croatian}{hr}
+\DeclareLanguage{danish}{da}
+\DeclareLanguage{dutch}{nl}
+\DeclareLanguage{USenglish}{en-US}
+\DeclareLanguage{american}{en-US}
+\DeclareLanguage{UKenglish}{en-GB}
+\DeclareLanguage{british}{en-GB}
+\DeclareLanguage{canadian}{en-US}
+\DeclareLanguage{australian}{en-US}
+\DeclareLanguage{newzealand}{en-US}
+\DeclareLanguage{esperanto}{eo}
+\DeclareLanguage{estonian}{et}
+\DeclareLanguage{finnish}{f\/i}
+\DeclareLanguage{francais}{fr}
+\DeclareLanguage{canadien}{fr}
+\DeclareLanguage{acadian}{fr}
+\DeclareLanguage{galician}{gl}
+\DeclareLanguage{austrian}{de}
+\DeclareLanguage{german}{de}
+\DeclareLanguage{germanb}{de}
+\DeclareLanguage{ngerman}{de}
+\DeclareLanguage{naustrian}{de}
+\DeclareLanguage{greek}{el}
+\DeclareLanguage{polutonikogreek}{el}
+\DeclareLanguage{hebrew}{he}
+\DeclareLanguage{magyar}{hu}
+\DeclareLanguage{hungarian}{hu}
+\DeclareLanguage{icelandic}{is}
+\DeclareLanguage{interlingua}{ie}
+\DeclareLanguage{irish}{ga}
+\DeclareLanguage{italian}{it}
+\DeclareLanguage{latin}{la}
+%\DeclareLanguage{lowersorbian}{no code?}
+%\DeclareLanguage{samin}{no code?}
+\DeclareLanguage{norsk}{no}
+\DeclareLanguage{nynorsk}{no}
+\DeclareLanguage{portuges}{pt}
+\DeclareLanguage{portuguese}{pt}
+\DeclareLanguage{brazilian}{pt}
+\DeclareLanguage{brazil}{pt}
+\DeclareLanguage{romanian}{ro}
+\DeclareLanguage{russian}{ru}
+%\DeclareLanguage{scottish}{no code?}
+\DeclareLanguage{spanish}{es}
+\DeclareLanguage{slovak}{sk}
+\DeclareLanguage{slovene}{sl}
+\DeclareLanguage{swedish}{sv}
+\DeclareLanguage{serbian}{sr}
+\DeclareLanguage{turkish}{tr}
+\DeclareLanguage{ukrainian}{uk}
+%\DeclareLanguage{uppersorbian}{no code?}
+\DeclareLanguage{welsh}{cy}
+
+\AtEndDocument{%
+\ncxtable
+\opftable
+}
+
+% Default empty values
+\def\Title{Unnamed}
+\def\Author{Anonymous}
+
+% We need to save values of title, author etc.
+%\AtBeginDocument{
+\let\origtitle\title
+\renewcommand\title[1]{%
+ \origtitle{#1}
+ \let\Title\@title
+}
+
+\let\origauthor\author
+\renewcommand\author[1]{%
+ \origauthor{#1}%
+ \let\Author\@author
+}
+%\let\Author\@author
+\let\Date\today
+\let\origdate\date
+\renewcommand\date[1]{%
+ \origdate{#1}%
+ \let\Date\@date%
+}
+%}
+
+\newcommand\coverimage[2][]{\includegraphics[#1]{#2}}
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index 01db7d7c76c..a724ea67e93 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -527,7 +527,7 @@ my @TLP_working = qw(
tensor termcal termlist termmenu testhyphens teubner
tex-ewd tex-font-errors-cheatsheet tex-gyre tex-gyre-math
tex-label tex-overview tex-ps tex-refs tex-virtual-academy-pl
- texapi texbytopic texcount
+ tex4ebook texapi texbytopic texcount
texdef texdiff texdirflatten texdraw texfot texilikechaps texilikecover
texliveonfly texloganalyser texlogos texmate texments
texpower texshade
diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds
index 79129c18ef4..1eaa839d591 100755
--- a/Master/tlpkg/libexec/ctan2tds
+++ b/Master/tlpkg/libexec/ctan2tds
@@ -2585,6 +2585,7 @@ $standardttf = '\.ttf|\.TTC';
'placeat' => '\.lua$',
'pythontex' => '([23]|_.*)\.py$',
'spelling' => '\.lua$',
+ 'tex4ebook' => '\.lua$',
);
diff --git a/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc
index e17312fc9ab..1241e586095 100644
--- a/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc
@@ -63,6 +63,7 @@ depend pythontex
depend seetexk
depend sty2dtx
depend synctex
+depend tex4ebook
depend texcount
depend texdef
depend texdiff
diff --git a/Master/tlpkg/tlpsrc/tex4ebook.tlpsrc b/Master/tlpkg/tlpsrc/tex4ebook.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/tex4ebook.tlpsrc