diff options
Diffstat (limited to 'support/make4ht/filters')
-rw-r--r-- | support/make4ht/filters/make4ht-domfilter.lua | 7 | ||||
-rw-r--r-- | support/make4ht/filters/make4ht-entities-to-unicode.lua | 8 | ||||
-rw-r--r-- | support/make4ht/filters/make4ht-mathjaxnode.lua | 11 | ||||
-rw-r--r-- | support/make4ht/filters/make4ht-staticsite.lua | 6 | ||||
-rw-r--r-- | support/make4ht/filters/make4ht-svg-height.lua | 4 |
5 files changed, 21 insertions, 15 deletions
diff --git a/support/make4ht/filters/make4ht-domfilter.lua b/support/make4ht/filters/make4ht-domfilter.lua index 27d9ed871d..f6df769d60 100644 --- a/support/make4ht/filters/make4ht-domfilter.lua +++ b/support/make4ht/filters/make4ht-domfilter.lua @@ -1,6 +1,7 @@ local filter_lib = require "make4ht-filterlib" local dom = require "luaxml-domobject" local mkutils = require "mkutils" +local log = logging.new "domfilter" local function load_filter(filtername) return require("domfilters.make4ht-"..filtername) @@ -42,8 +43,8 @@ local function filter(filters, name) return dom.parse(input) end) if not status then - print("DOM parsing of " .. filename .. " failed:") - print(domobject) + log:warning("DOM parsing of " .. filename .. " failed:") + log:warning(domobject) return nil, "DOM parsing failed" end for _,f in pairs(sequence) do @@ -53,7 +54,7 @@ local function filter(filters, name) if output then filter_lib.save_input_file(filename, output) else - print("DOM filter failed on ".. filename) + log:warning("DOM filter failed on ".. filename) end -- mark the filename as processed processed_files[filename] = true diff --git a/support/make4ht/filters/make4ht-entities-to-unicode.lua b/support/make4ht/filters/make4ht-entities-to-unicode.lua index fb921a631a..4bf106a79f 100644 --- a/support/make4ht/filters/make4ht-entities-to-unicode.lua +++ b/support/make4ht/filters/make4ht-entities-to-unicode.lua @@ -6,10 +6,12 @@ local disabled = { ["&"] = "&", ["<"] = "<", [">"] = ">"} return function(content) local content = content:gsub("%&%#x([A-Fa-f0-9]+);", function(entity) -- convert hexadecimal entity to Unicode - local newchar = utfchar(tonumber(entity, 16)) + local char_number = tonumber(entity, 16) + -- fix for non-breaking spaces, LO cannot open file when they are present as Unicode + if char_number == 160 then return " " end + local newchar = utfchar(char_number) -- we don't want to break XML validity with forbidden characters return disabled[newchar] or newchar end) - -- the non-breaking space character cause issues in the ODT opening - return content:gsub(string.char(160), " ") + return content end diff --git a/support/make4ht/filters/make4ht-mathjaxnode.lua b/support/make4ht/filters/make4ht-mathjaxnode.lua index 2b453e4255..748ecfd483 100644 --- a/support/make4ht/filters/make4ht-mathjaxnode.lua +++ b/support/make4ht/filters/make4ht-mathjaxnode.lua @@ -1,4 +1,5 @@ local mkutils = require "mkutils" +local log = logging.new("mathjaxnode") -- other possible value is page2svg local mathnodepath = "mjpage" -- options for MathJax command @@ -13,13 +14,13 @@ local cssfilename = "mathjax-chtml.css" local function compile(text) local tmpfile = os.tmpname() - print("Compile using MathJax") + log:info("Compile using MathJax") local command = mathnodepath .. " ".. options .. " > " .. tmpfile - print(command) + log:info(command) local commandhandle = io.popen(command,"w") commandhandle:write(text) commandhandle:close() - print("Result written to: ".. tmpfile) + log:info("Result written to: ".. tmpfile) local f = io.open(tmpfile) local content = f:read("*all") f:close() @@ -53,7 +54,7 @@ local function use_fonts(css) if not face:match("url%(") then return face end -- print(face) local family, filename = face:match(family_pattern) - print(family, filename) + log:info("use font: ",family, filename) local newfile = string.format("%s/%s.%s", fontdir, filename, fontformat) Make:add_file(newfile) return family_build:format(family, fontdir, filename, fontformat, fontformat) @@ -89,6 +90,6 @@ return function(text, arguments) save_css(cssfile, css) Make:add_file(cssfile) -- print(css) - print(cssfile) + log:info("CSS file: " .. cssfile) return newtext end diff --git a/support/make4ht/filters/make4ht-staticsite.lua b/support/make4ht/filters/make4ht-staticsite.lua index 6378f0440a..969d47ecaa 100644 --- a/support/make4ht/filters/make4ht-staticsite.lua +++ b/support/make4ht/filters/make4ht-staticsite.lua @@ -1,4 +1,5 @@ local domobj = require "luaxml-domobject" +local log = logging.new("staticsite") -- save the header settings in YAML format local function make_yaml(tbl, level) local t = {} @@ -69,7 +70,6 @@ local function get_header(tbl) end return function(s,par) - print(os.getenv "blog_home") local dom = domobj.parse(s) local properties = {} local head = dom:query_selector("head")[1] @@ -84,7 +84,7 @@ return function(s,par) properties.styles = styles local metas = {} for _, meta in ipairs(head:query_selector("meta")) do - print(meta:serialize()) + log:debug("parsed meta: " .. meta:serialize()) table.insert(metas, {charset= meta:get_attribute("charset"), content = meta:get_attribute("content"), property = meta:get_attribute("property"), name = meta:get_attribute("name")}) end properties.meta = metas @@ -92,7 +92,7 @@ return function(s,par) local body = dom:query_selector("body")[1] - print(get_header(properties)) + log:debug(get_header(properties)) -- return s return get_header(properties) .. body:serialize():gsub("<body.->", ""):gsub("</body>", "") end diff --git a/support/make4ht/filters/make4ht-svg-height.lua b/support/make4ht/filters/make4ht-svg-height.lua index 44e98748ea..bb9f8dbdc6 100644 --- a/support/make4ht/filters/make4ht-svg-height.lua +++ b/support/make4ht/filters/make4ht-svg-height.lua @@ -1,6 +1,8 @@ +local log = logging.new("svg-height") -- Make:image("svg$", "dvisvgm -n -a -p ${page} -b preview -c 1.4,1.4 -s ${source} > ${output}") + local max = function(a,b) return a > b and a or b end @@ -34,7 +36,7 @@ return function(svg) max_height = get_max_height(path, max_height) end -- update the height only if the max_height is larger than height set in the SVG file - print(max_height, height) + log:debug("max height and height", max_height, height) if max_height > height then svg = update_height(svg, max_height) end |