summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-03-03 23:05:59 +0000
committerKarl Berry <karl@freefriends.org>2020-03-03 23:05:59 +0000
commita5b08d6e4f20abd36645525e5907068dd1b6743b (patch)
tree21aa21d4a848402205fe76fe50fee254e805cbc0 /Master/texmf-dist/scripts
parentbb0d98952d1aee8d64d8f04a6352b4b761955ed4 (diff)
make4ht (1mar20)
git-svn-id: svn://tug.org/texlive/trunk@54053 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rw-r--r--Master/texmf-dist/scripts/make4ht/domfilters/make4ht-t4htlinks.lua1
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-detect_engine.lua8
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht2
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht-indexing.lua55
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua33
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/mkparams.lua8
6 files changed, 102 insertions, 5 deletions
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