texlive[52950] trunk: make4ht (27nov19)

commits+karl at tug.org commits+karl at tug.org
Wed Nov 27 23:06:50 CET 2019


Revision: 52950
          http://tug.org/svn/texlive?view=revision&revision=52950
Author:   karl
Date:     2019-11-27 23:06:50 +0100 (Wed, 27 Nov 2019)
Log Message:
-----------
make4ht (27nov19)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht
    trunk/Master/texmf-dist/doc/support/make4ht/README
    trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex
    trunk/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf
    trunk/Master/texmf-dist/doc/support/make4ht/readme.tex
    trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincharacters.lua
    trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua
    trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-html5.lua
    trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua
    trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-xhtml.lua
    trunk/Master/texmf-dist/scripts/make4ht/make4ht
    trunk/Master/texmf-dist/scripts/make4ht/mkutils.lua

Added Paths:
-----------
    trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua

Modified: trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht	2019-11-27 22:06:50 UTC (rev 52950)
@@ -29,7 +29,7 @@
 
 -- 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()

Modified: trunk/Master/texmf-dist/doc/support/make4ht/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/make4ht/README	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Master/texmf-dist/doc/support/make4ht/README	2019-11-27 22:06:50 UTC (rev 52950)
@@ -403,6 +403,10 @@
 
 :    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 @@
 
 :  remove spurious rows from HTML tables.
 
+mathmlfixes
+
+:  fix common issues for MathML.
+
 t4htlinks
 
 :  fix hyperlinks in the ODT format.

Modified: trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex	2019-11-27 22:06:50 UTC (rev 52950)
@@ -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}

Modified: trunk/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/make4ht/readme.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/make4ht/readme.tex	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Master/texmf-dist/doc/support/make4ht/readme.tex	2019-11-27 22:06:50 UTC (rev 52950)
@@ -477,6 +477,8 @@
 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 @@
 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}

Modified: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincharacters.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincharacters.lua	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincharacters.lua	2019-11-27 22:06:50 UTC (rev 52950)
@@ -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 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 @@
       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)

Added: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua	2019-11-27 22:06:50 UTC (rev 52950)
@@ -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
+


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua	2019-11-27 22:06:50 UTC (rev 52950)
@@ -19,14 +19,14 @@
   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

Modified: trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-html5.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-html5.lua	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-html5.lua	2019-11-27 22:06:50 UTC (rev 52950)
@@ -3,8 +3,7 @@
 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)

Modified: trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua	2019-11-27 22:06:50 UTC (rev 52950)
@@ -136,6 +136,9 @@
   -- 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

Modified: trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-xhtml.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-xhtml.lua	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Master/texmf-dist/scripts/make4ht/formats/make4ht-xhtml.lua	2019-11-27 22:06:50 UTC (rev 52950)
@@ -3,8 +3,7 @@
 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)

Modified: trunk/Master/texmf-dist/scripts/make4ht/make4ht
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht	2019-11-27 22:06:50 UTC (rev 52950)
@@ -29,7 +29,7 @@
 
 -- 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()

Modified: trunk/Master/texmf-dist/scripts/make4ht/mkutils.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/mkutils.lua	2019-11-27 22:06:27 UTC (rev 52949)
+++ trunk/Master/texmf-dist/scripts/make4ht/mkutils.lua	2019-11-27 22:06:50 UTC (rev 52950)
@@ -440,6 +440,7 @@
 -- 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)



More information about the tex-live-commits mailing list