summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/make4ht
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-11-06 23:34:03 +0000
committerKarl Berry <karl@freefriends.org>2019-11-06 23:34:03 +0000
commitaf84b9db7fece90caa80d73b8faa9de75dd9e568 (patch)
tree745ebd7a73950d0e7099c47a66b6b3deefb2f4bd /Master/texmf-dist/scripts/make4ht
parent73e3f7c059fcd8089c33c01b6034e5ad3c9d50d6 (diff)
make4ht (5nov19)
git-svn-id: svn://tug.org/texlive/trunk@52666 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/make4ht')
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua (renamed from Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_filters.lua (renamed from Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua (renamed from Master/texmf-dist/scripts/make4ht/extensions/dvisvgm_hashes.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-join_colors.lua (renamed from Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-latexmk_build.lua (renamed from Master/texmf-dist/scripts/make4ht/extensions/latexmk_build.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua (renamed from Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-odttemplate.lua (renamed from Master/texmf-dist/scripts/make4ht/extensions/odttemplate.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-preprocess_input.lua (renamed from Master/texmf-dist/scripts/make4ht/extensions/preprocess_input.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-staticsite.lua (renamed from Master/texmf-dist/scripts/make4ht/extensions/staticsite.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-tidy.lua (renamed from Master/texmf-dist/scripts/make4ht/extensions/tidy.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/formats/make4ht-docbook.lua (renamed from Master/texmf-dist/scripts/make4ht/formats/docbook.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/formats/make4ht-html5.lua (renamed from Master/texmf-dist/scripts/make4ht/formats/html5.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua (renamed from Master/texmf-dist/scripts/make4ht/formats/odt.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/formats/make4ht-tei.lua (renamed from Master/texmf-dist/scripts/make4ht/formats/tei.lua)0
-rw-r--r--Master/texmf-dist/scripts/make4ht/formats/make4ht-xhtml.lua (renamed from Master/texmf-dist/scripts/make4ht/formats/xhtml.lua)0
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht2
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua33
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/mathnode.lua87
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/mkutils.lua6
19 files changed, 37 insertions, 91 deletions
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua
index 9399492d907..9399492d907 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_domfilters.lua
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_filters.lua
index 513fbed34ee..513fbed34ee 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-common_filters.lua
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/dvisvgm_hashes.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
index 87f58abd57c..87f58abd57c 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/dvisvgm_hashes.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-dvisvgm_hashes.lua
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-join_colors.lua
index 182661fbdbc..182661fbdbc 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-join_colors.lua
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/latexmk_build.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-latexmk_build.lua
index bf4dcdde5a4..bf4dcdde5a4 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/latexmk_build.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-latexmk_build.lua
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua
index cbad897d4ec..cbad897d4ec 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-mathjaxnode.lua
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/odttemplate.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-odttemplate.lua
index 3b0af2a6999..3b0af2a6999 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/odttemplate.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-odttemplate.lua
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/preprocess_input.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-preprocess_input.lua
index 3155a8a7810..3155a8a7810 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/preprocess_input.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-preprocess_input.lua
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/staticsite.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-staticsite.lua
index a4204bc1733..a4204bc1733 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/staticsite.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-staticsite.lua
diff --git a/Master/texmf-dist/scripts/make4ht/extensions/tidy.lua b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-tidy.lua
index b381a05a8fb..b381a05a8fb 100644
--- a/Master/texmf-dist/scripts/make4ht/extensions/tidy.lua
+++ b/Master/texmf-dist/scripts/make4ht/extensions/make4ht-ext-tidy.lua
diff --git a/Master/texmf-dist/scripts/make4ht/formats/docbook.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-docbook.lua
index 3bd79eb83ed..3bd79eb83ed 100644
--- a/Master/texmf-dist/scripts/make4ht/formats/docbook.lua
+++ b/Master/texmf-dist/scripts/make4ht/formats/make4ht-docbook.lua
diff --git a/Master/texmf-dist/scripts/make4ht/formats/html5.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-html5.lua
index 633a45e7f34..633a45e7f34 100644
--- a/Master/texmf-dist/scripts/make4ht/formats/html5.lua
+++ b/Master/texmf-dist/scripts/make4ht/formats/make4ht-html5.lua
diff --git a/Master/texmf-dist/scripts/make4ht/formats/odt.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua
index c515a154a1b..c515a154a1b 100644
--- a/Master/texmf-dist/scripts/make4ht/formats/odt.lua
+++ b/Master/texmf-dist/scripts/make4ht/formats/make4ht-odt.lua
diff --git a/Master/texmf-dist/scripts/make4ht/formats/tei.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-tei.lua
index f81953a8b31..f81953a8b31 100644
--- a/Master/texmf-dist/scripts/make4ht/formats/tei.lua
+++ b/Master/texmf-dist/scripts/make4ht/formats/make4ht-tei.lua
diff --git a/Master/texmf-dist/scripts/make4ht/formats/xhtml.lua b/Master/texmf-dist/scripts/make4ht/formats/make4ht-xhtml.lua
index 4a4ac6689ca..4a4ac6689ca 100644
--- a/Master/texmf-dist/scripts/make4ht/formats/xhtml.lua
+++ b/Master/texmf-dist/scripts/make4ht/formats/make4ht-xhtml.lua
diff --git a/Master/texmf-dist/scripts/make4ht/make4ht b/Master/texmf-dist/scripts/make4ht/make4ht
index b1ff84f7006..fd153164cd7 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.3"
+local version = "v0.3b"
mkparams.version_number = version
local args = mkparams.get_args()
diff --git a/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua b/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua
new file mode 100755
index 00000000000..97f0b8df670
--- /dev/null
+++ b/Master/texmf-dist/scripts/make4ht/make4ht-odtfilter.lua
@@ -0,0 +1,33 @@
+local mkutils = require "mkutils"
+local zip = require "zip"
+
+
+-- use function to change contents of the ODT file
+local function update_odt(odtfilename, file_path, fn)
+ -- get name of the odt file
+ local odtname = mkutils.remove_extension(odtfilename) .. ".odt"
+ -- open and read contents of the requested file inside ODT file
+ local odtfile = zip.open(odtname)
+ local local_file = odtfile:open(file_path)
+ local content = local_file:read("*all")
+ local_file:close()
+ odtfile:close()
+ -- update the content using user function
+ content = fn(content)
+ -- write the updated file
+ local local_file_file = io.open(file_path,"w")
+ local_file_file:write(content)
+ local_file_file:close()
+ os.execute("zip " .. odtname .. " " .. file_path)
+ os.remove(file_path)
+end
+
+Make:match("tmp$", function(name, par)
+ update_odt(name, "content.xml", function(content)
+ return content:gsub("%&%#x([A-Fa-f0-9]+);", function(entity)
+ -- convert hexadecimal entity to Unicode
+ print(entity,utfchar(tonumber(entity, 16)))
+ return utfchar(tonumber(entity, 16))
+ end)
+ end)
+end)
diff --git a/Master/texmf-dist/scripts/make4ht/mathnode.lua b/Master/texmf-dist/scripts/make4ht/mathnode.lua
deleted file mode 100755
index 6d054ad7b85..00000000000
--- a/Master/texmf-dist/scripts/make4ht/mathnode.lua
+++ /dev/null
@@ -1,87 +0,0 @@
--- local mathnodepath = os.getenv "mathjaxnodepath"
---
--- print("mathnode", mathnodepath)
-local mkutils = require "mkutils"
--- other possible value is page2svg
-local mathnodepath = "page2html"
--- options for MathJax command
-local options = "--format MathML"
--- math fonts position
--- don't alter fonts if not set
-local fontdir = nil
--- if we copy fonts
-local fontdest = nil
-local fontformat = "otf"
-
-local function compile(src)
- local tmpfile = os.tmpname()
- local filename = src
- print("Compile using MathJax")
- local command = mathnodepath .. " ".. options .. " < " .. filename .. " > " .. tmpfile
- print(command)
- local status = os.execute(command)
- print("Result written to: ".. tmpfile)
- mkutils.cp(tmpfile, src)
- os.remove(tmpfile)
-end
-
-local function extract_css(file)
- local f = io.open(file, "r")
- local contents = f:read("*all")
- f:close()
- local css = ""
- local filename = ""
- contents = contents:gsub('<style id="(MathJax.-)">(.+)</style>', function(name, style)
- css = style
- filename = (name or "") .. ".css"
- return '<link rel="stylesheet" type="text/css" href="'..filename ..'" />'
- end)
- local x = assert(io.open(file, "w"))
- x:write(contents)
- x:close()
- return filename, css
-end
-
---
-local function use_fonts(css)
- local family_pattern = "font%-family:%s*(.-);.-%/([^%/]+)%.".. fontformat
- local family_build = "@font-face {font-family: %s; src: url('%s/%s.%s') format('%s')}"
- local fontdir = fontdir:gsub("/$","")
- css = css:gsub("(@font%-face%s*{.-})", function(face)
- -- if not face:match("url%(") then return face end
- if not face:match("url%(") then return "" end
- -- print(face)
- local family, filename = face:match(family_pattern)
- print(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)
- -- return face
- end)
- return css
-end
-
-
-local function save_css(filename, css)
- local f = io.open(filename, "w")
- f:write(css)
- f:close()
-end
-
-return function(text, arguments)
- -- if arguments.prg then mathnodepath = arguments.prg end
- mathnodepath = arguments.prg or mathnodepath
- options = arguments.options or options
- fontdir = arguments.fontdir or fontdir
- fontdest = arguments.fontdest or fontdest
- fontformat = arguments.fontformat or fontformat
- compile(text)
- filename, css = extract_css(text)
- if fontdir then
- css = use_fonts(css)
- end
- save_css(filename, css)
- Make:add_file(filename)
- -- print(css)
- print(filename)
-end
diff --git a/Master/texmf-dist/scripts/make4ht/mkutils.lua b/Master/texmf-dist/scripts/make4ht/mkutils.lua
index ba1cd6cbb9f..0ea85c7b56b 100755
--- a/Master/texmf-dist/scripts/make4ht/mkutils.lua
+++ b/Master/texmf-dist/scripts/make4ht/mkutils.lua
@@ -443,7 +443,7 @@ env.Make:add("bibtex", "bibtex ${input}")
--- load the output format plugins
function load_output_format(format_name)
- local format_library = "make4ht.formats."..format_name
+ local format_library = "make4ht.formats.make4ht-"..format_name
local is_format_file = find_lua_file(format_library)
if is_format_file then
local format = assert(require(format_library))
@@ -486,11 +486,11 @@ end
-- @param format current output format
function load_extension(name,format)
-- first test if the extension exists
- local extension_library = "make4ht.extensions." .. name
+ local extension_library = "make4ht.extensions.make4ht-ext-" .. name
local is_extension_file = find_lua_file(extension_library)
-- don't try to load the extension if it doesn't exist
if not is_extension_file then return nil end
- local extension = require("make4ht.extensions.".. name)
+ local extension = require("make4ht.extensions.make4ht-ext-".. name)
-- extensions can test if the current output format is supported
local test = extension.test
if test then