texlive[54053] trunk: make4ht (1mar20)

commits+karl at tug.org commits+karl at tug.org
Wed Mar 4 00:05:59 CET 2020


Revision: 54053
          http://tug.org/svn/texlive?view=revision&revision=54053
Author:   karl
Date:     2020-03-04 00:05:59 +0100 (Wed, 04 Mar 2020)
Log Message:
-----------
make4ht (1mar20)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht
    trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex
    trunk/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf
    trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-t4htlinks.lua
    trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua
    trunk/Master/texmf-dist/scripts/make4ht/make4ht
    trunk/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua
    trunk/Master/texmf-dist/scripts/make4ht/mkparams.lua

Added 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-03-03 23:05:43 UTC (rev 54052)
+++ trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht	2020-03-03 23:05:59 UTC (rev 54053)
@@ -29,7 +29,7 @@
 
 -- set version number. the template should be replaced by the
 -- actual version number by the build script
-local version = "v0.3d"
+local version = "v0.3e"
 mkparams.version_number = version
 
 local args = mkparams.get_args()

Modified: trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex	2020-03-03 23:05:43 UTC (rev 54052)
+++ trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex	2020-03-03 23:05:59 UTC (rev 54053)
@@ -3,6 +3,51 @@
 
 \begin{itemize}
 \item
+  2020/02/28
+
+  \begin{itemize}
+  \tightlist
+  \item
+    version \texttt{0.3e\ released}
+  \end{itemize}
+\item
+  2020/02/24
+
+  \begin{itemize}
+  \tightlist
+  \item
+    \texttt{t4htlinks} DOM filter: cleanup file names from internal
+    links.
+  \item
+    \texttt{make4ht-indexing}: added support for splitindex.
+  \end{itemize}
+\item
+  2020/02/19
+
+  \begin{itemize}
+  \tightlist
+  \item
+    use \texttt{UTF-8} output by default. \texttt{8-bit} output is
+    broken and non fixable.
+  \end{itemize}
+\item
+  2020/02/07
+
+  \begin{itemize}
+  \tightlist
+  \item
+    use \texttt{lualatex-dev} instead of \texttt{harflatex}
+  \end{itemize}
+\item
+  2020/02/06
+
+  \begin{itemize}
+  \tightlist
+  \item
+    added support for \texttt{harflatex} and \texttt{harftex} in the
+    \texttt{detect\_engine} extension.
+  \end{itemize}
+\item
   2020/01/22
 
   \begin{itemize}

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

Modified: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-t4htlinks.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-t4htlinks.lua	2020-03-03 23:05:43 UTC (rev 54052)
+++ trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-t4htlinks.lua	2020-03-03 23:05:59 UTC (rev 54053)
@@ -8,6 +8,7 @@
     -- add a link if it contains any subnodes and has href attribute
     if #children > 0 and href then
       link._name = "text:a"
+      href = href:gsub("^.+4oo%#", "#")
       link._attr = {["xlink:type"]="simple", ["xlink:href"]=href}
       -- if the link is named, add a bookmark
       if name then

Modified: trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua	2020-03-03 23:05:43 UTC (rev 54052)
+++ trunk/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua	2020-03-03 23:05:59 UTC (rev 54053)
@@ -34,8 +34,14 @@
   },
   pdflatex = {
     htlatex = "latex"
+  },
+  harflatex = {
+    htlatex = "lualatex-dev --output-format=dvi"
+  },
+  harftex= {
+    htlatex = "harftex --output-format=dvi",
+    command = htlatex.httex
   }
-
 }
 
 local function find_magic_program(filename)

Modified: trunk/Master/texmf-dist/scripts/make4ht/make4ht
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht	2020-03-03 23:05:43 UTC (rev 54052)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht	2020-03-03 23:05:59 UTC (rev 54053)
@@ -29,7 +29,7 @@
 
 -- set version number. the template should be replaced by the
 -- actual version number by the build script
-local version = "v0.3d"
+local version = "v0.3e"
 mkparams.version_number = version
 
 local args = mkparams.get_args()

