summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-03-21 20:57:24 +0000
committerKarl Berry <karl@freefriends.org>2019-03-21 20:57:24 +0000
commita5de2c33c167bd9438ec901fd013cbd3ded17861 (patch)
treed5153925188fec09cf1a15f83b658bccc89b1cbb
parent042522d56eecc50b11be37d5284fc43d2a6b51fe (diff)
tex4ebook (21mar19)
git-svn-id: svn://tug.org/texlive/trunk@50512 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xBuild/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook2
-rw-r--r--Master/texmf-dist/doc/support/tex4ebook/README12
-rw-r--r--Master/texmf-dist/doc/support/tex4ebook/changelog.tex36
-rw-r--r--Master/texmf-dist/doc/support/tex4ebook/readme.tex18
-rw-r--r--Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdfbin72222 -> 73368 bytes
-rw-r--r--Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.tex1
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/exec_epub.lua41
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/exec_epub3.lua4
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/tex4ebook2
-rw-r--r--Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht9
10 files changed, 96 insertions, 29 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook b/Build/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook
index 9e396ffc3f8..a95bf44c236 100755
--- a/Build/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook
+++ b/Build/source/texk/texlive/linked_scripts/tex4ebook/tex4ebook
@@ -66,7 +66,7 @@ else
end
if args.version then
- print "tex4ebook v0.2b"
+ print "tex4ebook v0.2c"
return
end
diff --git a/Master/texmf-dist/doc/support/tex4ebook/README b/Master/texmf-dist/doc/support/tex4ebook/README
index 228fe58df6f..951dad5a573 100644
--- a/Master/texmf-dist/doc/support/tex4ebook/README
+++ b/Master/texmf-dist/doc/support/tex4ebook/README
@@ -152,19 +152,25 @@ or *setting image size in em units instead of pt*^[http://tex.stackexchange.com/
Every epub file should have unique identifier, like ISBN, DOI, URI etc.
Default identifier is URI, with value `http://example.com/\jobname`.
+ \Configure{@author}{\let\footnote\@gobble}
+
+Local definitions of commands used in the `\author` command. As contents of
+`\author` are used in XML files, it is necessary to strip away any information
+which don't belongs here, such as `\footnote`.
+
\Configure{OpfScheme}{URI}
Type of unique identifier, default type is URI. It is
-used only in epub, it is deprecated for `epub3`
+used only in `epub`, it is deprecated for `epub3`
\Configure{resettoclevels}{list of section types in descending order}
Configure section types which should be included in the `NCX` file. Default
-value is the whole document hiearchy, from `\part` to `\paragraph`.
+value is the whole document hierarchy, from `\part` to `\paragraph`.
\Configure{DocumentLanguage}{language code}
-Each epub must declare the document language. It is inferred from `babel` main
+Each ePub file must declare the document language. It is inferred from `babel` main
language by default, but you can configure it when it doesn't work correctly.
The `language code` should be in [ISO
639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) form.
diff --git a/Master/texmf-dist/doc/support/tex4ebook/changelog.tex b/Master/texmf-dist/doc/support/tex4ebook/changelog.tex
index ebec6ca8175..d7743b1204f 100644
--- a/Master/texmf-dist/doc/support/tex4ebook/changelog.tex
+++ b/Master/texmf-dist/doc/support/tex4ebook/changelog.tex
@@ -3,6 +3,40 @@
\begin{itemize}
\item
+ 2019/03/21
+
+ \begin{itemize}
+ \tightlist
+ \item
+ released version \texttt{0.2c}
+ \end{itemize}
+\item
+ 2019/03/07
+
+ \begin{itemize}
+ \tightlist
+ \item
+ use \texttt{Luatexbase} package in the documentation because of
+ \texttt{Microtype} error
+ \item
+ remove \texttt{\textless{}guide\textgreater{}} element even in ePub
+ 2
+ \item
+ added \texttt{encoding} attribute to XML declaration in the NCX and
+ OPF files
+ \item
+ clean the temporary directory (\texttt{filename-format}) before file
+ packing
+ \end{itemize}
+\item
+ 2019/01/21
+
+ \begin{itemize}
+ \tightlist
+ \item
+ added \texttt{\textbackslash{}Configure\{@author\}}
+ \end{itemize}
+\item
2019/01/10
\begin{itemize}
@@ -25,7 +59,7 @@
\tightlist
\item
use the \texttt{uni-html4} option by default. It will convert some
- math characters as Unicode chars.
+ math characters as Unicode chars
\end{itemize}
\item
13/11/2018
diff --git a/Master/texmf-dist/doc/support/tex4ebook/readme.tex b/Master/texmf-dist/doc/support/tex4ebook/readme.tex
index 75db5437183..2a6110e03fc 100644
--- a/Master/texmf-dist/doc/support/tex4ebook/readme.tex
+++ b/Master/texmf-dist/doc/support/tex4ebook/readme.tex
@@ -166,25 +166,35 @@ Default identifier is URI, with value
\texttt{http://example.com/\textbackslash{}jobname}.
\begin{verbatim}
+\Configure{@author}{\let\footnote\@gobble}
+\end{verbatim}
+
+Local definitions of commands used in the
+\texttt{\textbackslash{}author} command. As contents of
+\texttt{\textbackslash{}author} are used in XML files, it is necessary
+to strip away any information which don't belongs here, such as
+\texttt{\textbackslash{}footnote}.
+
+\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}
+Type of unique identifier, default type is URI. It is used only in
+\texttt{epub}, it is deprecated for \texttt{epub3}
\begin{verbatim}
\Configure{resettoclevels}{list of section types in descending order}
\end{verbatim}
Configure section types which should be included in the \texttt{NCX}
-file. Default value is the whole document hiearchy, from
+file. Default value is the whole document hierarchy, from
\texttt{\textbackslash{}part} to \texttt{\textbackslash{}paragraph}.
\begin{verbatim}
\Configure{DocumentLanguage}{language code}
\end{verbatim}
-Each epub must declare the document language. It is inferred from
+Each ePub file must declare the document language. It is inferred from
\texttt{babel} main language by default, but you can configure it when
it doesn't work correctly. The \texttt{language\ code} should be in
\href{https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes}{ISO 639-1}
diff --git a/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf b/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf
index 42f18620c0a..6c7fd83af08 100644
--- a/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.pdf
+++ 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
index 0486abec3d3..f76c038d2d3 100644
--- a/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.tex
+++ b/Master/texmf-dist/doc/support/tex4ebook/tex4ebook-doc.tex
@@ -8,6 +8,7 @@
\usepackage[utf8]{inputenc}
\author{\href{mailto:michal.h21@gmail.com}{Michal Hoftich}}
\else
+\usepackage{luatexbase}
\usepackage{fontspec}
\setmainfont{TeX Gyre Schola}
\author{Michal Hoftich\footnote{\url{michal.h21@gmail.com}}}
diff --git a/Master/texmf-dist/scripts/tex4ebook/exec_epub.lua b/Master/texmf-dist/scripts/tex4ebook/exec_epub.lua
index 8502f280597..d92a8d103c9 100755
--- a/Master/texmf-dist/scripts/tex4ebook/exec_epub.lua
+++ b/Master/texmf-dist/scripts/tex4ebook/exec_epub.lua
@@ -20,7 +20,26 @@ tidy = false
local include_fonts = false
local metadir=""
-
+-- from https://stackoverflow.com/a/43407750/2467963
+local function deletedir(dir)
+ local attr = lfs.attributes(dir)
+ if attr then
+ for file in lfs.dir(dir) do
+ local file_path = dir..'/'..file
+ if file ~= "." and file ~= ".." then
+ if lfs.attributes(file_path, 'mode') == 'file' then
+ os.remove(file_path)
+ print('remove file',file_path)
+ elseif lfs.attributes(file_path, 'mode') == 'directory' then
+ print('dir', file_path)
+ deletedir(file_path)
+ end
+ end
+ end
+ lfs.rmdir(dir)
+ end
+ print('remove dir',dir)
+end
function prepare(params)
local randname=tostring(math.random(12000))
@@ -42,6 +61,7 @@ function prepare(params)
end
basedir = params.input.."-".. params.format
outputdir= basedir.."/"..outputdir_name --"outdir-"..randname --os.tmpdir()
+ deletedir(basedir)
makedir(outputdir)
-- lfs.mkdir(outputdir)
--ebookutils.mkdirectories(ebookutils.prepare_path(outputdir.."/"))
@@ -131,6 +151,10 @@ local mimetypes = {
smil = "application/smil+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
@@ -183,21 +207,7 @@ function make_opf()
-- the same filename is used in different directories. Is that a problem?
used_files[filename] = true
end
- --[[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 = {}
local used_ids = {}
@@ -263,6 +273,7 @@ function make_opf()
local opf_completed = table.concat(opf_complete,"\n")
-- poor man's tidy: remove trailing whitespace befora xml tags
opf_completed = opf_completed:gsub("[ ]*<","<")
+ opf_completed = remove_empty_guide(opf_completed)
h_first:write(opf_completed)
h_first:close()
os.remove(opf_second_part)
diff --git a/Master/texmf-dist/scripts/tex4ebook/exec_epub3.lua b/Master/texmf-dist/scripts/tex4ebook/exec_epub3.lua
index 56eff3f341c..53173be9e9c 100755
--- a/Master/texmf-dist/scripts/tex4ebook/exec_epub3.lua
+++ b/Master/texmf-dist/scripts/tex4ebook/exec_epub3.lua
@@ -138,7 +138,9 @@ local function cleanOPF()
content = content:gsub("<spine([^>]*)>", "<spine%1>\n<itemref idref=\"htmltoc\" linear=\"no\"/>\n")
-- remove empty guide element
end
- content = content:gsub("<guide>%s*</guide>","")
+ -- content = content:gsub("<guide>%s*</guide>","")
+ content = eb.remove_empty_guide(content)
+
content = add_media_overlays(content)
f = io.open(outputdir .. "/" ..opf,"w")
f:write(content)
diff --git a/Master/texmf-dist/scripts/tex4ebook/tex4ebook b/Master/texmf-dist/scripts/tex4ebook/tex4ebook
index 9e396ffc3f8..a95bf44c236 100755
--- a/Master/texmf-dist/scripts/tex4ebook/tex4ebook
+++ b/Master/texmf-dist/scripts/tex4ebook/tex4ebook
@@ -66,7 +66,7 @@ else
end
if args.version then
- print "tex4ebook v0.2b"
+ print "tex4ebook v0.2c"
return
end
diff --git a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht
index 82d03df3100..e4233fc55a4 100644
--- a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht
+++ b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht
@@ -29,6 +29,9 @@
% use this only if it doesn't work
\NewConfigure{DocumentLanguage}[1]{\def\GetLanguage{#1}}
+% definitions of commands ignored in \author
+\def\a:@author{}
+\NewConfigure{@author}[1]{\concat:config\a:@author{#1}}
\NewConfigure{OpfScheme}{1}
\Configure{OpfScheme}{URI}
@@ -319,7 +322,7 @@ href="#1" media-type="\a:CoverMimeType" />}}
% We don't want crosslinks in xml
% Basic sctructure of the ncx file
\NoFonts
-{\HCode{<?xml version="1.0"?>\Hnewline}}
+{\HCode{<?xml version="1.0" encoding="utf-8"?>\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,
@@ -372,7 +375,7 @@ href="#1" media-type="\a:CoverMimeType" />}}
\special{t4ht>content.opf}
\NoFonts
\HtmlParOff
-{\HCode{<?xml version="1.0"?>\Hnewline}}
+{\HCode{<?xml version="1.0" encoding="utf-8"?>\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}}
@@ -381,7 +384,7 @@ href="#1" media-type="\a:CoverMimeType" />}}
%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:creator>}{\a:@author\Author}\HCode{</dc:creator>\Hnewline}}
%{\HCode{<dc:contributor>\HP:file</dc:contributor>\Hnewline}}
{\HCode{<dc:date>}\:iso:date\HCode{</dc:date>}}
\a:OpfMetadata