summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-11-27 03:01:12 +0000
committerNorbert Preining <norbert@preining.info>2019-11-27 03:01:12 +0000
commit5142daa13e19b32afa064863e039da3afaf06e83 (patch)
treed8299dbf426b9b0e6cafacc4cbe5a6a762bf28a9 /support
parentbd1c54bb99e58d8c140acb0b0a536037f96349b4 (diff)
CTAN sync 201911270301
Diffstat (limited to 'support')
-rw-r--r--support/make4ht/README8
-rw-r--r--support/make4ht/changelog.tex41
-rw-r--r--support/make4ht/domfilters/make4ht-joincharacters.lua20
-rw-r--r--support/make4ht/domfilters/make4ht-mathmlfixes.lua46
-rw-r--r--support/make4ht/extensions/make4ht-ext-common_domfilters.lua6
-rw-r--r--support/make4ht/formats/make4ht-html5.lua3
-rw-r--r--support/make4ht/formats/make4ht-odt.lua3
-rw-r--r--support/make4ht/formats/make4ht-xhtml.lua3
-rwxr-xr-xsupport/make4ht/make4ht2
-rw-r--r--support/make4ht/make4ht-doc.pdfbin127067 -> 128196 bytes
-rw-r--r--support/make4ht/mkutils.lua1
-rw-r--r--support/make4ht/readme.tex4
12 files changed, 127 insertions, 10 deletions
diff --git a/support/make4ht/README b/support/make4ht/README
index df14833239..3b2e6b0085 100644
--- a/support/make4ht/README
+++ b/support/make4ht/README
@@ -403,6 +403,10 @@ detect compilation errors in the TeX log file.
: Process bibliography using the `biber` command.
+`Make:pythontex`
+
+: Process the input file using `pythontex`.
+
`Make:bibtex`
: Process bibliography using the `bibtex` command.
@@ -602,6 +606,10 @@ tablerows
: remove spurious rows from HTML tables.
+mathmlfixes
+
+: fix common issues for MathML.
+
t4htlinks
: fix hyperlinks in the ODT format.
diff --git a/support/make4ht/changelog.tex b/support/make4ht/changelog.tex
index 723de6762b..8fdd699e83 100644
--- a/support/make4ht/changelog.tex
+++ b/support/make4ht/changelog.tex
@@ -3,6 +3,47 @@
\begin{itemize}
\item
+ 2019/11/28
+
+ \begin{itemize}
+ \tightlist
+ \item
+ version \texttt{0.3c} released.
+ \item
+ updated \texttt{mathmlfixes} DOM filter. It handles
+ \texttt{\textless{}mstyle\textgreater{}} element inside token
+ elements now.
+ \item
+ use \texttt{mathmlfixes} and \texttt{joincharacters} DOM filters for
+ math XML files in the ODT output.
+ \end{itemize}
+\item
+ 2019/11/25
+
+ \begin{itemize}
+ \tightlist
+ \item
+ added \texttt{pythontex} command.
+ \item
+ added \texttt{mathmlfixes} DOM filter.
+ \item
+ use the \texttt{mathmlfixes} DOM filter in
+ \texttt{common\_domfilters} extension.
+ \end{itemize}
+\item
+ 2019/11/22
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{make4ht-joincharacters} dom filter: added support for the
+ \texttt{\textless{}mi\textgreater{}} element. Test all attributes
+ for match when joining characters.
+ \item
+ \texttt{html5} format: use the \texttt{common\_domfilters} by
+ default.
+ \end{itemize}
+\item
2019/11/03
\begin{itemize}
diff --git a/support/make4ht/domfilters/make4ht-joincharacters.lua b/support/make4ht/domfilters/make4ht-joincharacters.lua
index 30ed6e1382..5830eae78e 100644
--- a/support/make4ht/domfilters/make4ht-joincharacters.lua
+++ b/support/make4ht/domfilters/make4ht-joincharacters.lua
@@ -1,8 +1,23 @@
+local log = logging.new("joincharacters")
+
local charclasses = {
span=true,
mn = true,
+ mi = true
}
+local has_matching_attributes = function (el, next_el)
+ local el_attr = el._attr or {}
+ local next_attr = next_el._attr or {}
+ -- if the number of attributes doesn't match, elements don't match
+ if #next_attr ~= #el_attr then return false end
+ for k, v in pairs(el_attr) do
+ -- if any attribute doesn't match, elements don't match
+ if v~=next_attr[k] then return false end
+ end
+ return true
+end
+
local function join_characters(obj,par)
-- join adjanced span and similar elements inserted by
-- tex4ht to just one object.
@@ -10,12 +25,13 @@ local function join_characters(obj,par)
local options = get_filter_settings "joincharacters"
local charclasses = options.charclasses or par.charclasses or charclasses
+
obj:traverse_elements(function(el)
local get_name = function(curr)
return string.lower(curr:get_element_name())
end
local get_class = function(next_el)
- return next_el:get_attribute("class")
+ return next_el:get_attribute("class") or next_el:get_attribute("mathvariant")
end
local is_span = function(next_el)
return charclasses[get_name(next_el)]
@@ -41,7 +57,7 @@ local function join_characters(obj,par)
while next_el do
-- save the next element because we will remove it later
local real_next = get_next(next_el)
- if get_name(el) == get_name(next_el) and get_class(el) == get_class(next_el) and not el:get_attribute("id") then
+ if get_name(el) == get_name(next_el) and has_matching_attributes(el,next_el) and not el:get_attribute("id") then
-- it the following element match, copy it's children to the current element
for _, child in ipairs(next_el:get_children()) do
el:add_child_node(child)
diff --git a/support/make4ht/domfilters/make4ht-mathmlfixes.lua b/support/make4ht/domfilters/make4ht-mathmlfixes.lua
new file mode 100644
index 0000000000..a52b0e5d6b
--- /dev/null
+++ b/support/make4ht/domfilters/make4ht-mathmlfixes.lua
@@ -0,0 +1,46 @@
+-- <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"}
+local token_elements = {}
+for _, tok in ipairs(token) do token_elements[tok] = true end
+
+local function is_token_element(el)
+ return token_elements[el:get_element_name()]
+end
+
+local function fix_token_elements(el)
+ -- find token elements that are children of other token elements
+ if is_token_element(el) then
+ local parent = el:get_parent()
+ if is_token_element(parent) then
+ -- change top element in nested token elements to mstyle
+ parent._name = "mstyle"
+ end
+ end
+end
+
+local function fix_nested_mstyle(el)
+ -- the <mstyle> element can be child of token elements
+ -- we must exterminate it
+ if el:get_element_name() == "mstyle" then
+ local parent = el:get_parent()
+ if is_token_element(parent) then
+ -- if parent doesn't have the mathvariant attribute copy it from <mstyle>
+ if not parent:get_attribute("mathvariant") then
+ local mathvariant = el:get_attribute("mathvariant")
+ parent:set_attribute("mathvariant", mathvariant)
+ end
+ -- copy the contents of <mstyle> to the parent element
+ parent._children = el._children
+ end
+ end
+end
+
+return function(dom)
+ dom:traverse_elements(function(el)
+ fix_token_elements(el)
+ fix_nested_mstyle(el)
+ 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 9399492d90..ec687cd042 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"}
- local charclasses = {mn = true, ["text:span"] = true}
+ local process = filter {"joincharacters", "mathmlfixes"}
+ 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", "tablerows"}
+ local process = filter {"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows"}
make:match("html$", process)
count = 1
end
diff --git a/support/make4ht/formats/make4ht-html5.lua b/support/make4ht/formats/make4ht-html5.lua
index 633a45e7f3..a70309fa7a 100644
--- a/support/make4ht/formats/make4ht-html5.lua
+++ b/support/make4ht/formats/make4ht-html5.lua
@@ -3,8 +3,7 @@ local M = {}
local mkutils = require "mkutils"
function M.prepare_extensions(extensions)
- -- return mkutils.add_extensions("+common_domfilters", extensions)
- return extensions --mkutils.add_extensions("+tidy", extensions)
+ return mkutils.add_extensions("+common_domfilters", extensions)
end
function M.prepare_parameters(parameters,extensions)
diff --git a/support/make4ht/formats/make4ht-odt.lua b/support/make4ht/formats/make4ht-odt.lua
index c515a154a1..30fdc0744d 100644
--- a/support/make4ht/formats/make4ht-odt.lua
+++ b/support/make4ht/formats/make4ht-odt.lua
@@ -136,6 +136,9 @@ function M.modify_build(make)
-- fix the image dimensions wrongly set by xtpipes
local domfilters = domfilter {"t4htlinks", "odtpartable"}
make:match("4oo$", domfilters)
+ -- fixes for mathml
+ local mathmldomfilters = domfilter {"joincharacters","mathmlfixes"}
+ make:match("4om$", mathmldomfilters)
-- execute it before xtpipes, because we don't want xtpipes to mess with t4htlink elements
move_matches(make)
-- convert XML entities for Unicode characters produced by Xtpipes to characters
diff --git a/support/make4ht/formats/make4ht-xhtml.lua b/support/make4ht/formats/make4ht-xhtml.lua
index 4a4ac6689c..25fb339c0f 100644
--- a/support/make4ht/formats/make4ht-xhtml.lua
+++ b/support/make4ht/formats/make4ht-xhtml.lua
@@ -3,8 +3,7 @@ local M = {}
local mkutils = require "mkutils"
function M.prepare_extensions(extensions)
- -- return mkutils.add_extensions("+common_domfilters", extensions)
- return extensions
+ return mkutils.add_extensions("+common_domfilters", extensions)
end
function M.prepare_parameters(parameters,extensions)
diff --git a/support/make4ht/make4ht b/support/make4ht/make4ht
index fd153164cd..10311088d7 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.3b"
+local version = "v0.3c"
mkparams.version_number = version
local args = mkparams.get_args()
diff --git a/support/make4ht/make4ht-doc.pdf b/support/make4ht/make4ht-doc.pdf
index 9676888d51..949fa599c6 100644
--- a/support/make4ht/make4ht-doc.pdf
+++ b/support/make4ht/make4ht-doc.pdf
Binary files differ
diff --git a/support/make4ht/mkutils.lua b/support/make4ht/mkutils.lua
index 0ea85c7b56..944ab99cc7 100644
--- a/support/make4ht/mkutils.lua
+++ b/support/make4ht/mkutils.lua
@@ -440,6 +440,7 @@ end
-- for the BibLaTeX support
env.Make:add("biber", "biber ${input}")
env.Make:add("bibtex", "bibtex ${input}")
+env.Make:add("pythontex", "pythontex ${input}")
--- load the output format plugins
function load_output_format(format_name)
diff --git a/support/make4ht/readme.tex b/support/make4ht/readme.tex
index ff1d942d18..a326ce1010 100644
--- a/support/make4ht/readme.tex
+++ b/support/make4ht/readme.tex
@@ -477,6 +477,8 @@ Process the \texttt{DVI} file and create output files.
Create the CSS file and generate images.
\item[\texttt{Make:biber}]
Process bibliography using the \texttt{biber} command.
+\item[\texttt{Make:pythontex}]
+Process the input file using \texttt{pythontex}.
\item[\texttt{Make:bibtex}]
Process bibliography using the \texttt{bibtex} command.
\item[\texttt{Make:xindy}]
@@ -664,6 +666,8 @@ resolve tables nested inside paragraphs, which is invalid in the ODT
format.
\item[tablerows]
remove spurious rows from HTML tables.
+\item[mathmlfixes]
+fix common issues for MathML.
\item[t4htlinks]
fix hyperlinks in the ODT format.
\end{description}