diff options
author | Karl Berry <karl@freefriends.org> | 2019-11-27 22:06:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-11-27 22:06:50 +0000 |
commit | 5ddfa0bd3428ac6c5b0a4a564b2b1b78a468d129 (patch) | |
tree | 5a95803333995618d7870de20959b7dc9bd1589b | |
parent | 80cb9c50ef0c7af421240024db2804123753d73b (diff) |
make4ht (27nov19)
git-svn-id: svn://tug.org/texlive/trunk@52950 c570f23f-e606-0410-a88d-b1316a301751
13 files changed, 128 insertions, 11 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/make4ht/make4ht b/Build/source/texk/texlive/linked_scripts/make4ht/make4ht index fd153164cd7..10311088d78 100755 --- a/Build/source/texk/texlive/linked_scripts/make4ht/make4ht +++ b/Build/source/texk/texlive/linked_scripts/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/Master/texmf-dist/doc/support/make4ht/README b/Master/texmf-dist/doc/support/make4ht/README index df148332394..3b2e6b00850 100644 --- a/Master/texmf-dist/doc/support/make4ht/README +++ b/Master/texmf-dist/doc/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/Master/texmf-dist/doc/support/make4ht/changelog.tex b/Master/texmf-dist/doc/support/make4ht/changelog.tex index 723de6762bb..8fdd699e836 100644 --- a/Master/texmf-dist/doc/support/make4ht/changelog.tex +++ b/Master/texmf-dist/doc/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/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf b/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf Binary files differindex 9676888d51d..949fa599c62 100644 --- a/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf +++ b/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf diff --git a/Master/texmf-dist/doc/support/make4ht/readme.tex b/Master/texmf-dist/doc/support/make4ht/readme.tex index ff1d942d18d..a326ce10106 100644 --- a/Master/texmf-dist/doc/support/make4ht/readme.tex +++ b/Master/texmf-dist/doc/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} diff --git a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincharacters.lua b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincharacters.lua index 30ed6e1382a..5830eae78e6 100644 --- a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincharacters.lua +++ b/Master/texmf-dist/scripts/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/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua new file mode 100644 index 00000000000..a52b0e5d6b1 --- /dev/null +++ b/Master/texmf-dist/scripts/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/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua index 9399492d907..ec687cd042d 100644 --- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua +++ b/Master/texmf-dist/scripts/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/Master/texmf-dist/scripts/make4ht/formats/make4ht-html5.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-html5.lua index 633a45e7f34..a70309fa7ae 100644 --- a/Master/texmf-dist/scripts/make4ht/formats/make4ht-html5.lua +++ b/Master/texmf-dist/scripts/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/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua index c515a154a1b..30fdc0744da 100644 --- a/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua +++ b/Master/texmf-dist/scripts/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/Master/texmf-dist/scripts/make4ht/formats/make4ht-xhtml.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-xhtml.lua index 4a4ac6689ca..25fb339c0f8 100644 --- a/Master/texmf-dist/scripts/make4ht/formats/make4ht-xhtml.lua +++ b/Master/texmf-dist/scripts/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/Master/texmf-dist/scripts/make4ht/make4ht b/Master/texmf-dist/scripts/make4ht/make4ht index fd153164cd7..10311088d78 100755 --- a/Master/texmf-dist/scripts/make4ht/make4ht +++ b/Master/texmf-dist/scripts/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/Master/texmf-dist/scripts/make4ht/mkutils.lua b/Master/texmf-dist/scripts/make4ht/mkutils.lua index 0ea85c7b56b..944ab99cc74 100755 --- a/Master/texmf-dist/scripts/make4ht/mkutils.lua +++ b/Master/texmf-dist/scripts/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) |