summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
Diffstat (limited to 'support')
-rw-r--r--support/make4ht/README4
-rw-r--r--support/make4ht/changelog.tex114
-rw-r--r--support/make4ht/domfilters/make4ht-fixinlines.lua30
-rw-r--r--support/make4ht/domfilters/make4ht-mathmlfixes.lua129
-rw-r--r--support/make4ht/domfilters/make4ht-odtfonts.lua26
-rw-r--r--support/make4ht/extensions/make4ht-ext-common_domfilters.lua4
-rw-r--r--support/make4ht/extensions/make4ht-ext-common_filters.lua2
-rw-r--r--support/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua4
-rw-r--r--support/make4ht/extensions/make4ht-ext-join_colors.lua2
-rw-r--r--support/make4ht/extensions/make4ht-ext-mathjaxnode.lua2
-rw-r--r--support/make4ht/extensions/make4ht-ext-mjcli.lua2
-rw-r--r--support/make4ht/extensions/make4ht-ext-odttemplate.lua2
-rw-r--r--support/make4ht/extensions/make4ht-ext-staticsite.lua9
-rw-r--r--support/make4ht/filters/make4ht-staticsite.lua10
-rw-r--r--support/make4ht/formats/make4ht-odt.lua62
-rwxr-xr-xsupport/make4ht/make4ht2
-rw-r--r--support/make4ht/make4ht-doc.pdfbin152668 -> 153809 bytes
-rw-r--r--support/make4ht/make4ht-logging.lua10
-rw-r--r--support/make4ht/make4ht-xtpipes.lua15
-rw-r--r--support/make4ht/mkparams.lua2
-rw-r--r--support/make4ht/readme.tex3
-rw-r--r--support/tex4ebook/changelog.tex37
-rwxr-xr-xsupport/tex4ebook/tex4ebook2
-rw-r--r--support/tex4ebook/tex4ebook-doc.pdfbin85304 -> 85759 bytes
-rw-r--r--support/tex4ebook/tex4ebook-epub3.4ht11
-rw-r--r--support/tex4ebook/tex4ebook-exec_epub3.lua58
-rw-r--r--support/tex4ebook/tex4ebook.4ht2
27 files changed, 477 insertions, 67 deletions
diff --git a/support/make4ht/README b/support/make4ht/README
index 51af04a3fc..bdb5e173c3 100644
--- a/support/make4ht/README
+++ b/support/make4ht/README
@@ -657,6 +657,10 @@ joincolors
substantial growth of the CSS file. This filter replaces these rules with a
common one for elements with the same color value.
+odtfonts
+
+: fix styles for fonts that were wrongly converted by `Xtpipes` in the ODT format.
+
odtimagesize
: set correct dimensions for images in the ODT format. It is no longer used, as the dimensions are set by TeX4ht itself.
diff --git a/support/make4ht/changelog.tex b/support/make4ht/changelog.tex
index 8747cc4bf5..d4a50d29cf 100644
--- a/support/make4ht/changelog.tex
+++ b/support/make4ht/changelog.tex
@@ -3,6 +3,120 @@
\begin{itemize}
\item
+ 2022/02/18
+
+ \begin{itemize}
+ \tightlist
+ \item
+ version \texttt{0.3k} released.
+ \end{itemize}
+\item
+ 2022/02/07
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed support for some fonts in the ODT format.
+ \item
+ added \texttt{odtfonts} DOM filter.
+ \end{itemize}
+\item
+ 2022/01/30
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fix \texttt{mathvariant} attribue of
+ \texttt{\textless{}mi\textgreater{}} elements if they are children
+ of \texttt{\textless{}mstyle\textgreater{}}.
+ \end{itemize}
+\item
+ 2021/12/17
+
+ \begin{itemize}
+ \tightlist
+ \item
+ quote jobname in order to support filenames like \texttt{(xxx).tex}.
+ \end{itemize}
+\item
+ 2021/12/13
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed setting of properties in the \texttt{staticsite} filter.
+ \end{itemize}
+\item
+ 2021/12/06
+
+ \begin{itemize}
+ \tightlist
+ \item
+ in the end, use \texttt{\textless{}mtext\textgreater{}} even for one
+ \texttt{\textless{}mo\textgreater{}} in the \texttt{fix\_operators}
+ function. LO had issues with \texttt{\textless{}mi\textgreater{}}.
+ \end{itemize}
+\item
+ 2021/12/03
+
+ \begin{itemize}
+ \tightlist
+ \item
+ don't add additional \texttt{\textless{}mrow\textgreater{}} elements
+ in the \texttt{mathmlfixes} DOM filter. It caused various issues.
+ \end{itemize}
+\item
+ 2021/12/01
+
+ \begin{itemize}
+ \tightlist
+ \item
+ transform
+ \texttt{\textless{}mn\textgreater{}x\textless{}/mn\textgreater{}\textless{}mo\textgreater{}.\textless{}/mo\textgreater{}\textless{}mn\textgreater{}x\textless{}/mn\textgreater{}}
+ to
+ \texttt{\textless{}mn\textgreater{}x.x\textless{}/mn\textgreater{}}
+ in MathML.
+ \item
+ transform \texttt{\textless{}mo\textgreater{}} elements that are
+ single childs to \texttt{\textless{}mi\textgreater{}} in MathML, and
+ list of consecutive \texttt{\textless{}mo\textgreater{}} elements to
+ \texttt{\textless{}mtext\textgreater{}}. This should fix rendering
+ issues of superscripts in LibreOffice.
+ \item
+ added filter names in extensions to prevent multiple execution of
+ filters.
+ \end{itemize}
+\item
+ 2021/11/29
+
+ \begin{itemize}
+ \tightlist
+ \item
+ make current logging level available outside of the Logging module.
+ \item
+ print Xtpipes and Tidy output if these command fail in the Xtpipes
+ module.
+ \end{itemize}
+\item
+ 2021/11/18
+
+ \begin{itemize}
+ \tightlist
+ \item
+ don't put \texttt{\textless{}mrow\textgreater{}} as children of
+ \texttt{\textless{}mrow\textgreater{}} in the \texttt{mathmlfixes}
+ DOM filter.
+ \end{itemize}
+\item
+ 2021/11/04
+
+ \begin{itemize}
+ \tightlist
+ \item
+ more intelligent handling of text and inline elements outside of
+ paragraphs in the \texttt{fixinlines} DOM filter.
+ \end{itemize}
+\item
2021/10/11
\begin{itemize}
diff --git a/support/make4ht/domfilters/make4ht-fixinlines.lua b/support/make4ht/domfilters/make4ht-fixinlines.lua
index d1b11b123e..02338505b7 100644
--- a/support/make4ht/domfilters/make4ht-fixinlines.lua
+++ b/support/make4ht/domfilters/make4ht-fixinlines.lua
@@ -41,15 +41,33 @@ local function fix_inlines(obj)
local settings = get_filter_settings "fixinlines"
local inline_elements = settings.inline_elements or inline_elements
local nodes = obj:get_path("html body")
+ local new = nil
obj:traverse_node_list(nodes, function(jej)
- if jej._type == "ELEMENT" then
- local name = string.lower(jej._name)
+ if jej._type == "ELEMENT" or jej._type == "TEXT" then
+ local name = string.lower(jej._name or "")
-- local parent = jej:get_parent_node()
- if inline_elements[name] then
- local new = obj:create_element("p" )
- new:add_child_node(obj:copy_node(jej))
- jej:replace_node(new)
+ if inline_elements[name] or jej._type == "TEXT" then
+ if not new then
+ -- start new paragraph
+ if jej._type == "TEXT" and jej._text:match("^%s+$") then
+ -- ignore parts that contain only whitespace and are placed before
+ -- paragraph start
+ else
+ new = obj:create_element("p" )
+ new:add_child_node(obj:copy_node(jej))
+ jej:replace_node(new)
+ end
+ else
+ -- paragraph already exists
+ new:add_child_node(obj:copy_node(jej))
+ jej:remove_node()
+ end
+ else
+ -- close the current paragraph before new block element
+ new = nil
end
+ else
+ new = nil
end
end)
return obj
diff --git a/support/make4ht/domfilters/make4ht-mathmlfixes.lua b/support/make4ht/domfilters/make4ht-mathmlfixes.lua
index 42f1e55775..12754bedb9 100644
--- a/support/make4ht/domfilters/make4ht-mathmlfixes.lua
+++ b/support/make4ht/domfilters/make4ht-mathmlfixes.lua
@@ -1,3 +1,4 @@
+local log = logging.new("mathmlfixes")
-- <mglyph> should be inside <mi>, so we don't process it
-- even though it is a token element
local token = {"mi", "mn", "mo", "mtext", "mspace", "ms"}
@@ -37,20 +38,57 @@ local function fix_nested_mstyle(el)
end
end
--- if element contains
--- wrap everything in <mrow>
+local function fix_mathvariant(el)
+ -- set mathvariant of <mi> that is child of <mstyle> to have the same value
+ local function find_mstyle(x)
+ -- find if element has <mstyle> parent, and its value of mathvariant
+ if not x:is_element() then
+ return nil
+ elseif x:get_element_name() == "mstyle" then
+ return x:get_attribute("mathvariant")
+ else
+ return find_mstyle(x:get_parent())
+ end
+ end
+ if el:get_element_name() == "mi" then
+ -- process only <mi> that have mathvariant set
+ local oldmathvariant = el:get_attribute("mathvariant")
+ if oldmathvariant then
+ local mathvariant = find_mstyle(el:get_parent())
+ if mathvariant then
+ el:set_attribute("mathvariant", mathvariant)
+ end
+ end
+ end
+end
+
+-- put <mrow> as child of <math> if it already isn't here
+local allowed_top_mrow = {
+ math=true
+}
local function top_mrow(math)
local children = math:get_children()
local put_mrow = false
-- don't process elements with one or zero children
-- don't process elements that already are mrow
- if #children < 2 or math:get_element_name() == "mrow" then return nil end
+ local parent = math:get_parent()
+ local parent_name
+ if parent then parent_name = parent:get_element_name() end
+ local current_name = math:get_element_name()
+ if #children < 2 or not allowed_top_mrow[current_name] or current_name == "mrow" or parent_name == "mrow" then return nil end
+ local mrow_count = 0
for _,v in ipairs(children) do
if v:is_element() and is_token_element(v) then
put_mrow = true
- break
+ -- break
+ elseif v:is_element() and v:get_element_name() == "mrow" then
+ mrow_count = mrow_count + 1
end
end
+ if not put_mrow and math:get_element_name() == "math" and mrow_count == 0 then
+ -- put at least one <mrow> to each <math>
+ put_mrow = true
+ end
if put_mrow then
local mrow = math:create_element("mrow")
for _, el in ipairs(children) do
@@ -122,6 +160,86 @@ local function fix_mo_to_mfenced(el)
end
end
+local function fix_numbers(el)
+ -- convert <mn>1</mn><mo>.</mo><mn>3</mn> to <mn>1.3</mn>
+ if el:get_element_name() == "mn" then
+ local n = el:get_sibling_node(1)
+ -- test if next element is <mo class="MathClass-punc">.</mo>
+ if n and n:is_element()
+ and n:get_element_name() == "mo"
+ and n:get_attribute("class") == "MathClass-punc"
+ and n:get_text() == "."
+ then
+ -- get next element and test if it is <mn>
+ local x = el:get_sibling_node(2)
+ if x and x:is_element()
+ and x:get_element_name() == "mn"
+ then
+ -- join numbers and set it as text content of the current element
+ local newnumber = el:get_text() .. "." .. x:get_text()
+ log:debug("Joining numbers: " .. newnumber)
+ el._children = {}
+ local newchild = el:create_text_node(newnumber)
+ el:add_child_node(newchild)
+ -- remove elements that hold dot and decimal part
+ n:remove_node()
+ x:remove_node()
+ end
+ end
+ end
+end
+
+
+local function just_operators(list)
+ -- count <mo> and return true if list contains just them
+ local mo = 0
+ for _, x in ipairs(list) do
+ if x:get_element_name() == "mo" then mo = mo + 1 end
+ end
+ return mo
+end
+
+
+local function fix_operators(x)
+ -- change <mo> elements that are only children of any element to <mi>
+ -- this fixes issues in LibreOffice with a^{*}
+ -- I hope it doesn't introduce different issues
+ -- process only <mo>
+ if x:get_element_name() ~= "mo" then return nil end
+ local siblings = x:get_siblings()
+ -- test if current element list contains only <mo>
+ if just_operators(siblings) == #siblings then
+ if #siblings == 1 then
+ -- one <mo> translates to <mtext>
+ x._name = "mtext"
+ log:debug("changing one <mo> to <mtext>: " .. x:get_text())
+ -- I think we should use <mi>, but LO incorrectly renders it in <msubsup>,
+ -- even if we use the mathvariant="normal" attribute. <mtext> works, so
+ -- we use that instead.
+ -- x:set_attribute("mathvariant", "normal")
+ else
+ -- multiple <mo> translate to <mtext>
+ local text = {}
+ for _, el in ipairs(siblings) do
+ text[#text+1] = el:get_text()
+ end
+ -- replace first <mo> text with concetanated text content
+ -- of all <mo> elements
+ x._children = {}
+ local newtext = table.concat(text)
+ local text_el = x:create_text_node(newtext)
+ log:debug("changing <mo> to <mtext>: " .. newtext)
+ x:add_child_node(text_el)
+ -- change <mo> to <mtext>
+ x._name = "mtext"
+ -- remove subsequent <mo>
+ for i = 2, #siblings do
+ siblings[i]:remove_node()
+ end
+ end
+ end
+end
+
return function(dom)
dom:traverse_elements(function(el)
if settings.output_format ~= "odt" then
@@ -132,6 +250,9 @@ return function(dom)
end
fix_token_elements(el)
fix_nested_mstyle(el)
+ fix_numbers(el)
+ fix_operators(el)
+ fix_mathvariant(el)
top_mrow(el)
end)
return dom
diff --git a/support/make4ht/domfilters/make4ht-odtfonts.lua b/support/make4ht/domfilters/make4ht-odtfonts.lua
new file mode 100644
index 0000000000..68c8ecadc2
--- /dev/null
+++ b/support/make4ht/domfilters/make4ht-odtfonts.lua
@@ -0,0 +1,26 @@
+return function(dom, params)
+ -- fix ODT style for fonts
+ -- sometimes, fonts have missing size, we need to patch styles
+ local properties = get_filter_settings "odtfonts" or {}
+ local fix_lgfile_fonts = params.patched_lg_fonts or properties.patched_lg_fonts or {}
+ for _, style in ipairs(dom:query_selector "style|style") do
+ local typ = style:get_attribute("style:family")
+ if typ == "text" then
+ -- detect if the style is for font
+ local style_name = style:get_attribute("style:name")
+ local name, size, size2, size3 = style_name:match("(.-)%-(%d*)x%-(%d*)x%-(%d+)")
+ if name then
+ -- find if the style corresponds to a problematic font (it is set in formats/make4ht-odt.lua)
+ local used_name = name .. "-" .. size
+ if fix_lgfile_fonts[used_name] then
+ -- copy current style and fix the name
+ local new = style:copy_node()
+ new:set_attribute("style:name", string.format("%s-x-%sx-%s", name, size2, size3))
+ local parent = style:get_parent()
+ parent:add_child_node(new)
+ end
+ end
+ end
+ end
+ return dom
+end
diff --git a/support/make4ht/extensions/make4ht-ext-common_domfilters.lua b/support/make4ht/extensions/make4ht-ext-common_domfilters.lua
index 6219c95fbd..f7fbcdad24 100644
--- a/support/make4ht/extensions/make4ht-ext-common_domfilters.lua
+++ b/support/make4ht/extensions/make4ht-ext-common_domfilters.lua
@@ -19,14 +19,14 @@ function M.modify_build(make)
local count = 0
if current_format == "odt" then
-- some formats doesn't make sense in the ODT format
- local process = filter {"joincharacters", "mathmlfixes"}
+ local process = filter ({"joincharacters", "mathmlfixes"}, "commondomfilters")
local charclasses = {mn = true, ["text:span"] = true, mi=true}
make:match("4oo$", process, {charclasses= charclasses})
-- match math documents
make:match("4om$", process, {charclasses= charclasses})
count = 2
else
- local process = filter {"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows","booktabs", "sectionid", "itemparagraphs"}
+ local process = filter({"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows","booktabs", "sectionid", "itemparagraphs"}, "commondomfilters")
make:match("html?$", process)
count = 1
end
diff --git a/support/make4ht/extensions/make4ht-ext-common_filters.lua b/support/make4ht/extensions/make4ht-ext-common_filters.lua
index 9b3e7f3f74..0d0ee979fd 100644
--- a/support/make4ht/extensions/make4ht-ext-common_filters.lua
+++ b/support/make4ht/extensions/make4ht-ext-common_filters.lua
@@ -2,7 +2,7 @@ local M = {}
local filter = require "make4ht-filter"
-local process = filter {"cleanspan-nat", "fixligatures", "hruletohr", "entities", "fix-links"}
+local process = filter({"cleanspan-nat", "fixligatures", "hruletohr", "entities", "fix-links"}, "commonfilters")
-- filters support only html formats
function M.test(format)
diff --git a/support/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua b/support/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
index 8bf82e0588..53da32c3be 100644
--- a/support/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
+++ b/support/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
@@ -243,7 +243,7 @@ function M.modify_build(make)
end)
-- fix src attributes
- local process = filter {
+ local process = filter({
function(str, filename)
return str:gsub('src=["\'](.-)(["\'])', function(filename, endquote)
local newname = output_map[filename] or filename
@@ -251,7 +251,7 @@ function M.modify_build(make)
return 'src=' .. endquote .. newname .. endquote
end)
end
- }
+ }, "dvisvgmhashes")
make:match("htm.?$", process)
diff --git a/support/make4ht/extensions/make4ht-ext-join_colors.lua b/support/make4ht/extensions/make4ht-ext-join_colors.lua
index 4d72b0e15b..11e6d66fd2 100644
--- a/support/make4ht/extensions/make4ht-ext-join_colors.lua
+++ b/support/make4ht/extensions/make4ht-ext-join_colors.lua
@@ -9,7 +9,7 @@ function M.test(format)
end
function M.modify_build(make)
- local process = filter {"joincolors"}
+ local process = filter({"joincolors"}, "joincolors")
make:match("html?$", process)
return make
end
diff --git a/support/make4ht/extensions/make4ht-ext-mathjaxnode.lua b/support/make4ht/extensions/make4ht-ext-mathjaxnode.lua
index b9a44491ba..3b57351d05 100644
--- a/support/make4ht/extensions/make4ht-ext-mathjaxnode.lua
+++ b/support/make4ht/extensions/make4ht-ext-mathjaxnode.lua
@@ -13,7 +13,7 @@ function M.prepare_parameters(params)
end
function M.modify_build(make)
- local mathjax = filter { "mathjaxnode"}
+ local mathjax = filter({ "mathjaxnode"}, "mathjaxnode")
-- this extension needs mathml enabled
make:match("html?$",mathjax)
return make
diff --git a/support/make4ht/extensions/make4ht-ext-mjcli.lua b/support/make4ht/extensions/make4ht-ext-mjcli.lua
index e59b419cdf..8a60fab610 100644
--- a/support/make4ht/extensions/make4ht-ext-mjcli.lua
+++ b/support/make4ht/extensions/make4ht-ext-mjcli.lua
@@ -24,7 +24,7 @@ function M.prepare_parameters(params)
end
function M.modify_build(make)
- local mathjax = filter { "mjcli"}
+ local mathjax = filter({ "mjcli"}, "mjcli")
local params = {}
if detected_latex then
params.latex = true
diff --git a/support/make4ht/extensions/make4ht-ext-odttemplate.lua b/support/make4ht/extensions/make4ht-ext-odttemplate.lua
index 3b0af2a699..b3607fa477 100644
--- a/support/make4ht/extensions/make4ht-ext-odttemplate.lua
+++ b/support/make4ht/extensions/make4ht-ext-odttemplate.lua
@@ -8,7 +8,7 @@ M.test = function(format)
end
M.modify_build = function(make)
- local process = filter {"odttemplate"}
+ local process = filter({"odttemplate"}, "odttemplate")
make:match("4oy$", process)
return make
end
diff --git a/support/make4ht/extensions/make4ht-ext-staticsite.lua b/support/make4ht/extensions/make4ht-ext-staticsite.lua
index a9a5bcece7..b9272203a5 100644
--- a/support/make4ht/extensions/make4ht-ext-staticsite.lua
+++ b/support/make4ht/extensions/make4ht-ext-staticsite.lua
@@ -22,6 +22,7 @@ local function get_slug(settings)
-- escape
-- slug must contain the unescaped input name
local f = io.open(published_name, "w")
+ log:info("Publishing article", os.date("%Y-%m-%d %H:%M", time))
f:write(time)
f:close()
end
@@ -79,7 +80,7 @@ end
local function remove_maketitle(make)
-- use DOM filter to remove \maketitle block
local domfilter = require "make4ht-domfilter"
- local process = domfilter {
+ local process = domfilter({
function(dom)
local maketitles = dom:query_selector(".maketitle")
for _, el in ipairs(maketitles) do
@@ -88,7 +89,7 @@ local function remove_maketitle(make)
end
return dom
end
- }
+ }, "staticsite")
make:match("html$", process)
end
@@ -120,9 +121,9 @@ function M.modify_build(make)
-- we use an bogus match which will be executed only once as the very first one to insert
-- the filters
-- I should make filter from this
- local process = filter {
+ local process = filter({
"staticsite"
- }
+ }, "staticsite")
-- detect if we should remove maketitle
local site_settings = get_filter_settings "staticsite"
diff --git a/support/make4ht/filters/make4ht-staticsite.lua b/support/make4ht/filters/make4ht-staticsite.lua
index 5620f9c8bb..fba4d220b1 100644
--- a/support/make4ht/filters/make4ht-staticsite.lua
+++ b/support/make4ht/filters/make4ht-staticsite.lua
@@ -58,13 +58,17 @@ local function update_properties(properties, dom)
-- enable properties update from the config or build file
local settings = get_filter_settings "staticsite" or {}
local header = settings.header or {}
+ -- set non-function properties first
+ for field, rule in pairs(header) do
+ if type(rule) ~="function" then
+ properties[field] = rule
+ end
+ end
+ -- then execute functions. it ensures that all propeties set in header are available
for field, rule in pairs(header) do
-- it is possible to pass function as a rule, it will be executed with properties as a parameter
if type(rule) == "function" then
properties[field] = rule(properties, dom)
- else
- -- otherwise set properties
- properties[field] = rule
end
end
return properties
diff --git a/support/make4ht/formats/make4ht-odt.lua b/support/make4ht/formats/make4ht-odt.lua
index f3721eba00..01a587aff4 100644
--- a/support/make4ht/formats/make4ht-odt.lua
+++ b/support/make4ht/formats/make4ht-odt.lua
@@ -73,10 +73,10 @@ function Odtfile:pack()
lfs.chdir(self.archivelocation)
-- make temporary mime type file
self:make_mimetype()
- mkutils.execute(zip_command .. " -q0X " .. self.name .. " " .. self.mimetypename)
+ mkutils.execute(zip_command .. " -q0X '" .. self.name .. "' " .. self.mimetypename)
-- remove it, so the next command doesn't overwrite it
self:remove_mimetype()
- mkutils.execute(zip_command .." -r " .. self.name .. " *")
+ mkutils.execute(zip_command .." -r '" .. self.name .. "' *")
lfs.chdir(currentdir)
mkutils.cp(self.archivelocation .. "/" .. self.name, self.name)
mkutils.delete_dir(self.archivelocation)
@@ -164,13 +164,64 @@ local function fix_picture_sizes(tmpdir)
f:close()
end
+-- fix font records in the lg file that don't correct Font_Size record
+local lg_fonts_processed=false
+local patched_lg_fonts = {}
+local function fix_lgfile_fonts(ignored_name, params)
+ -- this function is called from file match. we must use the name of the .lg file
+ local filename = params.input .. ".lg"
+ if not lg_fonts_processed then
+ local lines = {}
+ -- default font_size
+ local font_size = "10"
+ if mkutils.file_exists(filename) then
+ --
+ for line in io.lines(filename) do
+ -- default font_size can be set in the .lg file
+ if line:match("Font_Size") then
+ font_size = line:match("Font_Size:%s*(%d+)")
+ elseif line:match("Font%(") then
+ -- match Font record
+ local name, size, size2, size3 = line:match('Font%("([^"]+)","([%d]*)","([%d]+)","([%d]+)"')
+ -- find if the first size is not set, and add the default font_size then
+ if size == "" then
+ line = string.format('Font("%s","%s","%s","%s")', name, font_size, size2, size3)
+ -- we must also save the font name and size for later post-processing, because
+ -- we will need to fix styles in content.xml too
+ patched_lg_fonts[name .. "-" .. font_size] = true
+ end
+ end
+ lines[#lines+1] = line
+ end
+ -- save changed lines to the lg file
+ local f = io.open(filename, "w")
+ for _,line in ipairs(lines) do
+ f:write(line .. "\n")
+ end
+ f:close()
+ end
+ filter_settings "odtfonts" {patched_lg_fonts = patched_lg_fonts}
+ end
+ lg_fonts_processed=true
+ return true
+end
+
+local move_matches = xtpipeslib.move_matches
+
+local function insert_lgfile_fonts(make)
+ local first_file = make.params.input .. ".4oo"
+ -- find the last file and escape it so it can be used
+ -- in filename match
+ make:match(first_file, fix_lgfile_fonts)
+ move_matches(make)
+end
+
-- escape string to be used in the gsub search
local function escape_file(filename)
local quotepattern = '(['..("%^$().[]*+-?"):gsub("(.)", "%%%1")..'])'
return filename:gsub(quotepattern, "%%%1")
end
-local move_matches = xtpipeslib.move_matches
-- call xtpipes from Lua
local function call_xtpipes(make)
@@ -185,6 +236,8 @@ local function call_xtpipes(make)
-- we need to move last two matches, for 4oo and 4om files
move_matches(make)
move_matches(make)
+ -- fix font records in the lg file
+ insert_lgfile_fonts(make)
else
log:warning "Cannot locate xtpipes. Try to set TEXMFROOT variable to a root directory of your TeX distribution"
end
@@ -231,6 +284,9 @@ function M.modify_build(make)
-- fixes for mathml
local mathmldomfilters = domfilter({"joincharacters","mathmlfixes"}, "mathmlfilters")
make:match("4om$", mathmldomfilters)
+ -- DOM filters that should be executed after xtpipes
+ local latedom = domfilter({"odtfonts"}, "lateodtfilters")
+ make:match("4oo$", latedom)
-- convert XML entities for Unicode characters produced by Xtpipes to characters
local fixentities = filter {"entities-to-unicode", remove_xtpipes}
make:match("4oo", fixentities)
diff --git a/support/make4ht/make4ht b/support/make4ht/make4ht
index 74a9c22d2b..b938fdede1 100755
--- a/support/make4ht/make4ht
+++ b/support/make4ht/make4ht
@@ -29,7 +29,7 @@ make4ht [options] filename ["tex4ht.sty op." "tex4ht op." "t4ht op" "latex op"]
-- set version number. the template should be replaced by the
-- actual version number by the build script
-local version = "v0.3j"
+local version = "v0.3k"
mkparams.version_number = version
local args = mkparams.get_args()
diff --git a/support/make4ht/make4ht-doc.pdf b/support/make4ht/make4ht-doc.pdf
index 58ce628888..665ad1fea4 100644
--- a/support/make4ht/make4ht-doc.pdf
+++ b/support/make4ht/make4ht-doc.pdf
Binary files differ
diff --git a/support/make4ht/make4ht-logging.lua b/support/make4ht/make4ht-logging.lua
index 63b11433ea..0f195689c2 100644
--- a/support/make4ht/make4ht-logging.lua
+++ b/support/make4ht/make4ht-logging.lua
@@ -4,7 +4,8 @@ local logging = {}
local levels = {}
-- level of bugs that should be shown
-local show_level = 1
+-- enable querying of current log level
+logging.show_level = 1
local max_width = 0
local max_status = 0
@@ -34,7 +35,7 @@ end
-- the logging level is set once
function logging.set_level(name)
local level = levels[name] or 1
- show_level = level
+ logging.show_level = level
end
function logging.print_msg(header, message, color)
@@ -53,7 +54,7 @@ function logging.new(module)
module = module,
output = function(self, output)
-- used for printing of output of commands
- if show_level <= (levels[debug] or 1) then
+ if logging.show_level <= (levels["debug"] or 1) then
print(output)
end
end
@@ -68,7 +69,7 @@ function logging.new(module)
-- set make4ht exit status
max_status = math.max(status, max_status)
-- max width is saved in logging.prepare_levels
- if mode.level >= show_level then
+ if mode.level >= logging.show_level then
-- support variable number of parameters
local table_with_holes = table.pack(...)
local table_without_holes = {}
@@ -106,6 +107,7 @@ logging.prepare_levels()
-- logging.set_level("error")
-- cls:info("level set")
-- cls:error("just print the error")
+--
return logging
diff --git a/support/make4ht/make4ht-xtpipes.lua b/support/make4ht/make4ht-xtpipes.lua
index 3f5b51e07b..544663fb89 100644
--- a/support/make4ht/make4ht-xtpipes.lua
+++ b/support/make4ht/make4ht-xtpipes.lua
@@ -48,18 +48,27 @@ function M.get_xtpipes(selfautoparent)
mkutils.mv(filename, tmpfile)
local command = pattern % {filename = tmpfile, outputfile = filename}
log:info("execute: " ..command)
- local status = mkutils.execute(command)
+ local status, output = mkutils.execute(command)
if status > 0 then
-- if xtpipes failed to process the file, it may mean that it was bad-formed xml
-- we can try to make it well-formed using Tidy
local tidy_command = 'tidy -utf8 -xml -asxml -q -o "${filename}" "${tmpfile}"' % {tmpfile = tmpfile, filename = filename}
- log:warning("xtpipes failed trying tidy")
+ log:warning("Xtpipes failed")
+ -- show_level 1 is debug mode, which prints command output as well
+ -- we need this condition to prevent multiple instances of the output
+ if logging.show_level > 1 then
+ print(output)
+ end
+ log:warning("Trying HTML tidy")
log:debug(tidy_command)
- local status = os.execute(tidy_command)
+ local status, output = os.execute(tidy_command)
if status > 0 then
-- if tidy failed as well, just use the original file
-- it will probably produce corrupted ODT file though
log:warning("Tidy failed as well")
+ if logging.show_level > 1 then
+ print(output)
+ end
mkutils.mv(tmpfile, filename)
end
end
diff --git a/support/make4ht/mkparams.lua b/support/make4ht/mkparams.lua
index 5517c0a19f..e330b6a0ab 100644
--- a/support/make4ht/mkparams.lua
+++ b/support/make4ht/mkparams.lua
@@ -108,7 +108,7 @@ local function handle_jobname(input, args)
input = input:match("([^%/^%\\]+)$")
-- input also cannot contain spaces, replace them with underscores
input = input:gsub("%s", "_")
- table.insert(latex_params,"-jobname="..input)
+ table.insert(latex_params,"-jobname='"..input.. "'")
else
-- when user specifies -jobname, we must change name of the input file,
-- in order to be able to process correct dvi file with tex4ht and t4ht
diff --git a/support/make4ht/readme.tex b/support/make4ht/readme.tex
index caf5e05966..db45e582d5 100644
--- a/support/make4ht/readme.tex
+++ b/support/make4ht/readme.tex
@@ -734,6 +734,9 @@ many \texttt{\textless{}span\textgreater{}} elements with unique
the document. A CSS rule is added for each of these elements, which may
result in substantial growth of the CSS file. This filter replaces these
rules with a common one for elements with the same color value.
+\item[odtfonts]
+fix styles for fonts that were wrongly converted by \texttt{Xtpipes} in
+the ODT format.
\item[odtimagesize]
set correct dimensions for images in the ODT format. It is no longer
used, as the dimensions are set by TeX4ht itself.
diff --git a/support/tex4ebook/changelog.tex b/support/tex4ebook/changelog.tex
index 607249691e..7eaa4c85ec 100644
--- a/support/tex4ebook/changelog.tex
+++ b/support/tex4ebook/changelog.tex
@@ -3,6 +3,43 @@
\begin{itemize}
\item
+ 2022/02/18
+
+ \begin{itemize}
+ \tightlist
+ \item
+ released version \texttt{0.3h}.
+ \end{itemize}
+\item
+ 2022/01/13
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed issue where child TOC elements were inserted into
+ \texttt{\textless{}a\textgreater{}} element.
+ \end{itemize}
+\item
+ 2021/12/07
+
+ \begin{itemize}
+ \tightlist
+ \item
+ print space after section number in Epub 3 TOC.
+ \item
+ keep original elements in Epub 3 TOC.
+ \end{itemize}
+\item
+ 2021/12/04
+
+ \begin{itemize}
+ \tightlist
+ \item
+ fixed support for
+ \href{https://github.com/michal-h21/tex4ebook/issues/85}{appendix
+ chapters in Epub 3}.
+ \end{itemize}
+\item
2021/11/08
\begin{itemize}
diff --git a/support/tex4ebook/tex4ebook b/support/tex4ebook/tex4ebook
index b170da2cee..8f6c8aa3f7 100755
--- a/support/tex4ebook/tex4ebook
+++ b/support/tex4ebook/tex4ebook
@@ -67,7 +67,7 @@ else
end
if args.version then
- print "tex4ebook v0.3g"
+ print "tex4ebook v0.3h"
return
end
diff --git a/support/tex4ebook/tex4ebook-doc.pdf b/support/tex4ebook/tex4ebook-doc.pdf
index 0e06106160..7e8386af7a 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 b30e1c3ef1..9d49b624e6 100644
--- a/support/tex4ebook/tex4ebook-epub3.4ht
+++ b/support/tex4ebook/tex4ebook-epub3.4ht
@@ -13,9 +13,10 @@
%%%%%%%%%%%%%%%%%%%%%%%
\Configure{tableofcontents}{
\a:NavMap
- \resettoclevels{part,chapter,section,subsection,subsubsection}
- \navsection{part}{part,chapter,section,subsection,subsubsection}
- \navsection{chapter}{chapter,section,subsection,subsubsection}
+ \resettoclevels{part,appendix,chapter,section,subsection,subsubsection}
+ \navsection{part}{part,appendix,chapter,section,subsection,subsubsection}
+ \navsection{appendix}{appendix,chapter,section,subsection,subsubsection}
+ \navsection{chapter}{appendix,chapter,section,subsection,subsubsection}
\navsection{section}{section,subsection,subsubsection}
\navsection{subsection}{subsection,subsubsection}
\navsection{subsubsection}{subsubsection}
@@ -26,13 +27,13 @@
\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}%
+}{\usetoclevels{part,appendix,chapter,section,subsection,subsubsection}%
\ifbool{tocnoempty}{}{\HCode{<li><a href="\jobname.\:html">Document</a></li>}}
\HCode{</ol></nav>}}
%%%%%%%%%%%
\Configure{NavSection}{%
\booltrue{tocnoempty}
- \HCode{<li>}}{\HCode{<ol>\Hnewline}}{}{\Tg</ol>\Tg</li>}
+ \HCode{<li>}}{\HCode{<ol>\Hnewline}}{\ }{\Tg</ol>\Tg</li>}
% Disable numbering of the TOC by the reading system, numbers are added by tex4ht
\Css{nav\#toc ol{list-style: none;}}
%%%% End toc nav configuration
diff --git a/support/tex4ebook/tex4ebook-exec_epub3.lua b/support/tex4ebook/tex4ebook-exec_epub3.lua
index fc200bd866..328acaae37 100644
--- a/support/tex4ebook/tex4ebook-exec_epub3.lua
+++ b/support/tex4ebook/tex4ebook-exec_epub3.lua
@@ -113,6 +113,12 @@ local function add_media_overlays(content)
end
+-- elements that shouldn't be put inside <a> in TOC
+local stop_toc_processing_elements = {
+ ol = true,
+ ul = true
+}
+
local function remove_spurious_TOC_elements(tocdom)
local function count_child_elements(el)
-- count children elements of the current element
@@ -127,36 +133,44 @@ local function remove_spurious_TOC_elements(tocdom)
for _, el in ipairs(tocdom:query_selector("ol")) do
if count_child_elements(el) == 0 then
el:remove_node()
- -- local newli = el:create_element("li")
- -- local newspan = newli:create_element("span")
- -- newli:add_child_node(newspan)
- -- el:add_child_node(newli)
end
end
-- place child elements of the <li> elements to an <a> element, epubcheck reports
-- error for text nodes that are direct child of <li>
for _, el in ipairs(tocdom:query_selector("li")) do
- local text = {}
- local link -- save the <a> element
+
+ local newa = el:create_element("a")
+ local newchildren = {newa}
+ -- we want to stop putting content as child of <a> when it
+ -- finds child TOC entries
+ local keep_processing = true
for i, child in ipairs(el._children) do
- if child:is_text() then
- -- trim spurious spaces
- local childtext = child._text:gsub("^%s*",""):gsub("%s*$","")
- -- save the text for the later use
- table.insert(text, childtext)
- child:remove_node()
- elseif child:is_element() and child:get_element_name() == "a" then
- link = child
- table.insert(text, child:get_text())
+ child_name = child:get_element_name()
+ -- put contents of <li> to a new <a> element
+ if child:is_element() and child_name == "a" then
+ -- set id and href of the new <a> element, if it isn't set already
+ if not newa:get_attribute("href") then
+ local id = child:get_attribute("id")
+ local href = child:get_attribute("href")
+ newa:set_attribute("id", id)
+ newa:set_attribute("href", href)
+ end
+ -- copy <a> contents to the new <a> element
+ for _, x in ipairs(child._children or {}) do newa:add_child_node(x:copy_node()) end
+
+ elseif stop_toc_processing_elements[child_name] then
+ -- don't put child toc entries to the new <a>
+ keep_processing = false
+ newchildren[#newchildren+1] = child
+ elseif keep_processing == true then
+ -- put every node before <ol> or <ul> into the new <a>
+ newa:add_child_node(child:copy_node())
+ else
+ newchildren[#newchildren+1] = child
end
end
- if link then
- local content = table.concat(text, " ")
- -- remove the original text
- link._children = {}
- local text = link:create_text_node(content)
- link:add_child_node(text)
- end
+ -- set contents of <li> to be the new <a>
+ el._children = newchildren
end
return tocdom
diff --git a/support/tex4ebook/tex4ebook.4ht b/support/tex4ebook/tex4ebook.4ht
index c078eee57e..8686c2932f 100644
--- a/support/tex4ebook/tex4ebook.4ht
+++ b/support/tex4ebook/tex4ebook.4ht
@@ -342,7 +342,7 @@ href="#1" media-type="\a:CoverMimeType" />}}
% define toc levels which should be included in the NCX file
\NewConfigure{resettoclevels}{1}
-\Configure{resettoclevels}{part,chapter,section,subsection,subsubsection,paragraph}
+\Configure{resettoclevels}{part,appendix,chapter,section,subsection,subsubsection,paragraph}
\def\:tempa{%
\EndP%