From a276123bbbc409023c9148d82eae1f94c79fdd13 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 18 Feb 2022 22:12:02 +0000 Subject: make4ht (18feb22) git-svn-id: svn://tug.org/texlive/trunk@62075 c570f23f-e606-0410-a88d-b1316a301751 --- .../make4ht/domfilters/make4ht-fixinlines.lua | 30 ++++- .../make4ht/domfilters/make4ht-mathmlfixes.lua | 129 ++++++++++++++++++++- .../make4ht/domfilters/make4ht-odtfonts.lua | 26 +++++ .../extensions/make4ht-ext-common_domfilters.lua | 4 +- .../extensions/make4ht-ext-common_filters.lua | 2 +- .../extensions/make4ht-ext-dvisvgm_hashes.lua | 4 +- .../make4ht/extensions/make4ht-ext-join_colors.lua | 2 +- .../make4ht/extensions/make4ht-ext-mathjaxnode.lua | 2 +- .../make4ht/extensions/make4ht-ext-mjcli.lua | 2 +- .../make4ht/extensions/make4ht-ext-odttemplate.lua | 2 +- .../make4ht/extensions/make4ht-ext-staticsite.lua | 9 +- .../scripts/make4ht/filters/make4ht-staticsite.lua | 10 +- .../scripts/make4ht/formats/make4ht-odt.lua | 62 +++++++++- Master/texmf-dist/scripts/make4ht/make4ht | 2 +- .../texmf-dist/scripts/make4ht/make4ht-logging.lua | 10 +- .../texmf-dist/scripts/make4ht/make4ht-xtpipes.lua | 15 ++- Master/texmf-dist/scripts/make4ht/mkparams.lua | 2 +- 17 files changed, 275 insertions(+), 38 deletions(-) create mode 100644 Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtfonts.lua (limited to 'Master/texmf-dist/scripts/make4ht') diff --git a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-fixinlines.lua b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-fixinlines.lua index d1b11b123ef..02338505b78 100644 --- a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-fixinlines.lua +++ b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-fixinlines.lua @@ -41,15 +41,33 @@ local function fix_inlines(obj) local settings = get_filter_settings "fixinlines" local inline_elements = settings.inline_elements or inline_elements local nodes = obj:get_path("html body") + local new = nil obj:traverse_node_list(nodes, function(jej) - if jej._type == "ELEMENT" then - local name = string.lower(jej._name) + if jej._type == "ELEMENT" or jej._type == "TEXT" then + local name = string.lower(jej._name or "") -- local parent = jej:get_parent_node() - if inline_elements[name] then - local new = obj:create_element("p" ) - new:add_child_node(obj:copy_node(jej)) - jej:replace_node(new) + if inline_elements[name] or jej._type == "TEXT" then + if not new then + -- start new paragraph + if jej._type == "TEXT" and jej._text:match("^%s+$") then + -- ignore parts that contain only whitespace and are placed before + -- paragraph start + else + new = obj:create_element("p" ) + new:add_child_node(obj:copy_node(jej)) + jej:replace_node(new) + end + else + -- paragraph already exists + new:add_child_node(obj:copy_node(jej)) + jej:remove_node() + end + else + -- close the current paragraph before new block element + new = nil end + else + new = nil end end) return obj diff --git a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua index 42f1e557752..12754bedb97 100644 --- a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua +++ b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-mathmlfixes.lua @@ -1,3 +1,4 @@ +local log = logging.new("mathmlfixes") -- should be inside , so we don't process it -- even though it is a token element local token = {"mi", "mn", "mo", "mtext", "mspace", "ms"} @@ -37,20 +38,57 @@ local function fix_nested_mstyle(el) end end --- if element contains --- wrap everything in +local function fix_mathvariant(el) + -- set mathvariant of that is child of to have the same value + local function find_mstyle(x) + -- find if element has parent, and its value of mathvariant + if not x:is_element() then + return nil + elseif x:get_element_name() == "mstyle" then + return x:get_attribute("mathvariant") + else + return find_mstyle(x:get_parent()) + end + end + if el:get_element_name() == "mi" then + -- process only that have mathvariant set + local oldmathvariant = el:get_attribute("mathvariant") + if oldmathvariant then + local mathvariant = find_mstyle(el:get_parent()) + if mathvariant then + el:set_attribute("mathvariant", mathvariant) + end + end + end +end + +-- put as child of if it already isn't here +local allowed_top_mrow = { + math=true +} local function top_mrow(math) local children = math:get_children() local put_mrow = false -- don't process elements with one or zero children -- don't process elements that already are mrow - if #children < 2 or math:get_element_name() == "mrow" then return nil end + local parent = math:get_parent() + local parent_name + if parent then parent_name = parent:get_element_name() end + local current_name = math:get_element_name() + if #children < 2 or not allowed_top_mrow[current_name] or current_name == "mrow" or parent_name == "mrow" then return nil end + local mrow_count = 0 for _,v in ipairs(children) do if v:is_element() and is_token_element(v) then put_mrow = true - break + -- break + elseif v:is_element() and v:get_element_name() == "mrow" then + mrow_count = mrow_count + 1 end end + if not put_mrow and math:get_element_name() == "math" and mrow_count == 0 then + -- put at least one to each + put_mrow = true + end if put_mrow then local mrow = math:create_element("mrow") for _, el in ipairs(children) do @@ -122,6 +160,86 @@ local function fix_mo_to_mfenced(el) end end +local function fix_numbers(el) + -- convert 1.3 to 1.3 + if el:get_element_name() == "mn" then + local n = el:get_sibling_node(1) + -- test if next element is . + if n and n:is_element() + and n:get_element_name() == "mo" + and n:get_attribute("class") == "MathClass-punc" + and n:get_text() == "." + then + -- get next element and test if it is + local x = el:get_sibling_node(2) + if x and x:is_element() + and x:get_element_name() == "mn" + then + -- join numbers and set it as text content of the current element + local newnumber = el:get_text() .. "." .. x:get_text() + log:debug("Joining numbers: " .. newnumber) + el._children = {} + local newchild = el:create_text_node(newnumber) + el:add_child_node(newchild) + -- remove elements that hold dot and decimal part + n:remove_node() + x:remove_node() + end + end + end +end + + +local function just_operators(list) + -- count and return true if list contains just them + local mo = 0 + for _, x in ipairs(list) do + if x:get_element_name() == "mo" then mo = mo + 1 end + end + return mo +end + + +local function fix_operators(x) + -- change elements that are only children of any element to + -- this fixes issues in LibreOffice with a^{*} + -- I hope it doesn't introduce different issues + -- process only + if x:get_element_name() ~= "mo" then return nil end + local siblings = x:get_siblings() + -- test if current element list contains only + if just_operators(siblings) == #siblings then + if #siblings == 1 then + -- one translates to + x._name = "mtext" + log:debug("changing one to : " .. x:get_text()) + -- I think we should use , but LO incorrectly renders it in , + -- even if we use the mathvariant="normal" attribute. works, so + -- we use that instead. + -- x:set_attribute("mathvariant", "normal") + else + -- multiple translate to + local text = {} + for _, el in ipairs(siblings) do + text[#text+1] = el:get_text() + end + -- replace first text with concetanated text content + -- of all elements + x._children = {} + local newtext = table.concat(text) + local text_el = x:create_text_node(newtext) + log:debug("changing to : " .. newtext) + x:add_child_node(text_el) + -- change to + x._name = "mtext" + -- remove subsequent + for i = 2, #siblings do + siblings[i]:remove_node() + end + end + end +end + return function(dom) dom:traverse_elements(function(el) if settings.output_format ~= "odt" then @@ -132,6 +250,9 @@ return function(dom) end fix_token_elements(el) fix_nested_mstyle(el) + fix_numbers(el) + fix_operators(el) + fix_mathvariant(el) top_mrow(el) end) return dom diff --git a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtfonts.lua b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtfonts.lua new file mode 100644 index 00000000000..68c8ecadc25 --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtfonts.lua @@ -0,0 +1,26 @@ +return function(dom, params) + -- fix ODT style for fonts + -- sometimes, fonts have missing size, we need to patch styles + local properties = get_filter_settings "odtfonts" or {} + local fix_lgfile_fonts = params.patched_lg_fonts or properties.patched_lg_fonts or {} + for _, style in ipairs(dom:query_selector "style|style") do + local typ = style:get_attribute("style:family") + if typ == "text" then + -- detect if the style is for font + local style_name = style:get_attribute("style:name") + local name, size, size2, size3 = style_name:match("(.-)%-(%d*)x%-(%d*)x%-(%d+)") + if name then + -- find if the style corresponds to a problematic font (it is set in formats/make4ht-odt.lua) + local used_name = name .. "-" .. size + if fix_lgfile_fonts[used_name] then + -- copy current style and fix the name + local new = style:copy_node() + new:set_attribute("style:name", string.format("%s-x-%sx-%s", name, size2, size3)) + local parent = style:get_parent() + parent:add_child_node(new) + end + end + end + end + return dom +end 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 6219c95fbd2..f7fbcdad243 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 @@ -19,14 +19,14 @@ function M.modify_build(make) local count = 0 if current_format == "odt" then -- some formats doesn't make sense in the ODT format - local process = filter {"joincharacters", "mathmlfixes"} + local process = filter ({"joincharacters", "mathmlfixes"}, "commondomfilters") local charclasses = {mn = true, ["text:span"] = true, mi=true} make:match("4oo$", process, {charclasses= charclasses}) -- match math documents make:match("4om$", process, {charclasses= charclasses}) count = 2 else - local process = filter {"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows","booktabs", "sectionid", "itemparagraphs"} + local process = filter({"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows","booktabs", "sectionid", "itemparagraphs"}, "commondomfilters") make:match("html?$", process) count = 1 end 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 9b3e7f3f74d..0d0ee979fd5 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 @@ -2,7 +2,7 @@ local M = {} local filter = require "make4ht-filter" -local process = filter {"cleanspan-nat", "fixligatures", "hruletohr", "entities", "fix-links"} +local process = filter({"cleanspan-nat", "fixligatures", "hruletohr", "entities", "fix-links"}, "commonfilters") -- filters support only html formats function M.test(format) 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 8bf82e05889..53da32c3be3 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 @@ -243,7 +243,7 @@ function M.modify_build(make) end) -- fix src attributes - local process = filter { + local process = filter({ function(str, filename) return str:gsub('src=["\'](.-)(["\'])', function(filename, endquote) local newname = output_map[filename] or filename @@ -251,7 +251,7 @@ function M.modify_build(make) return 'src=' .. endquote .. newname .. endquote end) end - } + }, "dvisvgmhashes") make:match("htm.?$", process) 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 4d72b0e15b5..11e6d66fd21 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 @@ -9,7 +9,7 @@ function M.test(format) end function M.modify_build(make) - local process = filter {"joincolors"} + local process = filter({"joincolors"}, "joincolors") make:match("html?$", process) return make end 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 b9a44491bad..3b57351d05f 100644 --- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua +++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua @@ -13,7 +13,7 @@ function M.prepare_parameters(params) end function M.modify_build(make) - local mathjax = filter { "mathjaxnode"} + local mathjax = filter({ "mathjaxnode"}, "mathjaxnode") -- this extension needs mathml enabled make:match("html?$",mathjax) return make diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mjcli.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mjcli.lua index e59b419cdf4..8a60fab610d 100644 --- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mjcli.lua +++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mjcli.lua @@ -24,7 +24,7 @@ function M.prepare_parameters(params) end function M.modify_build(make) - local mathjax = filter { "mjcli"} + local mathjax = filter({ "mjcli"}, "mjcli") local params = {} if detected_latex then params.latex = true diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-odttemplate.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-odttemplate.lua index 3b0af2a6999..b3607fa4773 100644 --- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-odttemplate.lua +++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-odttemplate.lua @@ -8,7 +8,7 @@ M.test = function(format) end M.modify_build = function(make) - local process = filter {"odttemplate"} + local process = filter({"odttemplate"}, "odttemplate") make:match("4oy$", process) return make end diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-staticsite.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-staticsite.lua index a9a5bcece7c..b9272203a52 100644 --- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-staticsite.lua +++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-staticsite.lua @@ -22,6 +22,7 @@ local function get_slug(settings) -- escape -- slug must contain the unescaped input name local f = io.open(published_name, "w") + log:info("Publishing article", os.date("%Y-%m-%d %H:%M", time)) f:write(time) f:close() end @@ -79,7 +80,7 @@ end local function remove_maketitle(make) -- use DOM filter to remove \maketitle block local domfilter = require "make4ht-domfilter" - local process = domfilter { + local process = domfilter({ function(dom) local maketitles = dom:query_selector(".maketitle") for _, el in ipairs(maketitles) do @@ -88,7 +89,7 @@ local function remove_maketitle(make) end return dom end - } + }, "staticsite") make:match("html$", process) end @@ -120,9 +121,9 @@ function M.modify_build(make) -- we use an bogus match which will be executed only once as the very first one to insert -- the filters -- I should make filter from this - local process = filter { + local process = filter({ "staticsite" - } + }, "staticsite") -- detect if we should remove maketitle local site_settings = get_filter_settings "staticsite" diff --git a/Master/texmf-dist/scripts/make4ht/filters/make4ht-staticsite.lua b/Master/texmf-dist/scripts/make4ht/filters/make4ht-staticsite.lua index 5620f9c8bb6..fba4d220b10 100644 --- a/Master/texmf-dist/scripts/make4ht/filters/make4ht-staticsite.lua +++ b/Master/texmf-dist/scripts/make4ht/filters/make4ht-staticsite.lua @@ -58,13 +58,17 @@ local function update_properties(properties, dom) -- enable properties update from the config or build file local settings = get_filter_settings "staticsite" or {} local header = settings.header or {} + -- set non-function properties first + for field, rule in pairs(header) do + if type(rule) ~="function" then + properties[field] = rule + end + end + -- then execute functions. it ensures that all propeties set in header are available for field, rule in pairs(header) do -- it is possible to pass function as a rule, it will be executed with properties as a parameter if type(rule) == "function" then properties[field] = rule(properties, dom) - else - -- otherwise set properties - properties[field] = rule end end return properties diff --git a/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua index f3721eba00b..01a587aff47 100644 --- a/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua +++ b/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua @@ -73,10 +73,10 @@ function Odtfile:pack() lfs.chdir(self.archivelocation) -- make temporary mime type file self:make_mimetype() - mkutils.execute(zip_command .. " -q0X " .. self.name .. " " .. self.mimetypename) + mkutils.execute(zip_command .. " -q0X '" .. self.name .. "' " .. self.mimetypename) -- remove it, so the next command doesn't overwrite it self:remove_mimetype() - mkutils.execute(zip_command .." -r " .. self.name .. " *") + mkutils.execute(zip_command .." -r '" .. self.name .. "' *") lfs.chdir(currentdir) mkutils.cp(self.archivelocation .. "/" .. self.name, self.name) mkutils.delete_dir(self.archivelocation) @@ -164,13 +164,64 @@ local function fix_picture_sizes(tmpdir) f:close() end +-- fix font records in the lg file that don't correct Font_Size record +local lg_fonts_processed=false +local patched_lg_fonts = {} +local function fix_lgfile_fonts(ignored_name, params) + -- this function is called from file match. we must use the name of the .lg file + local filename = params.input .. ".lg" + if not lg_fonts_processed then + local lines = {} + -- default font_size + local font_size = "10" + if mkutils.file_exists(filename) then + -- + for line in io.lines(filename) do + -- default font_size can be set in the .lg file + if line:match("Font_Size") then + font_size = line:match("Font_Size:%s*(%d+)") + elseif line:match("Font%(") then + -- match Font record + local name, size, size2, size3 = line:match('Font%("([^"]+)","([%d]*)","([%d]+)","([%d]+)"') + -- find if the first size is not set, and add the default font_size then + if size == "" then + line = string.format('Font("%s","%s","%s","%s")', name, font_size, size2, size3) + -- we must also save the font name and size for later post-processing, because + -- we will need to fix styles in content.xml too + patched_lg_fonts[name .. "-" .. font_size] = true + end + end + lines[#lines+1] = line + end + -- save changed lines to the lg file + local f = io.open(filename, "w") + for _,line in ipairs(lines) do + f:write(line .. "\n") + end + f:close() + end + filter_settings "odtfonts" {patched_lg_fonts = patched_lg_fonts} + end + lg_fonts_processed=true + return true +end + +local move_matches = xtpipeslib.move_matches + +local function insert_lgfile_fonts(make) + local first_file = make.params.input .. ".4oo" + -- find the last file and escape it so it can be used + -- in filename match + make:match(first_file, fix_lgfile_fonts) + move_matches(make) +end + -- escape string to be used in the gsub search local function escape_file(filename) local quotepattern = '(['..("%^$().[]*+-?"):gsub("(.)", "%%%1")..'])' return filename:gsub(quotepattern, "%%%1") end -local move_matches = xtpipeslib.move_matches -- call xtpipes from Lua local function call_xtpipes(make) @@ -185,6 +236,8 @@ local function call_xtpipes(make) -- we need to move last two matches, for 4oo and 4om files move_matches(make) move_matches(make) + -- fix font records in the lg file + insert_lgfile_fonts(make) else log:warning "Cannot locate xtpipes. Try to set TEXMFROOT variable to a root directory of your TeX distribution" end @@ -231,6 +284,9 @@ function M.modify_build(make) -- fixes for mathml local mathmldomfilters = domfilter({"joincharacters","mathmlfixes"}, "mathmlfilters") make:match("4om$", mathmldomfilters) + -- DOM filters that should be executed after xtpipes + local latedom = domfilter({"odtfonts"}, "lateodtfilters") + make:match("4oo$", latedom) -- convert XML entities for Unicode characters produced by Xtpipes to characters local fixentities = filter {"entities-to-unicode", remove_xtpipes} make:match("4oo", fixentities) diff --git a/Master/texmf-dist/scripts/make4ht/make4ht b/Master/texmf-dist/scripts/make4ht/make4ht index 74a9c22d2b9..b938fdede1e 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.3j" +local version = "v0.3k" mkparams.version_number = version local args = mkparams.get_args() diff --git a/Master/texmf-dist/scripts/make4ht/make4ht-logging.lua b/Master/texmf-dist/scripts/make4ht/make4ht-logging.lua index 63b11433ea4..0f195689c2e 100755 --- a/Master/texmf-dist/scripts/make4ht/make4ht-logging.lua +++ b/Master/texmf-dist/scripts/make4ht/make4ht-logging.lua @@ -4,7 +4,8 @@ local logging = {} local levels = {} -- level of bugs that should be shown -local show_level = 1 +-- enable querying of current log level +logging.show_level = 1 local max_width = 0 local max_status = 0 @@ -34,7 +35,7 @@ end -- the logging level is set once function logging.set_level(name) local level = levels[name] or 1 - show_level = level + logging.show_level = level end function logging.print_msg(header, message, color) @@ -53,7 +54,7 @@ function logging.new(module) module = module, output = function(self, output) -- used for printing of output of commands - if show_level <= (levels[debug] or 1) then + if logging.show_level <= (levels["debug"] or 1) then print(output) end end @@ -68,7 +69,7 @@ function logging.new(module) -- set make4ht exit status max_status = math.max(status, max_status) -- max width is saved in logging.prepare_levels - if mode.level >= show_level then + if mode.level >= logging.show_level then -- support variable number of parameters local table_with_holes = table.pack(...) local table_without_holes = {} @@ -106,6 +107,7 @@ logging.prepare_levels() -- logging.set_level("error") -- cls:info("level set") -- cls:error("just print the error") +-- return logging diff --git a/Master/texmf-dist/scripts/make4ht/make4ht-xtpipes.lua b/Master/texmf-dist/scripts/make4ht/make4ht-xtpipes.lua index 3f5b51e07b8..544663fb899 100755 --- a/Master/texmf-dist/scripts/make4ht/make4ht-xtpipes.lua +++ b/Master/texmf-dist/scripts/make4ht/make4ht-xtpipes.lua @@ -48,18 +48,27 @@ function M.get_xtpipes(selfautoparent) mkutils.mv(filename, tmpfile) local command = pattern % {filename = tmpfile, outputfile = filename} log:info("execute: " ..command) - local status = mkutils.execute(command) + local status, output = mkutils.execute(command) if status > 0 then -- if xtpipes failed to process the file, it may mean that it was bad-formed xml -- we can try to make it well-formed using Tidy local tidy_command = 'tidy -utf8 -xml -asxml -q -o "${filename}" "${tmpfile}"' % {tmpfile = tmpfile, filename = filename} - log:warning("xtpipes failed trying tidy") + log:warning("Xtpipes failed") + -- show_level 1 is debug mode, which prints command output as well + -- we need this condition to prevent multiple instances of the output + if logging.show_level > 1 then + print(output) + end + log:warning("Trying HTML tidy") log:debug(tidy_command) - local status = os.execute(tidy_command) + local status, output = os.execute(tidy_command) if status > 0 then -- if tidy failed as well, just use the original file -- it will probably produce corrupted ODT file though log:warning("Tidy failed as well") + if logging.show_level > 1 then + print(output) + end mkutils.mv(tmpfile, filename) end end diff --git a/Master/texmf-dist/scripts/make4ht/mkparams.lua b/Master/texmf-dist/scripts/make4ht/mkparams.lua index 5517c0a19f3..e330b6a0abd 100755 --- a/Master/texmf-dist/scripts/make4ht/mkparams.lua +++ b/Master/texmf-dist/scripts/make4ht/mkparams.lua @@ -108,7 +108,7 @@ local function handle_jobname(input, args) input = input:match("([^%/^%\\]+)$") -- input also cannot contain spaces, replace them with underscores input = input:gsub("%s", "_") - table.insert(latex_params,"-jobname="..input) + table.insert(latex_params,"-jobname='"..input.. "'") else -- when user specifies -jobname, we must change name of the input file, -- in order to be able to process correct dvi file with tex4ht and t4ht -- cgit v1.2.3