summaryrefslogtreecommitdiff
path: root/support/make4ht/extensions
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-07-27 03:01:57 +0000
committerNorbert Preining <norbert@preining.info>2021-07-27 03:01:57 +0000
commitcef58753eba8ad7e2071195dbd92454febe82d32 (patch)
treedf909696e42fb25ce108e30258c7f935ded86079 /support/make4ht/extensions
parent84465d50d746dfed1bfbe7bb5065279665fa87de (diff)
CTAN sync 202107270301
Diffstat (limited to 'support/make4ht/extensions')
-rw-r--r--support/make4ht/extensions/make4ht-ext-build_changed.lua68
-rw-r--r--support/make4ht/extensions/make4ht-ext-common_domfilters.lua2
-rw-r--r--support/make4ht/extensions/make4ht-ext-staticsite.lua28
3 files changed, 27 insertions, 71 deletions
diff --git a/support/make4ht/extensions/make4ht-ext-build_changed.lua b/support/make4ht/extensions/make4ht-ext-build_changed.lua
deleted file mode 100644
index e0fc5ec6eb..0000000000
--- a/support/make4ht/extensions/make4ht-ext-build_changed.lua
+++ /dev/null
@@ -1,68 +0,0 @@
--- 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/support/make4ht/extensions/make4ht-ext-common_domfilters.lua b/support/make4ht/extensions/make4ht-ext-common_domfilters.lua
index 802902d48d..6219c95fbd 100644
--- a/support/make4ht/extensions/make4ht-ext-common_domfilters.lua
+++ b/support/make4ht/extensions/make4ht-ext-common_domfilters.lua
@@ -26,7 +26,7 @@ function M.modify_build(make)
make:match("4om$", process, {charclasses= charclasses})
count = 2
else
- local process = filter {"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows","booktabs"}
+ local process = filter {"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows","booktabs", "sectionid", "itemparagraphs"}
make:match("html?$", process)
count = 1
end
diff --git a/support/make4ht/extensions/make4ht-ext-staticsite.lua b/support/make4ht/extensions/make4ht-ext-staticsite.lua
index 5704959970..a9a5bcece7 100644
--- a/support/make4ht/extensions/make4ht-ext-staticsite.lua
+++ b/support/make4ht/extensions/make4ht-ext-staticsite.lua
@@ -16,7 +16,7 @@ local function get_slug(settings)
local f = io.open(published_name, "r")
local readtime = f:read("*line")
time = tonumber(readtime)
- log:info("Already pubslished", slug)
+ log:info("Already pubslished", os.date("%Y-%m-%d %H:%M", time))
f:close()
else
-- escape
@@ -76,6 +76,22 @@ local function insert_filter(make, pattern, fn)
})
end
+local function remove_maketitle(make)
+ -- use DOM filter to remove \maketitle block
+ local domfilter = require "make4ht-domfilter"
+ local process = domfilter {
+ function(dom)
+ local maketitles = dom:query_selector(".maketitle")
+ for _, el in ipairs(maketitles) do
+ log:debug("removing maketitle")
+ el:remove_node()
+ end
+ return dom
+ end
+ }
+ make:match("html$", process)
+end
+
local function copy_files(filename, par)
local function prepare_path(dir, subdir)
@@ -84,7 +100,7 @@ local function copy_files(filename, par)
end
-- get extension settings
local site_settings = get_filter_settings "staticsite"
- local site_root = site_settings.site_root
+ local site_root = site_settings.site_root or "./"
local map = site_settings.map or {}
-- default path without subdir, will be used if the file is not matched
-- by any pattern in the map
@@ -107,6 +123,14 @@ function M.modify_build(make)
local process = filter {
"staticsite"
}
+
+ -- detect if we should remove maketitle
+ local site_settings = get_filter_settings "staticsite"
+ -- \maketitle is removed by default, set `remove_maketitle=false` setting to disable that
+ if site_settings.remove_maketitle ~= false then
+ remove_maketitle(make)
+ end
+
local settings = make.params
-- get the published file name
local slug = get_slug(settings)