texlive[53514] trunk: make4ht (23jan20)

commits+karl at tug.org commits+karl at tug.org
Thu Jan 23 22:55:17 CET 2020


Revision: 53514
          http://tug.org/svn/texlive?view=revision&revision=53514
Author:   karl
Date:     2020-01-23 22:55:17 +0100 (Thu, 23 Jan 2020)
Log Message:
-----------
make4ht (23jan20)

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/domfilters/make4ht-tablerows.lua
    trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua
    trunk/Master/texmf-dist/scripts/make4ht/make4ht
    trunk/Master/texmf-dist/scripts/make4ht/make4ht-htlatex.lua
    trunk/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua
    trunk/Master/texmf-dist/scripts/make4ht/mkparams.lua
    trunk/Master/texmf-dist/scripts/make4ht/mkutils.lua

Added Paths:
-----------
    trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-booktabs.lua
    trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua

Removed Paths:
-------------
    trunk/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua

Modified: trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht	2020-01-23 21:55:17 UTC (rev 53514)
@@ -29,7 +29,7 @@
 
 -- set version number. the template should be replaced by the
 -- actual version number by the build script
-local version = "v0.3c"
+local version = "v0.3d"
 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	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/doc/support/make4ht/README	2020-01-23 21:55:17 UTC (rev 53514)
@@ -238,6 +238,16 @@
 `common_filters`. Used DOM filters are `fixinlines`, `idcolons`,
 `joincharacters`, and `tablerows`.
 
+detect\_engine
+
+:    detect engine and format necessary for the document compilation from the
+     magic comments supported by \LaTeX\ editors such as TeXShop or TeXWorks. 
+     Add something like the following line at the beginning of the main \TeX\ file:
+
+     `%!TEX TS-program = xelatex`
+
+     It supports also Plain \TeX, use for example `tex` or `luatex` as the program name.
+
 dvisvgm\_hashes
 
 :    efficient generation of SVG pictures using Dvisvgm. It can utilize
@@ -387,6 +397,10 @@
 
 :    One call to the TeX engine with special configuration for loading of the `tex4ht.sty` package.
 
+`Make:httex`
+
+:    Variant of `Make:htlatex` suitable for Plain \TeX.
+
 `Make:latexmk`
 
 :    Use `Latexmk` for the document compilation. `tex4ht.sty` will be loaded automatically.
