diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-03 23:05:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-03 23:05:59 +0000 |
commit | a5b08d6e4f20abd36645525e5907068dd1b6743b (patch) | |
tree | 21aa21d4a848402205fe76fe50fee254e805cbc0 | |
parent | bb0d98952d1aee8d64d8f04a6352b4b761955ed4 (diff) |
make4ht (1mar20)
git-svn-id: svn://tug.org/texlive/trunk@54053 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/make4ht/make4ht | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/support/make4ht/changelog.tex | 45 | ||||
-rw-r--r-- | Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf | bin | 130605 -> 131544 bytes | |||
-rw-r--r-- | Master/texmf-dist/scripts/make4ht/domfilters/make4ht-t4htlinks.lua | 1 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua | 8 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/make4ht/make4ht | 2 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua | 55 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua | 33 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/make4ht/mkparams.lua | 8 |
9 files changed, 148 insertions, 6 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/make4ht/make4ht b/Build/source/texk/texlive/linked_scripts/make4ht/make4ht index d90bd5b9704..50917bd57ec 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.3d" +local version = "v0.3e" mkparams.version_number = version local args = mkparams.get_args() diff --git a/Master/texmf-dist/doc/support/make4ht/changelog.tex b/Master/texmf-dist/doc/support/make4ht/changelog.tex index d67418081f7..13effe5fd03 100644 --- a/Master/texmf-dist/doc/support/make4ht/changelog.tex +++ b/Master/texmf-dist/doc/support/make4ht/changelog.tex @@ -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} 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 287a06722ad..371e3e3fb81 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/scripts/make4ht/domfilters/make4ht-t4htlinks.lua b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-t4htlinks.lua index 9a4efb97395..e602f02fd12 100644 --- a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-t4htlinks.lua +++ b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-t4htlinks.lua @@ -8,6 +8,7 @@ return function(dom) -- 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 diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua index 8bb91d3a697..6c8bc74106b 100644 --- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua +++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua @@ -34,8 +34,14 @@ local change_table = { }, 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) diff --git a/Master/texmf-dist/scripts/make4ht/make4ht b/Master/texmf-dist/scripts/make4ht/make4ht index d90bd5b9704..50917bd57ec 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.3d" +local version = "v0.3e" mkparams.version_number = version local args = mkparams.get_args() diff --git a/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua b/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua index 072536556a8..a86fd139aa2 100755 --- a/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua +++ b/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua @@ -142,8 +142,12 @@ local process_index = function(indname, idx) 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 @@ local prepare_tmp_idx = function(par) 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 @@ local run_indexing_command = function(command, par) par.indfile = nil end + M.get_utf8 = get_utf8 M.load_enc = load_enc M.parse_idx = parse_idx diff --git a/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua b/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua new file mode 100755 index 00000000000..97f0b8df670 --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua @@ -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) diff --git a/Master/texmf-dist/scripts/make4ht/mkparams.lua b/Master/texmf-dist/scripts/make4ht/mkparams.lua index 0254de9ac23..5517c0a19f3 100755 --- a/Master/texmf-dist/scripts/make4ht/mkparams.lua +++ b/Master/texmf-dist/scripts/make4ht/mkparams.lua @@ -29,7 +29,7 @@ Available options: -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 @@ local function process_args(args) 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 |