From fa4484fd40909b7d8d5205c08917375a1287748b Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 1 May 2018 17:59:54 +0000 Subject: make4ht lua files in runtime git-svn-id: svn://tug.org/texlive/trunk@47548 c570f23f-e606-0410-a88d-b1316a301751 --- .../make4ht/extensions/common_domfilters.lua | 27 ---------- .../support/make4ht/extensions/common_filters.lua | 26 ---------- .../doc/support/make4ht/extensions/latexmk.lua | 31 ------------ .../doc/support/make4ht/extensions/mathjaxnode.lua | 16 ------ .../doc/support/make4ht/extensions/tidy.lua | 57 ---------------------- .../doc/support/make4ht/formats/html5.lua | 17 ------- .../texmf-dist/doc/support/make4ht/formats/odt.lua | 11 ----- .../doc/support/make4ht/formats/xhtml.lua | 16 ------ .../make4ht/extensions/common_domfilters.lua | 27 ++++++++++ .../scripts/make4ht/extensions/common_filters.lua | 26 ++++++++++ .../scripts/make4ht/extensions/latexmk.lua | 31 ++++++++++++ .../scripts/make4ht/extensions/mathjaxnode.lua | 16 ++++++ .../texmf-dist/scripts/make4ht/extensions/tidy.lua | 57 ++++++++++++++++++++++ .../texmf-dist/scripts/make4ht/formats/html5.lua | 17 +++++++ Master/texmf-dist/scripts/make4ht/formats/odt.lua | 11 +++++ .../texmf-dist/scripts/make4ht/formats/xhtml.lua | 16 ++++++ Master/tlpkg/libexec/ctan2tds | 2 +- 17 files changed, 202 insertions(+), 202 deletions(-) delete mode 100644 Master/texmf-dist/doc/support/make4ht/extensions/common_domfilters.lua delete mode 100644 Master/texmf-dist/doc/support/make4ht/extensions/common_filters.lua delete mode 100644 Master/texmf-dist/doc/support/make4ht/extensions/latexmk.lua delete mode 100644 Master/texmf-dist/doc/support/make4ht/extensions/mathjaxnode.lua delete mode 100644 Master/texmf-dist/doc/support/make4ht/extensions/tidy.lua delete mode 100644 Master/texmf-dist/doc/support/make4ht/formats/html5.lua delete mode 100644 Master/texmf-dist/doc/support/make4ht/formats/odt.lua delete mode 100644 Master/texmf-dist/doc/support/make4ht/formats/xhtml.lua create mode 100644 Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua create mode 100644 Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua create mode 100644 Master/texmf-dist/scripts/make4ht/extensions/latexmk.lua create mode 100644 Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua create mode 100644 Master/texmf-dist/scripts/make4ht/extensions/tidy.lua create mode 100644 Master/texmf-dist/scripts/make4ht/formats/html5.lua create mode 100644 Master/texmf-dist/scripts/make4ht/formats/odt.lua create mode 100644 Master/texmf-dist/scripts/make4ht/formats/xhtml.lua diff --git a/Master/texmf-dist/doc/support/make4ht/extensions/common_domfilters.lua b/Master/texmf-dist/doc/support/make4ht/extensions/common_domfilters.lua deleted file mode 100644 index 7c9a2dfaea4..00000000000 --- a/Master/texmf-dist/doc/support/make4ht/extensions/common_domfilters.lua +++ /dev/null @@ -1,27 +0,0 @@ -local M = {} - - -local filter = require "make4ht-domfilter" --- local process = filter {"fixinlines", "idcolons", "joincharacters" } - --- filters support only html formats -function M.test(format) - if format == "odt" then return false end - return true -end - -function M.modify_build(make) - local process = filter {"fixinlines", "idcolons", "joincharacters"} - 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 - if #matches > 1 then - local last = matches[#matches] - table.insert(matches, 1, last) - matches[#matches] = nil - end - return make -end - -return M diff --git a/Master/texmf-dist/doc/support/make4ht/extensions/common_filters.lua b/Master/texmf-dist/doc/support/make4ht/extensions/common_filters.lua deleted file mode 100644 index 513fbed34ee..00000000000 --- a/Master/texmf-dist/doc/support/make4ht/extensions/common_filters.lua +++ /dev/null @@ -1,26 +0,0 @@ -local M = {} - - -local filter = require "make4ht-filter" -local process = filter {"cleanspan-nat", "fixligatures", "hruletohr", "entities", "fix-links"} - --- filters support only html formats -function M.test(format) - if format == "odt" then return false end - return true -end - -function M.modify_build(make) - 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 - if #matches > 1 then - local last = matches[#matches] - table.insert(matches, 1, last) - matches[#matches] = nil - end - return make -end - -return M diff --git a/Master/texmf-dist/doc/support/make4ht/extensions/latexmk.lua b/Master/texmf-dist/doc/support/make4ht/extensions/latexmk.lua deleted file mode 100644 index bf4dcdde5a4..00000000000 --- a/Master/texmf-dist/doc/support/make4ht/extensions/latexmk.lua +++ /dev/null @@ -1,31 +0,0 @@ --- use Latexmk in first LaTeX call --- only in the first call, because we don't need to execute biber, etc. in the subsequent --- LaTeX calls, these are only for resolving the cross-references -local M = {} -function M.modify_build(make) - local used = false - local first - local build_seq = make.build_seq - -- find first htlatex call in the build sequence - for pos,v in ipairs(build_seq) do - if v.name == "htlatex" and not first then - first = pos - end - end - -- if htlatex was found - if first then - -- add dummy latexmk call to the build sequence - make:latexmk {} - -- replace name, command and type in the first htlatex - -- call with values from the dummy latexmk call - local replaced = build_seq[first] - local latexmk = build_seq[#build_seq] - replaced.name = latexmk.name - replaced.command = latexmk.command - replaced.type = latexmk.type - -- remove the dummy latexmk - table.remove(build_seq) - end - return make -end -return M diff --git a/Master/texmf-dist/doc/support/make4ht/extensions/mathjaxnode.lua b/Master/texmf-dist/doc/support/make4ht/extensions/mathjaxnode.lua deleted file mode 100644 index cbad897d4ec..00000000000 --- a/Master/texmf-dist/doc/support/make4ht/extensions/mathjaxnode.lua +++ /dev/null @@ -1,16 +0,0 @@ -local M = {} - - -local filter = require "make4ht-filter" -function M.test(format) - if format == "odt" then return false end - return true -end - -function M.modify_build(make) - local mathjax = filter { "mathjaxnode"} - make:match("html$",mathjax) - return make -end - -return M diff --git a/Master/texmf-dist/doc/support/make4ht/extensions/tidy.lua b/Master/texmf-dist/doc/support/make4ht/extensions/tidy.lua deleted file mode 100644 index cf8ea9785a5..00000000000 --- a/Master/texmf-dist/doc/support/make4ht/extensions/tidy.lua +++ /dev/null @@ -1,57 +0,0 @@ -local M = {} - -function M.test(format) - if format == "odt" then return false end - return true -end - -local empty_elements = { - area=true, - base=true, - br=true, - col=true, - embed=true, - hr=true, - img=true, - input=true, - keygen=true, - link=true, - meta=true, - param=true, - source=true, - track=true, - wbr=true, -} - --- LuaXML cannot read HTML with unclosed tags (like ) --- Tidy removes end slashes in the HTML output, so --- this function will add them back -local function close_tags(s) - return s:gsub("<(%w+)([^>]-)>", function(tag, rest) - local endslash = "" - if empty_elements[tag] then endslash = " /" end - return string.format("<%s%s%s>", tag, rest, endslash) - end) -end - - - -function M.modify_build(make) - 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 - print("execute: ".. command) - -- os.execute(command) - local run = io.popen(command, "r") - local result = run:read("*all") - run:close() - result = close_tags(result) - local f = io.open(filename, "w") - f:write(result) - f:close() - end) - return make -end - -return M diff --git a/Master/texmf-dist/doc/support/make4ht/formats/html5.lua b/Master/texmf-dist/doc/support/make4ht/formats/html5.lua deleted file mode 100644 index 633a45e7f34..00000000000 --- a/Master/texmf-dist/doc/support/make4ht/formats/html5.lua +++ /dev/null @@ -1,17 +0,0 @@ -local M = {} - -local mkutils = require "mkutils" - -function M.prepare_extensions(extensions) - -- return mkutils.add_extensions("+common_domfilters", extensions) - return extensions --mkutils.add_extensions("+tidy", extensions) -end - -function M.prepare_parameters(parameters,extensions) - parameters.tex4ht_sty_par = parameters.tex4ht_sty_par .. ",html5" - parameters = mkutils.extensions_prepare_parameters(extensions,parameters) - return parameters -end - - -return M diff --git a/Master/texmf-dist/doc/support/make4ht/formats/odt.lua b/Master/texmf-dist/doc/support/make4ht/formats/odt.lua deleted file mode 100644 index 66105166f32..00000000000 --- a/Master/texmf-dist/doc/support/make4ht/formats/odt.lua +++ /dev/null @@ -1,11 +0,0 @@ -local M = {} -local mkutils = require "mkutils" - -function M.prepare_parameters(settings, extensions) - settings.tex4ht_sty_par = settings.tex4ht_sty_par ..",ooffice" - settings.tex4ht_par = settings.tex4ht_par .. " ooffice/! -cmozhtf" - settings.t4ht_par = settings.t4ht_par .. " -cooxtpipes -coo " - settings = mkutils.extensions_prepare_parameters(extensions, settings) - return settings -end -return M diff --git a/Master/texmf-dist/doc/support/make4ht/formats/xhtml.lua b/Master/texmf-dist/doc/support/make4ht/formats/xhtml.lua deleted file mode 100644 index 4a4ac6689ca..00000000000 --- a/Master/texmf-dist/doc/support/make4ht/formats/xhtml.lua +++ /dev/null @@ -1,16 +0,0 @@ -local M = {} - -local mkutils = require "mkutils" - -function M.prepare_extensions(extensions) - -- return mkutils.add_extensions("+common_domfilters", extensions) - return extensions -end - -function M.prepare_parameters(parameters,extensions) - parameters = mkutils.extensions_prepare_parameters(extensions,parameters) - return parameters -end - - -return M diff --git a/Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua b/Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua new file mode 100644 index 00000000000..7c9a2dfaea4 --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua @@ -0,0 +1,27 @@ +local M = {} + + +local filter = require "make4ht-domfilter" +-- local process = filter {"fixinlines", "idcolons", "joincharacters" } + +-- filters support only html formats +function M.test(format) + if format == "odt" then return false end + return true +end + +function M.modify_build(make) + local process = filter {"fixinlines", "idcolons", "joincharacters"} + 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 + if #matches > 1 then + local last = matches[#matches] + table.insert(matches, 1, last) + matches[#matches] = nil + end + return make +end + +return M diff --git a/Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua b/Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua new file mode 100644 index 00000000000..513fbed34ee --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua @@ -0,0 +1,26 @@ +local M = {} + + +local filter = require "make4ht-filter" +local process = filter {"cleanspan-nat", "fixligatures", "hruletohr", "entities", "fix-links"} + +-- filters support only html formats +function M.test(format) + if format == "odt" then return false end + return true +end + +function M.modify_build(make) + 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 + if #matches > 1 then + local last = matches[#matches] + table.insert(matches, 1, last) + matches[#matches] = nil + end + return make +end + +return M diff --git a/Master/texmf-dist/scripts/make4ht/extensions/latexmk.lua b/Master/texmf-dist/scripts/make4ht/extensions/latexmk.lua new file mode 100644 index 00000000000..bf4dcdde5a4 --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/extensions/latexmk.lua @@ -0,0 +1,31 @@ +-- use Latexmk in first LaTeX call +-- only in the first call, because we don't need to execute biber, etc. in the subsequent +-- LaTeX calls, these are only for resolving the cross-references +local M = {} +function M.modify_build(make) + local used = false + local first + local build_seq = make.build_seq + -- find first htlatex call in the build sequence + for pos,v in ipairs(build_seq) do + if v.name == "htlatex" and not first then + first = pos + end + end + -- if htlatex was found + if first then + -- add dummy latexmk call to the build sequence + make:latexmk {} + -- replace name, command and type in the first htlatex + -- call with values from the dummy latexmk call + local replaced = build_seq[first] + local latexmk = build_seq[#build_seq] + replaced.name = latexmk.name + replaced.command = latexmk.command + replaced.type = latexmk.type + -- remove the dummy latexmk + table.remove(build_seq) + end + return make +end +return M diff --git a/Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua b/Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua new file mode 100644 index 00000000000..cbad897d4ec --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua @@ -0,0 +1,16 @@ +local M = {} + + +local filter = require "make4ht-filter" +function M.test(format) + if format == "odt" then return false end + return true +end + +function M.modify_build(make) + local mathjax = filter { "mathjaxnode"} + make:match("html$",mathjax) + return make +end + +return M diff --git a/Master/texmf-dist/scripts/make4ht/extensions/tidy.lua b/Master/texmf-dist/scripts/make4ht/extensions/tidy.lua new file mode 100644 index 00000000000..cf8ea9785a5 --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/extensions/tidy.lua @@ -0,0 +1,57 @@ +local M = {} + +function M.test(format) + if format == "odt" then return false end + return true +end + +local empty_elements = { + area=true, + base=true, + br=true, + col=true, + embed=true, + hr=true, + img=true, + input=true, + keygen=true, + link=true, + meta=true, + param=true, + source=true, + track=true, + wbr=true, +} + +-- LuaXML cannot read HTML with unclosed tags (like ) +-- Tidy removes end slashes in the HTML output, so +-- this function will add them back +local function close_tags(s) + return s:gsub("<(%w+)([^>]-)>", function(tag, rest) + local endslash = "" + if empty_elements[tag] then endslash = " /" end + return string.format("<%s%s%s>", tag, rest, endslash) + end) +end + + + +function M.modify_build(make) + 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 + print("execute: ".. command) + -- os.execute(command) + local run = io.popen(command, "r") + local result = run:read("*all") + run:close() + result = close_tags(result) + local f = io.open(filename, "w") + f:write(result) + f:close() + end) + return make +end + +return M diff --git a/Master/texmf-dist/scripts/make4ht/formats/html5.lua b/Master/texmf-dist/scripts/make4ht/formats/html5.lua new file mode 100644 index 00000000000..633a45e7f34 --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/formats/html5.lua @@ -0,0 +1,17 @@ +local M = {} + +local mkutils = require "mkutils" + +function M.prepare_extensions(extensions) + -- return mkutils.add_extensions("+common_domfilters", extensions) + return extensions --mkutils.add_extensions("+tidy", extensions) +end + +function M.prepare_parameters(parameters,extensions) + parameters.tex4ht_sty_par = parameters.tex4ht_sty_par .. ",html5" + parameters = mkutils.extensions_prepare_parameters(extensions,parameters) + return parameters +end + + +return M diff --git a/Master/texmf-dist/scripts/make4ht/formats/odt.lua b/Master/texmf-dist/scripts/make4ht/formats/odt.lua new file mode 100644 index 00000000000..66105166f32 --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/formats/odt.lua @@ -0,0 +1,11 @@ +local M = {} +local mkutils = require "mkutils" + +function M.prepare_parameters(settings, extensions) + settings.tex4ht_sty_par = settings.tex4ht_sty_par ..",ooffice" + settings.tex4ht_par = settings.tex4ht_par .. " ooffice/! -cmozhtf" + settings.t4ht_par = settings.t4ht_par .. " -cooxtpipes -coo " + settings = mkutils.extensions_prepare_parameters(extensions, settings) + return settings +end +return M diff --git a/Master/texmf-dist/scripts/make4ht/formats/xhtml.lua b/Master/texmf-dist/scripts/make4ht/formats/xhtml.lua new file mode 100644 index 00000000000..4a4ac6689ca --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/formats/xhtml.lua @@ -0,0 +1,16 @@ +local M = {} + +local mkutils = require "mkutils" + +function M.prepare_extensions(extensions) + -- return mkutils.add_extensions("+common_domfilters", extensions) + return extensions +end + +function M.prepare_parameters(parameters,extensions) + parameters = mkutils.extensions_prepare_parameters(extensions,parameters) + return parameters +end + + +return M diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 8037e50d05a..2c15d71112a 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -2834,7 +2834,7 @@ $standardttf = '\.ttf|\.TTC'; 'luamesh' => '\.lua$', 'luasseq' => '\.lua$', 'lyluatex' => '\.lua$', - 'make4ht' => 'filters|\.lua$', + 'make4ht' => '(extensions|filters|formats|\.lua)$', 'mycv' => 'mycv_split_contents\.pl', 'pgfmolbio' => '\.lua$', 'placeat' => '\.lua$', -- cgit v1.2.3