summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/make4ht/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/make4ht/extensions')
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-build_changed.lua68
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua6
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mjcli.lua36
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-staticsite.lua3
4 files changed, 111 insertions, 2 deletions
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-build_changed.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-build_changed.lua
new file mode 100644
index 00000000000..e0fc5ec6eb2
--- /dev/null
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-build_changed.lua
@@ -0,0 +1,68 @@
+-- this make4ht build file tries to recompile modified blog article sources
+--
+
+-- disable any compilation
+Make.build_seq = {}
+Make:add("tex4ht", "")
+Make:add("t4ht", "")
+
+local log = logging.new "compile newest"
+
+
+
+-- construct the name of the generated HTML file from the .published file
+local function get_generated_html_name(published_file, directory, file_pattern)
+ local f = io.open(directory .. "/" .. published_file, "r")
+ local content = f:read("*all")
+ f:close()
+ local timestamp = tonumber(content)
+ local basename = mkutils.remove_extension(published_file)
+ local tex_file = basename .. ".tex"
+ -- expand fillename in the file_pattern
+ local expanded = file_pattern % {input = basename}
+ -- expand date in the file_pattern
+ expanded = os.date(expanded, timestamp)
+ log:status("found source files :", directory, basename, expanded)
+ return {directory = directory, tex_file = tex_file, generated = expanded .. ".html"}
+end
+
+-- process subdirectories of the basedir and look for the filename.published files
+local function find_published(basedir, file_pattern)
+ local published = {}
+ for f in lfs.dir(basedir) do
+ local fullname = basedir .. "/" .. f
+ local attributes = lfs.attributes(fullname)
+ -- process directories, but ignore . and ..
+ if attributes.mode == "directory" and f ~= "." and f~= ".." then
+ for name in lfs.dir(fullname) do
+ if name:match("published$") then
+ published[#published + 1] = get_generated_html_name(name, fullname, file_pattern)
+ end
+
+ end
+ end
+ end
+ return published
+end
+
+-- find tex files that were modified later than the generated HTML files
+local function find_changed(published, site_root)
+ local keep = {}
+ for _, entry in ipairs(published) do
+ local source_attributes = lfs.attributes(entry.directory .. "/" .. entry.tex_file)
+ local dest_attributes = lfs.attributes(site_root .. "/" .. entry.generated)
+ --
+ print(entry.tex_file, entry.generated, source_attributes.change < dest_attributes.change)
+ end
+end
+
+
+Make:add("rebuild", function(par)
+ local config = get_filter_settings "staticsite"
+ -- how the generated HTML files are named
+ local file_pattern = config.file_pattern or "%Y-%m-%d-${input}"
+ local published = find_published(par.tex_dir, file_pattern)
+ local changed = find_changed(published, config.site_root)
+end)
+
+Make:rebuild{tex_dir = "posts"}
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 c2c4928aeb9..b9a44491bad 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua
@@ -7,8 +7,14 @@ function M.test(format)
return true
end
+function M.prepare_parameters(params)
+ params.tex4ht_sty_par = params.tex4ht_sty_par .. ",mathml"
+ return params
+
+end
function M.modify_build(make)
local mathjax = filter { "mathjaxnode"}
+ -- this extension needs mathml enabled
make:match("html?$",mathjax)
return make
end
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mjcli.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mjcli.lua
new file mode 100644
index 00000000000..e59b419cdf4
--- /dev/null
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mjcli.lua
@@ -0,0 +1,36 @@
+local M = {}
+
+
+local filter = require "make4ht-filter"
+function M.test(format)
+ -- this extension works only for formats based on HTML, as it produces
+ -- custom HTML tags that would be ilegal in XML
+ if not format:match("html5?$") then return false end
+ return true
+end
+
+--
+local detected_latex = false
+function M.prepare_parameters(params)
+ -- mjcli supports both MathML and LaTeX math input
+ -- LaTeX math is keep if user uses "mathjax" option for make4ht
+ -- "mathjax" option used in \Preamble in the .cfg file doesn't work
+ if params.tex4ht_sty_par:match("mathjax") then
+ detected_latex = true
+ else
+ params.tex4ht_sty_par = params.tex4ht_sty_par .. ",mathml"
+ end
+ return params
+
+end
+function M.modify_build(make)
+ local mathjax = filter { "mjcli"}
+ local params = {}
+ if detected_latex then
+ params.latex = true
+ end
+ make:match("html?$",mathjax, params)
+ return make
+end
+
+return M
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 a4204bc1733..5704959970a 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-staticsite.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-staticsite.lua
@@ -125,8 +125,7 @@ function M.modify_build(make)
-- match.params.outdir = outdir
-- print(match.pattern, match.params.outdir)
-- end
- -- make the YAML header only for the main HTML file
- make:match(mainfile .. ".html", process)
+ make:match("html?$", process)
make:match(".*", copy_files, {slug=slug})
end)