diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/support/tex4ebook/README | 7 | ||||
-rw-r--r-- | Master/texmf-dist/doc/support/tex4ebook/changelog.tex | 29 | ||||
-rw-r--r-- | Master/texmf-dist/doc/support/tex4ebook/readme.tex | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf | bin | 83506 -> 84685 bytes | |||
-rwxr-xr-x | Master/texmf-dist/scripts/tex4ebook/tex4ebook | 2 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_azw.lua | 17 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_azw3.lua | 20 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_mobi.lua | 38 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht | 29 |
9 files changed, 126 insertions, 24 deletions
diff --git a/Master/texmf-dist/doc/support/tex4ebook/README b/Master/texmf-dist/doc/support/tex4ebook/README index f87bd02f422..d19ca44e1bc 100644 --- a/Master/texmf-dist/doc/support/tex4ebook/README +++ b/Master/texmf-dist/doc/support/tex4ebook/README @@ -297,6 +297,13 @@ See the `make4ht` documentation for an example and more information. # Troubleshooting +## Kindle formats + +`tex4ebook` uses `kindlegen` command for the conversion to Kindle formats (`mobi`, +`azw` and `azw3`). Unfortunatelly, Amazon discontinued this command, so we use +also `ebook-convert` provided by Calibre if `kindlegen` fails. + + ## Fixed layout EPUB The basic support for the Fixed layout EPUB 3 can be enabled using the following configurations: diff --git a/Master/texmf-dist/doc/support/tex4ebook/changelog.tex b/Master/texmf-dist/doc/support/tex4ebook/changelog.tex index f415f81c8c2..8c9445b9106 100644 --- a/Master/texmf-dist/doc/support/tex4ebook/changelog.tex +++ b/Master/texmf-dist/doc/support/tex4ebook/changelog.tex @@ -3,6 +3,35 @@ \begin{itemize} \item + 2021/09/30 + + \begin{itemize} + \tightlist + \item + released version \texttt{0.3e} + \item + better detection if \texttt{kindlegen} was found. + \end{itemize} +\item + 2021/09/23 + + \begin{itemize} + \tightlist + \item + use \texttt{ebook-convert} for convertsion to Kindle formats if + \texttt{kindlegen} fails. + \end{itemize} +\item + 2021/08/22 + + \begin{itemize} + \tightlist + \item + fixed + \href{https://tex.stackexchange.com/a/611611/2891}{cross-referencing + issue} related to unnumbered equations. + \end{itemize} +\item 2021/07/26 \begin{itemize} diff --git a/Master/texmf-dist/doc/support/tex4ebook/readme.tex b/Master/texmf-dist/doc/support/tex4ebook/readme.tex index 428ac6c68ca..99853b4d392 100644 --- a/Master/texmf-dist/doc/support/tex4ebook/readme.tex +++ b/Master/texmf-dist/doc/support/tex4ebook/readme.tex @@ -352,6 +352,14 @@ information. \hypertarget{troubleshooting}{% \section{Troubleshooting}\label{troubleshooting}} +\hypertarget{kindle-formats}{% +\subsection{Kindle formats}\label{kindle-formats}} + +\texttt{tex4ebook} uses \texttt{kindlegen} command for the conversion to +Kindle formats (\texttt{mobi}, \texttt{azw} and \texttt{azw3}). +Unfortunatelly, Amazon discontinued this command, so we use also +\texttt{ebook-convert} provided by Calibre if \texttt{kindlegen} fails. + \hypertarget{fixed-layout-epub}{% \subsection{Fixed layout EPUB}\label{fixed-layout-epub}} diff --git a/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf b/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf Binary files differindex 170a8fc4f1c..62a87cd2507 100644 --- a/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf +++ b/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf diff --git a/Master/texmf-dist/scripts/tex4ebook/tex4ebook b/Master/texmf-dist/scripts/tex4ebook/tex4ebook index 2b2b38b1133..5c6aca5546e 100755 --- a/Master/texmf-dist/scripts/tex4ebook/tex4ebook +++ b/Master/texmf-dist/scripts/tex4ebook/tex4ebook @@ -67,7 +67,7 @@ else end if args.version then - print "tex4ebook v0.3d" + print "tex4ebook v0.3e" return end diff --git a/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_azw.lua b/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_azw.lua index 397292b648b..ebf8d341446 100755 --- a/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_azw.lua +++ b/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_azw.lua @@ -1,5 +1,6 @@ module(...,package.seeall) local eb = require("tex4ebook-exec_epub") +local mobi = require("tex4ebook-exec_mobi") local ebookutils = require("mkutils") local log = logging.new "exec_azw" @@ -19,13 +20,15 @@ function writeContainer() -- find the azw filename local azwfile = eb.outputfile:gsub("epub$", "azw") local azwdist = eb.destdir .. azwfile - local command = "kindlegen " .. epubpath .. " -o " .. azwfile - log:info("Pack azw ".. command) - local status, output = ebookutils.execute(command) - -- copy the azw file to the destination directory - -- the destination directory will be created by the epub writer, so it is possible to use - -- the cp function which doesn't try to create directory - ebookutils.cp(eb.basedir .. "/" .. azwfile, azwdist) + local status = mobi.kindlegen(epubpath, azwfile) + if status then + -- copy the azw file to the destination directory + -- the destination directory will be created by the epub writer, so it is possible to use + -- the cp function which doesn't try to create directory + if azwfile ~= azwdist then + ebookutils.cp(azwfile, azwdist) + end + end return ret end diff --git a/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_azw3.lua b/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_azw3.lua index 33e8a1182c5..36c537f7eeb 100755 --- a/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_azw3.lua +++ b/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_azw3.lua @@ -1,5 +1,6 @@ module(...,package.seeall) local eb = require("tex4ebook-exec_epub") +local mobi = require("tex4ebook-exec_mobi") local ebookutils = require("mkutils") local log = logging.new "exec_azw" @@ -19,13 +20,18 @@ function writeContainer() -- find the azw filename local azwfile = eb.outputfile:gsub("epub$", "azw3") local azwdist = eb.destdir .. azwfile - local command = "kindlegen " .. epubpath .. " -o " .. azwfile - log:info("Pack azw ".. command) - local status, output = ebookutils.execute(command) - -- copy the azw file to the destination directory - -- the destination directory will be created by the epub writer, so it is possible to use - -- the cp function which doesn't try to create directory - ebookutils.cp(eb.basedir .. "/" .. azwfile, azwdist) + -- local command = "kindlegen " .. epubpath .. " -o " .. azwfile + -- log:info("Pack azw ".. command) + -- local status, output = ebookutils.execute(command) + local status = mobi.kindlegen(epubpath, azwfile) + if status then + -- copy the azw file to the destination directory + -- the destination directory will be created by the epub writer, so it is possible to use + -- the cp function which doesn't try to create directory + if azwfile ~= azwdist then + ebookutils.cp(azwfile, azwdist) + end + end return ret end diff --git a/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_mobi.lua b/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_mobi.lua index 92b70af71c3..828baeba4ae 100755 --- a/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_mobi.lua +++ b/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_mobi.lua @@ -11,22 +11,46 @@ function run(out,params) return eb.run(out, params) end +function kindlegen(source, outputfile) + -- try to run kindlegen first + local command = "kindlegen " .. source .. " -o " .. outputfile + local status, output = ebookutils.execute(command) + log:debug("running kindlegen: " .. command, status) + -- if we cannot find kindlegen, try ebook-convert + if not output:match("Amazon") then + log:debug("kindlegen failed, trying epub-convert") + local ebookcmd = "ebook-convert " .. source .. " " .. outputfile + status, output = ebookutils.execute(ebookcmd) + if status > 0 then + log:error("Conversion to the output format failed") + log:error("Do you have either kindlegen or ebook-convert installed?") + return false + end + end + return true +end + function writeContainer() local ret = eb.writeContainer() -- convert the epub file to mobi local epubpath = eb.basedir .. "/" .. eb.outputfile - log:info("Pack mobi "..os.execute("kindlegen " .. epubpath)) -- find the mobi filename - local mobifile = epubpath:gsub("epub$", "mobi") + local mobifile = eb.outputfile:gsub("epub$", "mobi") local mobidist = eb.destdir .. eb.outputfile:gsub("epub$", "mobi") - -- copy the mobi file to the destination directory - -- the destination directory will be created by the epub writer, so it is possible to use - -- the cp function which doesn't try to create directory - ebookutils.cp(mobifile, mobidist) - + log:info("Convert Epub to mobi") + local status = kindlegen(epubpath, mobifile) + if status then + -- copy the mobi file to the destination directory + -- the destination directory will be created by the epub writer, so it is possible to use + -- the cp function which doesn't try to create directory + if mobifile ~= mobidist then + ebookutils.cp(mobifile, mobidist) + end + end return ret end function clean() return eb.clean() end + diff --git a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht index 01324639175..7cd6ca39fe4 100644 --- a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht +++ b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht @@ -318,7 +318,27 @@ href="#1" media-type="\a:CoverMimeType" />}} } % Get filename from tableofcontents anchor -\def\ncx:hfile#1{\Ref{)F\Ref{)Q#1}F-}} +\def\ncx:hfile#1{\LikeRef{)F\LikeRef{)Q#1}F-}} + +\ExplSyntaxOn +% get filename for the section label +% sometimes, TeX4ht returns list of file numbers for label. we must use just +% the first number. we use the LaTeX 3 sequence list to get it. +\tl_new:N\ncx:hfilename +\def\ncx:newhfile#1{ + \cs_if_exist_use:cTF{cw:)Q#1}{% + % cw:)Q#1 is csname of tag from the xref file. we convert it to sequence + \seq_set_from_clist:Nc\l_tmpa_seq{cw:)Q#1} + % get first item and put it to a token list + \seq_get_left:NN \l_tmpa_seq \l_tmpa_tl + % \RefFileNumber returns file name for the given file number + % \ncx:hfilename contains the filename for later use + \tl_set:Nx \ncx:hfilename {\RefFileNumber{\l_tmpa_tl}} + }{% + \tl_set:Nn \ncx:hfilename {nic} + } +} +\ExplSyntaxOff % define toc levels which should be included in the NCX file \NewConfigure{resettoclevels}{1} @@ -349,7 +369,12 @@ href="#1" media-type="\a:CoverMimeType" />}} % 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} + \Configure{TocLink}{% + \ncx:newhfile{##2} + \def\navmapsrc{\ncx:hfilename\:sharp ##2} + \opf:registerfilename{\ncx:hfilename} + ##4 + } % Configuraion of entries \expandafter\resettoclevels\expandafter{\a:resettoclevels}% \confnavsections% |