summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/make4ht
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-09-07 21:20:51 +0000
committerKarl Berry <karl@freefriends.org>2020-09-07 21:20:51 +0000
commit5c122b3fd45bd3b2708e3fc0927e84243d548709 (patch)
tree8930267a2d57bcd925d66d3f3d240e1c4b7a956b /Master/texmf-dist/scripts/make4ht
parent3581485c7b70a58b3297157f006b3260ce2b11c0 (diff)
make4ht (7sep20)
git-svn-id: svn://tug.org/texlive/trunk@56284 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/make4ht')
-rw-r--r--Master/texmf-dist/scripts/make4ht/domfilters/make4ht-fixinlines.lua1
-rw-r--r--Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua1
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua2
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_filters.lua2
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua6
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-join_colors.lua2
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua2
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-tidy.lua2
-rw-r--r--Master/texmf-dist/scripts/make4ht/formats/make4ht-jats.lua14
-rw-r--r--Master/texmf-dist/scripts/make4ht/formats/make4ht-tei.lua17
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht4
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht-errorlogparser.lua5
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht-indexing.lua2
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua33
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/mkutils.lua9
15 files changed, 55 insertions, 47 deletions
diff --git a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-fixinlines.lua b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-fixinlines.lua
index 25489f59ca5..d1b11b123ef 100644
--- a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-fixinlines.lua
+++ b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-fixinlines.lua
@@ -1,4 +1,5 @@
local inline_elements = {
+ a=true,
b=true,
big=true,
i=true,
diff --git a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua
index a52b0e5d6b1..3e044b94453 100644
--- a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua
+++ b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua
@@ -28,6 +28,7 @@ local function fix_nested_mstyle(el)
-- 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._attr = parent._attr or {}
parent:set_attribute("mathvariant", mathvariant)
end
-- copy the contents of <mstyle> to the parent element
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua
index 63232b22cec..802902d48d7 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua
@@ -27,7 +27,7 @@ function M.modify_build(make)
count = 2
else
local process = filter {"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows","booktabs"}
- make:match("html$", process)
+ make:match("html?$", process)
count = 1
end
return make
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_filters.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_filters.lua
index 513fbed34ee..9b3e7f3f74d 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_filters.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_filters.lua
@@ -11,7 +11,7 @@ function M.test(format)
end
function M.modify_build(make)
- make:match("html$", process)
+ make:match("html?$", process)
local matches = make.matches
-- the filters should be first match to be executed, especially if tidy
-- should be executed as well
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
index 87f58abd57c..8bf82e05889 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
@@ -244,11 +244,11 @@ function M.modify_build(make)
-- fix src attributes
local process = filter {
- function(str)
- return str:gsub('src="([^"]+)', function(filename)
+ function(str, filename)
+ return str:gsub('src=["\'](.-)(["\'])', function(filename, endquote)
local newname = output_map[filename] or filename
log:debug("newname", newname)
- return 'src="'.. newname
+ return 'src=' .. endquote .. newname .. endquote
end)
end
}
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-join_colors.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-join_colors.lua
index 182661fbdbc..4d72b0e15b5 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-join_colors.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-join_colors.lua
@@ -10,7 +10,7 @@ end
function M.modify_build(make)
local process = filter {"joincolors"}
- make:match("html$", process)
+ make:match("html?$", process)
return make
end
return M
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua
index cbad897d4ec..c2c4928aeb9 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua
@@ -9,7 +9,7 @@ end
function M.modify_build(make)
local mathjax = filter { "mathjaxnode"}
- make:match("html$",mathjax)
+ make:match("html?$",mathjax)
return make
end
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-tidy.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-tidy.lua
index b381a05a8fb..8318a8b8949 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-tidy.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-tidy.lua
@@ -38,7 +38,7 @@ end
function M.modify_build(make)
- make:match("html$", function(filename, par)
+ make:match("html?$", function(filename, par)
local settings = get_filter_settings "tidy" or {}
par.options = par.options or settings.options or "-utf8 -w 512 -ashtml -q"
local command = "tidy ${options} ${filename}" % par
diff --git a/Master/texmf-dist/scripts/make4ht/formats/make4ht-jats.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-jats.lua
new file mode 100644
index 00000000000..13bcd86d41e
--- /dev/null
+++ b/Master/texmf-dist/scripts/make4ht/formats/make4ht-jats.lua
@@ -0,0 +1,14 @@
+local M = {}
+local xtpipeslib = require "make4ht-xtpipes"
+
+function M.prepare_parameters(settings, extensions)
+ settings.tex4ht_sty_par = settings.tex4ht_sty_par ..",jats"
+ settings = mkutils.extensions_prepare_parameters(extensions, settings)
+ return settings
+end
+
+function M.prepare_extensions(extensions)
+ return extensions
+end
+
+return M
diff --git a/Master/texmf-dist/scripts/make4ht/formats/make4ht-tei.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-tei.lua
index f81953a8b31..660f6d49d83 100644
--- a/Master/texmf-dist/scripts/make4ht/formats/make4ht-tei.lua
+++ b/Master/texmf-dist/scripts/make4ht/formats/make4ht-tei.lua
@@ -1,6 +1,8 @@
local M = {}
local xtpipeslib = require "make4ht-xtpipes"
+local domfilter = require "make4ht-domfilter"
+
function M.prepare_parameters(settings, extensions)
settings.tex4ht_sty_par = settings.tex4ht_sty_par ..",tei"
settings = mkutils.extensions_prepare_parameters(extensions, settings)
@@ -11,4 +13,19 @@ function M.prepare_extensions(extensions)
return extensions
end
+function M.modify_build(make)
+ local process = domfilter {
+ "joincharacters"
+ }
+
+ -- we use <hi> elements for characters styled using HTF fonts in TEI
+ -- use the `joincharacters` DOM filter to join them
+ filter_settings "joincharacters" {
+ charclasses = { hi=true, mn = true}
+ }
+
+ make:match("xml$", process)
+ return make
+end
+
return M
diff --git a/Master/texmf-dist/scripts/make4ht/make4ht b/Master/texmf-dist/scripts/make4ht/make4ht
index 50917bd57ec..079c464ecd2 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.3e"
+local version = "v0.3f"
mkparams.version_number = version
local args = mkparams.get_args()
@@ -43,7 +43,7 @@ local mode = parameters.mode
local build_file = parameters.build_file
-- handle output formats
-local allowed_output_formats = {xhtml = true, html5=true, odt = true, docbook=true, tei=true}
+local allowed_output_formats = {xhtml = true, html5=true, odt = true, docbook=true, tei=true, jats=true}
-- formatter is Lua library which must provide at least prepare_parameters
-- and process_build_sequence functions
local formatter
diff --git a/Master/texmf-dist/scripts/make4ht/make4ht-errorlogparser.lua b/Master/texmf-dist/scripts/make4ht/make4ht-errorlogparser.lua
index b48957c6514..e536370ac98 100755
--- a/Master/texmf-dist/scripts/make4ht/make4ht-errorlogparser.lua
+++ b/Master/texmf-dist/scripts/make4ht/make4ht-errorlogparser.lua
@@ -1,7 +1,10 @@
local m = {}
local function get_filename(chunk)
- local filename = chunk:match("([^\n^%(]+)")
+ local filename = chunk:match("([^\n^%(]+)")
+ if not filename then
+ return false, "No filename detected"
+ end
local first = filename:match("^[%./\\]+")
if first then return filename end
return false
diff --git a/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua b/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua
index a86fd139aa2..eb9c9b50172 100755
--- a/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua
+++ b/Master/texmf-dist/scripts/make4ht/make4ht-indexing.lua
@@ -75,7 +75,7 @@ local parse_idx = function(content)
if line:match("^\\beforeentry") then
-- increment index entry number
current_entry = current_entry + 1
- local file, dest = line:match("\\beforeentry{(.-)}{(.-)}")
+ local file, dest = line:match("\\beforeentry%s*{(.-)}{(.-)}")
map[current_entry] = {file = file, dest = dest}
elseif line:match("^\\indexentry") then
-- replace the page number with the current
diff --git a/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua b/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua
deleted file mode 100755
index 97f0b8df670..00000000000
--- a/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua
+++ /dev/null
@@ -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)
diff --git a/Master/texmf-dist/scripts/make4ht/mkutils.lua b/Master/texmf-dist/scripts/make4ht/mkutils.lua
index a4f16fb71ad..38a49663157 100755
--- a/Master/texmf-dist/scripts/make4ht/mkutils.lua
+++ b/Master/texmf-dist/scripts/make4ht/mkutils.lua
@@ -118,6 +118,9 @@ function cp(src,dest)
local command = string.format('%s "%s" "%s"', cp_func, src, dest)
if cp_func == "copy" then command = command:gsub("/",'\\') end
log:info("Copy: "..command)
+ if not file_exists(src) then
+ log:error("File " .. src .. " doesn't exist")
+ end
os.execute(command)
end
@@ -264,9 +267,11 @@ end
local main_settings = {}
main_settings.fonts = {}
-local env = {}
+-- use global environment in the build file
+-- it used to be sandboxed, but it proved not to be useful at all
+local env = _G ---{}
--- We make sandbox for make script, all functions must be explicitely declared
+-- explicitly enale some functions and modules in the sandbox
-- Function declarations:
env.pairs = pairs
env.ipairs = ipairs