@@ -571,6 +585,10 @@
 :  [Aeneas](https://www.readbeyond.it/aeneas/) is a tool for automagical synchronization of text and audio.
    This filter modifies the HTML code to support synchronization.
 
+booktabs
+
+:  fix lines produced by the `\cmidrule` command provided by the Booktabs package.
+
 collapsetoc
 
 :  collapse table of contents to contain only top-level sectioning level and sections on the current page.

Modified: trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex	2020-01-23 21:55:17 UTC (rev 53514)
@@ -3,6 +3,70 @@
 
 \begin{itemize}
 \item
+  2020/01/22
+
+  \begin{itemize}
+  \tightlist
+  \item
+    version \texttt{0.3d} released.
+  \item
+    added \texttt{Make:httex} command for Plain TeX support.
+  \item
+    added \texttt{detect\_engine} extension. It supports detection of
+    the used engine and format from TeX Shop or TeXWorks magic comments.
+    These comments can look like:
+    \texttt{\%!TEX\ TS-program\ =\ xelatex}.
+  \end{itemize}
+\item
+  2020/01/22
+
+  \begin{itemize}
+  \tightlist
+  \item
+    fixed support for multiple indices in \texttt{make4ht-indexing.lua}.
+  \end{itemize}
+\item
+  2019/12/29
+
+  \begin{itemize}
+  \tightlist
+  \item
+    use the \texttt{mathvariant="italic"} attribute for joined
+    \texttt{\textless{}mi\textgreater{}} elements.
+  \item
+    fixed comparison of element attributes in \texttt{joincharacters}
+    DOM filter.
+  \end{itemize}
+\item
+  2019/12/28
+
+  \begin{itemize}
+  \tightlist
+  \item
+    print warning if the input file doesn't exist.
+  \end{itemize}
+\item
+  2019/12/17
+
+  \begin{itemize}
+  \tightlist
+  \item
+    added \texttt{booktabs} DOM filter.
+  \item
+    load the \texttt{booktabs} in \texttt{common\_domfilters} by
+    default.
+  \end{itemize}
+\item
+  2019/12/14
+
+  \begin{itemize}
+  \tightlist
+  \item
+    fixed bug in the \texttt{tablerows} DOM filter -- it could remove
+    table rows if they contained only one column with elements that
+    contained no text content.
+  \end{itemize}
+\item
   2019/11/28
 
   \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	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/doc/support/make4ht/readme.tex	2020-01-23 21:55:17 UTC (rev 53514)
@@ -303,6 +303,16 @@
 clean the HTML file using DOM filters. It is more powerful than
 \texttt{common\_filters}. Used DOM filters are \texttt{fixinlines},
 \texttt{idcolons}, \texttt{joincharacters}, and \texttt{tablerows}.
+\item[detect\_engine]
+detect engine and format necessary for the document compilation from the
+magic comments supported by \LaTeX~editors such as TeXShop or TeXWorks.
+Add something like the following line at the beginning of the main
+\TeX~file:
+
+\texttt{\%!TEX\ TS-program\ =\ xelatex}
+
+It supports also Plain \TeX, use for example \texttt{tex} or
+\texttt{luatex} as the program name.
 \item[dvisvgm\_hashes]
 efficient generation of SVG pictures using Dvisvgm. It can utilize
 multiple processor cores and generates only changed images.
@@ -468,6 +478,8 @@
 \item[\texttt{Make:htlatex}]
 One call to the TeX engine with special configuration for loading of the
 \texttt{tex4ht.sty} package.
+\item[\texttt{Make:httex}]
+Variant of \texttt{Make:htlatex} suitable for Plain \TeX.
 \item[\texttt{Make:latexmk}]
 Use \texttt{Latexmk} for the document compilation. \texttt{tex4ht.sty}
 will be loaded automatically.
@@ -639,6 +651,9 @@
 \href{https://www.readbeyond.it/aeneas/}{Aeneas} is a tool for
 automagical synchronization of text and audio. This filter modifies the
 HTML code to support synchronization.
+\item[booktabs]
+fix lines produced by the \texttt{\textbackslash{}cmidrule} command
+provided by the Booktabs package.
 \item[collapsetoc]
 collapse table of contents to contain only top-level sectioning level
 and sections on the current page.

Added: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-booktabs.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-booktabs.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-booktabs.lua	2020-01-23 21:55:17 UTC (rev 53514)
@@ -0,0 +1,82 @@
+
+local function find_cmidrules(current_rows)
+  -- save rows with cmidrules here
+  local matched_rows = {}
+  local continue = false
+  for row_no, row in ipairs(current_rows) do
+    local columnposition = 1
+    local matched_cmidrule = false
+
+    for _, col in ipairs(row:query_selector("td")) do
+      -- keep track of culumns
+      local span = tonumber(col:get_attribute("colspan")) or 1
+      local cmidrule = col:query_selector(".cmidrule")
+      -- column contain cmidrule
+      if #cmidrule > 0 then
+        -- remove any child elements, we don't need them anymore
+        col._children = {}
+        -- only one cmidrule can be on each row, save the position, column span and all attributes
+        matched_rows[row_no] = {attributes = col._attr, column = columnposition, span = span, continue = continue}
+        matched_cmidrule = true
+      end
+      columnposition = columnposition + span
+    end
+    if matched_cmidrule then
+      -- save the row number of the first cmidrule on the current row
+      continue = continue or row_no
+    else
+      continue = false
+    end
+
+  end
+  -- save the table rows count, so we can loop over them sequentially later
+  matched_rows.length = #current_rows
+  return matched_rows
+end
+
+local function update_row(current_rows, match, newspan, i)
+  local row_to_update = current_rows[match.continue]
+  -- insert spanning column if necessary
+  if newspan > 0 then
+    local td = row_to_update:create_element("td", {colspan=tostring(newspan), span="nazdar"})
+    row_to_update:add_child_node(td)
+  end
+  -- insert the rule column
+  local td = row_to_update:create_element("td", match.attributes)
+  row_to_update:add_child_node(td)
+  -- remove unnecessary row
+  current_rows[i]:remove_node()
+end
+
+local function join_rows(matched_rows,current_rows)
+  for i = 1, matched_rows.length do
+    local match = matched_rows[i]
+    if match then
+      -- we only need to process rows that place subsequent cmidrules on the same row
+      local continue = match.continue
+      if continue then
+        local prev_row = matched_rows[continue]
+        -- find column where the previous cmidrule ends
+        local prev_end = prev_row.column + prev_row.span
+        local newspan = match.column - prev_end 
+        update_row(current_rows, match, newspan, i)
+        -- update the current row position
+        prev_row.column = match.column
+        prev_row.span = match.span
+      end
+    end
+  end
+end
+
+local function process_booktabs(dom)
+  local tables = dom:query_selector("table")
+  for _, tbl in ipairs(tables) do
+    local current_rows = tbl:query_selector("tr")
+    local matched_rows = find_cmidrules(current_rows)
+    join_rows(matched_rows, current_rows)
+  end
+  return dom
+end
+
+return process_booktabs
+


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-booktabs.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincharacters.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincharacters.lua	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincharacters.lua	2020-01-23 21:55:17 UTC (rev 53514)
@@ -3,14 +3,35 @@
 local charclasses = {
   span=true,
   mn = true,
-  mi = true
 }
 
+local function update_mathvariant(curr)
+  -- when we join several <mi> elements, they will be rendered incorrectly
+  -- we must set the mathvariant attribute
+  local parent = curr:get_parent()
+  -- set mathvariant only if it haven't been set by the parent element
+  if not parent:get_attribute("mathvariant") then
+    -- curr._attr = curr._attr or {}
+    local mathvariant = "italic"
+    -- the joined elements don't have attributes
+    curr._attr = curr._attr or {}
+    curr:set_attribute("mathvariant", mathvariant)
+  end
+end
+
+local table_count = function(tbl)
+  local tbl = tbl or {}
+  local i = 0
+  for k,v in pairs(tbl) do i = i + 1 end
+  return i
+end
+
+
 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
+  if table_count(next_attr) ~= table_count(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
@@ -18,6 +39,7 @@
   return true
 end
 
+
 local function join_characters(obj,par)
   -- join adjanced span and similar elements inserted by 
   -- tex4ht to just one object.
@@ -25,29 +47,37 @@
   local options = get_filter_settings "joincharacters"
   local charclasses = options.charclasses or par.charclasses or charclasses
 
+  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") or next_el:get_attribute("mathvariant")
+  end
+  local is_span = function(next_el)
+    return charclasses[get_name(next_el)]
+  end
+  local join_elements = function(el, next_el)
+    -- 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)
+    end
+    -- remove the next element
+    next_el:remove_node()
+  end
 
-  obj:traverse_elements(function(el)
-    local get_name = function(curr) 
-      return string.lower(curr:get_element_name())
+  local function get_next(curr, class)
+    local next_el = curr:get_next_node()
+    if next_el and next_el:is_element() and is_span(next_el) then
+      return next_el
+      -- if the next node is space followed by a matching element, we should add this space
+    elseif next_el and next_el:is_text() and get_next(next_el, class) then
+      local text = next_el._text 
+      -- match only text containing just whitespace
+      if text:match("^%s+$") then return next_el end
     end
-    local get_class = function(next_el)
-      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)]
-    end
+  end
 
-    local function get_next(curr, class)
-      local next_el = curr:get_next_node()
-      if next_el and next_el:is_element() and is_span(next_el) then
-        return next_el
-        -- if the next node is space followed by a matching element, we should add this space
-      elseif next_el and next_el:is_text() and get_next(next_el, class) then
-        local text = next_el._text 
-        -- match only text containing just whitespace
-        if text:match("^%s+$") then return next_el end
-      end
-    end
+  obj:traverse_elements(function(el)
     -- loop over all elements and test if the current element is in a list of
     -- processed elements (charclasses)
     if is_span(el) then
@@ -54,16 +84,11 @@
       local next_el = get_next(el)
       -- loop over the following elements and test whether they are of the same type
       -- as the current one
-      while  next_el do
+      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 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)
-          end
-          -- remove the next element
-          next_el:remove_node()
+          join_elements(el, next_el)
           -- add the whitespace
         elseif next_el:is_text() then
           local s = next_el._text
@@ -80,6 +105,36 @@
     end
 
   end)