Modified: trunk/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua	2020-03-03 23:05:43 UTC (rev 54052)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua	2020-03-03 23:05:59 UTC (rev 54053)
@@ -142,8 +142,12 @@
   return true
 end
 
+local get_idxname = function(par)
+  return par.idxfile or par.input .. ".idx"
+end
+
 local prepare_tmp_idx = function(par)
-  par.idxfile = par.idxfile or par.input .. ".idx"
+  par.idxfile = get_idxname(par)
   -- construct the .ind name, based on the .idx name
   par.indfile = par.indfile or par.idxfile:gsub("idx$", "ind")
   load_enc()
@@ -156,10 +160,56 @@
   return  newidxfile, idxdata
 end
 
-local run_indexing_command = function(command, par)
+
+local splitindex = function(par)
+  local files = {}
+  local idxfiles = {}
+  local buffer 
+  local idxfile = get_idxname(par)
+  for line in io.lines(idxfile) do
+    local file = line:match("indexentry%[(.-)%]")
+    if file then
+      -- generate idx name for the current output file
+      file =  par.input .. "-" ..file .. ".idx"
+      local current = files[file] or {}
+      -- remove file name from the index entry
+      local indexentry = line:gsub("indexentry%[.-%]", "indexentry")
+      -- save the index entry and preseding line to the current buffer
+      table.insert(current, buffer)
+      table.insert(current, indexentry)
+      files[file] = current
+    end
+    -- 
+    buffer = line
+  end
+  -- save idx files
+  for filename, contents in pairs(files) do
+    log:info("Saving split index file: " .. filename)
+    idxfiles[#idxfiles+1] = filename
+    local f = io.open(filename, "w")
+    f:write(table.concat(contents, "\n"))
+    f:close()
+  end
+  return idxfiles
+end
+
+local function run_indexing_command (command, par)
   -- detect command name from the command. It will be the first word
   local cmd_name = command:match("^[%a]+") or "indexing"
   local xindylog  = logging.new(cmd_name)
+  -- support split index
+  local subindexes = splitindex(par)
+  if #subindexes > 0 then
+    -- call the command again on all files produced by splitindex
+    for _, subindex in ipairs(subindexes) do
+      -- make copy of the parameters
+      local t = {}
+      for k,v in pairs(par) do t[k] = v end
+      t.idxfile = subindex
+      run_indexing_command(command, t)
+    end
+    return nil
+  end
   local newidxfile, idxdata = prepare_tmp_idx(par)
   if not newidxfile then
     -- the idxdata will contain error message in the case of error
@@ -182,6 +232,7 @@
   par.indfile = nil
 end
 
+
 M.get_utf8 = get_utf8
 M.load_enc = load_enc
 M.parse_idx = parse_idx

Added: trunk/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua	2020-03-03 23:05:59 UTC (rev 54053)
@@ -0,0 +1,33 @@
+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)


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/make4ht/mkparams.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/mkparams.lua	2020-03-03 23:05:43 UTC (rev 54052)
+++ trunk/Master/texmf-dist/scripts/make4ht/mkparams.lua	2020-03-03 23:05:59 UTC (rev 54053)
@@ -29,7 +29,7 @@
   -m,--mode (default default) Switch which can be used in the makefile 
   -n,--no-tex4ht Disable dvi file processing with the tex4ht command
   -s,--shell-escape Enables running external programs from LaTeX
-  -u,--utf8  For output documents in utf8 encoding
+  -u,--utf8  [obsolete] The document is generated in UTF8 encoding by default
   -v,--version  Display version number
   -x,--xetex Use xelatex for document compilation
 ]]
@@ -185,6 +185,12 @@
 		outdir = outdir:gsub('/$','')
 	end
 
+  -- make4ht now requires UTF-8 output, because of DOM filters
+  -- numeric entites are expanded to Unicode characters. These
+  -- characters would be displayed incorrectly in 8 bit encodings.
+
+  args.utf8 = true
+
 	if args.backend == "lua4ht" then
 		args.lua = true
 		args.xetex = nil



More information about the tex-live-commits mailing list.