+  -- process <mi> elements
+  obj:traverse_elements(function(el)
+    local function get_next_mi(curr)
+      local next_el = curr:get_next_node()
+      if next_el and next_el:is_element() then
+        return next_el
+      end
+    end
+    local function has_no_attributes(x)
+      return table_count(x._attr) == 0
+    end
+
+    -- join only subsequential <mi> elements with no attributes
+    if get_name(el) == "mi" and has_no_attributes(el) then
+      local next_el = get_next_mi(el)
+      while next_el do
+        local real_next = get_next_mi(next_el)
+        if get_name(next_el) == "mi" and has_no_attributes(next_el) then
+          join_elements(el, next_el)
+          -- set math variant to italic 
+          -- (if the parent <mstyle> element doesn't set it to something else)
+          update_mathvariant(el)
+        else
+          -- break the loop otherwise
+          real_next = nil
+        end
+        next_el = real_next
+      end
+    end
+  end)
   -- join text nodes in an element into one
   obj:traverse_elements(function(el)
     -- save the text

Modified: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-tablerows.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-tablerows.lua	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-tablerows.lua	2020-01-23 21:55:17 UTC (rev 53514)
@@ -1,5 +1,16 @@
 local log = logging.new ("tablerows")
 return function(dom)
+  local has_child_elements = function(child)
+    -- detect if the element contains child elements
+    local child_elements = 0
+    local children = child:get_children()
+    for _, el in ipairs(children) do
+      local step = el:is_element() and 1 or 0
+      -- log:info("element name", el._name)
+      child_elements = child_elements + step
+    end
+    return child_elements > 0
+  end
   local is_empty_row = function(row)
     local not_empty = false
     local element_count = 0
@@ -11,7 +22,8 @@
       if child:is_element() then 
         element_count = element_count + 1
         -- empty rows contain only one element, it is not empty otherwise
-        if element_count > 1 then return false end
+        if element_count > 1 or has_child_elements(child) then return false end
+
         -- detect if it contains only whitespace
         not_empty = child:get_text():gsub("%s","") ~= "" or not_empty
       end

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	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua	2020-01-23 21:55:17 UTC (rev 53514)
@@ -26,7 +26,7 @@
     make:match("4om$", process, {charclasses= charclasses})
     count = 2
   else
-    local process = filter {"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows"}
+    local process = filter {"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows","booktabs"}
     make:match("html$", process)
     count = 1
   end

Added: trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua	2020-01-23 21:55:17 UTC (rev 53514)
@@ -0,0 +1,91 @@
+-- support magic comments used by TeXShop and TeXWorks to detect used engine and format
+--
+local M = {}
+local log = logging.new("detect engine")
+local htlatex = require "make4ht-htlatex"
+
+-- we must change build sequence when Plain TeX is requested
+local change_table = {
+  tex = {
+    htlatex = "etex",
+    command = htlatex.httex
+  }, 
+  pdftex = {
+    htlatex = "etex",
+    command = htlatex.httex
+  },
+  etex = {
+    htlatex = "etex",
+    command = htlatex.httex
+  },
+  luatex = {
+    htlatex = "dviluatex",
+    command = htlatex.httex
+  },
+  xetex = {
+    htlatex = "xetex -no-pdf",
+    command = htlatex.httex
+  },
+  xelatex = {
+    htlatex = "xelatex -no-pdf",
+  },
+  lualatex = {
+    htlatex = "dvilualatex",
+  },
+  pdflatex = {
+    htlatex = "latex"
+  }
+
+}
+
+local function find_magic_program(filename)
+  -- find the magic line containing program name
+  local get_comment = function(line)
+    return line:match("%s*%%%s*(.+)")
+  end
+  local empty_line = function(line) return line:match("^%s*$") end
+  for line in io.lines(filename) do
+    local comment = get_comment(line)
+    -- read line after line from the file, break the processing after first non comment or non empty line
+    if not comment and not empty_line(line) then return nil, "Cannot find program name" end
+    comment = comment or "" -- comment is nil for empty lines
+    local program = comment:match("!%s*[Tt][Ee][Xx].-program%s*=%s*([^%s]+)")
+    if program then return program:lower() end
+  end
+end
+
+-- update htlatex entries with detected program
+local function update_build_sequence(program, build_seq)
+  -- handle Plain TeX
+  local replaces = change_table[program] or {}
+  local is_xetex = program:match("xe") -- we must handle xetex in tex4ht
+  for pos, entry in ipairs(build_seq) do
+    if entry.name == "htlatex" then
+      -- handle httex
+      entry.command = replaces.command or entry.command
+      local params = entry.params or {}
+      params.htlatex = replaces.htlatex or params.htlatex
+      entry.params = params
+    elseif is_xetex and entry.name == "tex4ht" then
+      -- tex4ht must process .xdv file if the TeX file was compiled by XeTeX
+      entry.params.tex4ht_par = entry.params.tex4ht_par .. " -.xdv"
+    end
+  end
+end
+
+
+function M.modify_build(make)
+  -- find magic comments in the TeX file
+  local build_seq = make.build_seq
+  local tex_file = make.params.tex_file
+  local program, msg = find_magic_program(tex_file)
+  if program then
+    log:info("Found program name", program)
+    update_build_sequence(program, build_seq)
+  else
+    log:warning("Cannot find magic line with the program name")
+  end
+  return make
+end
+
+return M


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/make4ht/make4ht
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht	2020-01-23 21:55:17 UTC (rev 53514)
@@ -29,7 +29,7 @@
 
 -- set version number. the template should be replaced by the
 -- actual version number by the build script
-local version = "v0.3c"
+local version = "v0.3d"
 mkparams.version_number = version
 
 local args = mkparams.get_args()

Modified: trunk/Master/texmf-dist/scripts/make4ht/make4ht-htlatex.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht-htlatex.lua	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht-htlatex.lua	2020-01-23 21:55:17 UTC (rev 53514)
@@ -51,11 +51,17 @@
 "\\documentstyle[tex4ht]}}}\\makeatother\\HCode ${tex4ht_sty_par}.a.b.c."..
 "\\input \"\\detokenize{${tex_file}}\"'"
 
+Make.plain_command = '${htlatex} --interaction=${interaction} ${latex_par}' ..
+"'\\def\\Link#1.a.b.c.{\\expandafter\\def\\csname tex4ht\\endcsname{\\expandafter\\def\\csname tex4ht\\endcsname{#1,html}\\input tex4ht.sty }}" ..
+"\\def\\HCode{\\futurelet\\HCode\\HChar}\\def\\HChar{\\ifx\"\\HCode\\def\\HCode\"##1\"{\\Link##1}\\expandafter\\HCode\\else\\expandafter\\Link\\fi}" ..
+"\\HCode ${tex4ht_sty_par}.a.b.c.\\input \"\\detokenize{${tex_file}}\"'"
 
+
 local m = {}
 
-function m.htlatex(par)
-  local command = Make.latex_command
+function m.htlatex(par, latex_command)
+  -- latex_command can be also plain_command for Plain TeX
+  local command = latex_command or Make.latex_command
   local devnull = " > /dev/null 2>&1"
   if os.type == "windows" then
     command = command:gsub("'",'')
@@ -72,4 +78,15 @@
   return Make.testlogfile(par)
 end
 
+function m.httex(par)
+  local newpar = {}
+  for k,v in pairs(par) do newpar[k] = v end
+  -- change executable name from *latex to *tex
+  newpar.htlatex = newpar.htlatex:gsub("latex", "tex")
+  -- plain tex command doesn't support etex extensions
+  -- which are necessary for TeX4ht. just quick hack to fix this
+  if newpar.htlatex == "tex" then newpar.htlatex = "etex" end
+  return m.htlatex(newpar, Make.plain_command)
+end
+
 return m

Modified: trunk/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua	2020-01-23 21:55:17 UTC (rev 53514)
@@ -177,6 +177,9 @@
   if not status then xindylog:warning(msg) end
   -- remove the temporary idx file
   os.remove(newidxfile)
+  -- null the indfile, it is necessary in order to support
+  -- multiple indices
+  par.indfile = nil
 end
 
 M.get_utf8 = get_utf8

Deleted: trunk/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua	2020-01-23 21:55:17 UTC (rev 53514)
@@ -1,33 +0,0 @@
-local mkutils = require "mkutils"
-local zip = require "zip"
-
-
--- use function to change contents of the ODT file
-local function update_odt(odtfilename, file_path, fn)
-  -- get name of the odt file
-  local odtname = mkutils.remove_extension(odtfilename) .. ".odt"
-  -- open and read contents of the requested file inside ODT file
-  local odtfile = zip.open(odtname)
-  local local_file = odtfile:open(file_path)
-  local content = local_file:read("*all")
-  local_file:close()
-  odtfile:close()
-  -- update the content using user function
-  content = fn(content)
-  -- write the updated file
-  local local_file_file  = io.open(file_path,"w")
-  local_file_file:write(content)
-  local_file_file:close()
-  os.execute("zip " .. odtname .. " " .. file_path)
-  os.remove(file_path)
-end
-
-Make:match("tmp$", function(name, par)
-  update_odt(name, "content.xml", function(content)
-    return content:gsub("%&%#x([A-Fa-f0-9]+);", function(entity)
-      -- convert hexadecimal entity to Unicode
-      print(entity,utfchar(tonumber(entity, 16)))
-      return utfchar(tonumber(entity, 16))
-    end)
-  end)
-end)

Modified: trunk/Master/texmf-dist/scripts/make4ht/mkparams.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/mkparams.lua	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/scripts/make4ht/mkparams.lua	2020-01-23 21:55:17 UTC (rev 53514)
@@ -134,6 +134,11 @@
   return latex_params, input
 end
 
+local function tex_file_not_exits(tex_file)
+  -- try to find the input file, return false if we cannot find it
+  return not (kpse.find_file(tex_file, "tex") or kpse.find_file(tex_file .. ".tex", "tex"))
+end
+
 -- use standard input instead of file if the filename is just `-`
 -- return the filename and status if it is a tmp name
 local function handle_input_file(filename)
@@ -191,6 +196,10 @@
 
 	local compiler = args.lua and "dvilualatex" or args.xetex and "xelatex --no-pdf" or "latex"
   local tex_file, is_tmp_file = handle_input_file(args.filename)
+  -- test if the file exists
+  if not is_tmp_file and tex_file_not_exits(tex_file) then
+    log:warning("Cannot find input file: " .. tex_file)
+  end
 	local input = mkutils.remove_extension(tex_file)
   -- the output file name can be influneced using -jobname parameter passed to the TeX engine
 	local latex_params, input = handle_jobname(input, args) 

Modified: trunk/Master/texmf-dist/scripts/make4ht/mkutils.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/mkutils.lua	2020-01-23 21:54:54 UTC (rev 53513)
+++ trunk/Master/texmf-dist/scripts/make4ht/mkutils.lua	2020-01-23 21:55:17 UTC (rev 53514)
@@ -338,8 +338,11 @@
 local htlatex = require "make4ht-htlatex"
 env.Make:add("htlatex", htlatex.htlatex
 ,{correct_exit=0})
+env.Make:add("htttex", htlatex.httex, {
+  htlatex = "etex",
+  correct_exit=0
+})
 
-
 env.Make:add("latexmk", function(par)
   local settings = get_filter_settings "htlatex" or {}
   par.interaction = par.interaction or settings.interaction or "batchmode"



More information about the tex-live-commits mailing list