diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/support/make4ht/README | 11 | ||||
-rw-r--r-- | Master/texmf-dist/doc/support/make4ht/changelog.tex | 48 | ||||
-rw-r--r-- | Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf | bin | 111789 -> 112999 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/support/make4ht/readme.tex | 8 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincolors.lua | 73 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtimagesize.lua | 4 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua | 16 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/make4ht/formats/odt.lua | 2 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/make4ht/make4ht | 2 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/make4ht/make4ht-config.lua | 2 |
10 files changed, 159 insertions, 7 deletions
diff --git a/Master/texmf-dist/doc/support/make4ht/README b/Master/texmf-dist/doc/support/make4ht/README index 46b22e5b14f..a99a108d691 100644 --- a/Master/texmf-dist/doc/support/make4ht/README +++ b/Master/texmf-dist/doc/support/make4ht/README @@ -134,6 +134,10 @@ common\_domfilters `common_filters`. Used DOM filters are `fixinlines`, `idcolons` and `joincharacters`. +join\_colors + +: load the `joincolors` domfilter for all HTML files. + mathjaxnode : use [mathjax-node-page](https://github.com/pkra/mathjax-node-page/) to @@ -441,6 +445,13 @@ joincharacters : join consecutive `<span>` or `<mn>` elements. +joincolors + +: many `<span>` elements with unique `id` attribute are created when \LaTeX\ colors are being used in the document. + CSS rule is added for each of these elements, which may result in + substantial grow of the CSS file. This filter replace these rules with a + common one for elements with the same color value. + odtimagesize : set correct dimensions for images in the ODT format. It is loaded by default for the ODT output. diff --git a/Master/texmf-dist/doc/support/make4ht/changelog.tex b/Master/texmf-dist/doc/support/make4ht/changelog.tex index b8d6ea15a0b..0c70be59a7e 100644 --- a/Master/texmf-dist/doc/support/make4ht/changelog.tex +++ b/Master/texmf-dist/doc/support/make4ht/changelog.tex @@ -3,15 +3,59 @@ \begin{itemize} \item + 2019/03/21 + + \begin{itemize} + \tightlist + \item + version 0.2f released + \end{itemize} +\item + 2019/03/15 + + \begin{itemize} + \tightlist + \item + check for the image dimensions existence in the + \texttt{odtimagesize} domfilter. + \end{itemize} +\item + 2019/03/13 + + \begin{itemize} + \tightlist + \item + don't use \texttt{odtimagesize} domfilter in the \texttt{ODT} + format, the issue it fixes had been resolved in \texttt{tex4ht}. + \end{itemize} +\item + 2019/03/08 + + \begin{itemize} + \tightlist + \item + use \texttt{\%USERPROFILE} for home dir search on Windows. + \end{itemize} +\item + 2019/01/28 + + \begin{itemize} + \tightlist + \item + added \texttt{joincolors} domfilter and \texttt{join\_colors} + extension. It can join CSS rules created for the LaTeX colors and + update the HTML file. + \end{itemize} +\item 2019/01/22 \begin{itemize} \tightlist \item + version 0.2e released + \item updated the \texttt{odttemplate} filter. It will use styles from the generated ODT file that haven't been present in the template file. - \item - version 0.2e released \end{itemize} \item 2019/01/10 diff --git a/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf b/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf Binary files differindex 9a767c9cc73..84653d3df82 100644 --- a/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf +++ b/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf diff --git a/Master/texmf-dist/doc/support/make4ht/readme.tex b/Master/texmf-dist/doc/support/make4ht/readme.tex index bb4fa0e7803..c9fc0a2f3ed 100644 --- a/Master/texmf-dist/doc/support/make4ht/readme.tex +++ b/Master/texmf-dist/doc/support/make4ht/readme.tex @@ -168,6 +168,8 @@ clean the output HTML files using filters. clean the HTML file using DOM filters. It is more powerful than \texttt{common\_filters}. Used DOM filters are \texttt{fixinlines}, \texttt{idcolons} and \texttt{joincharacters}. +\item[join\_colors] +load the \texttt{joincolors} domfilter for all HTML files. \item[mathjaxnode] use \href{https://github.com/pkra/mathjax-node-page/}{mathjax-node-page} to convert from MathML code to HTML + CSS or SVG. See @@ -463,6 +465,12 @@ replace the colon (\texttt{:}) character in internal links and \item[joincharacters] join consecutive \texttt{\textless{}span\textgreater{}} or \texttt{\textless{}mn\textgreater{}} elements. +\item[joincolors] +many \texttt{\textless{}span\textgreater{}} elements with unique +\texttt{id} attribute are created when \LaTeX~colors are being used in +the document. CSS rule is added for each of these elements, which may +result in substantial grow of the CSS file. This filter replace these +rules with a common one for elements with the same color value. \item[odtimagesize] set correct dimensions for images in the ODT format. It is loaded by default for the ODT output. diff --git a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincolors.lua b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincolors.lua new file mode 100644 index 00000000000..1b7a97be0a2 --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincolors.lua @@ -0,0 +1,73 @@ +local cssfiles = {} + + +-- keep mapping between span ids and colors +local colors = {} + +local function extract_colors(csscontent) + local used_colors = {} + -- delete the color ids and save the used colors + csscontent = csscontent:gsub("[%a]*%#(textcolor.-)%s*{%s*color%s*%:%s*(.-)%s*%}%s", function(id, color) + -- convert rgb() function to hex value and generate the span name + local converted = "textcolor-" .. color:gsub("rgb%((.-),(.-),(.-)%)", function(r,g,b) + return string.format("%02x%02x%02x", tonumber(r), tonumber(g), tonumber(b)) + end) + -- save the id and used color + colors[id] = converted + used_colors[converted] = color + return "" + end) + -- add the used colors to css + local t = {} + for class, color in pairs(used_colors) do + t[#t+1] = string.format(".%s{color:%s;}", class, color) + end + return csscontent .. table.concat(t, "\n") +end + +local function process_css(cssfile) + local f = io.open(cssfile,"r") + if not f then return nil, "Cannot open the CSS file: ".. cssfile end + local content = f:read("*all") + f:close() + -- delete color ids and replace them with joined spans + local newcontent = extract_colors(content) + -- save the updated css file + local f=io.open(cssfile, "w") + f:write(newcontent) + f:close() +end + + +local function process_css_files(dom) + for _, el in ipairs(dom:query_selector("link")) do + local href = el:get_attribute("href") or "" + if not cssfiles[href] and href:match("css$") then + print("Load CSS file ", href) + cssfiles[href] = true + process_css(href) + end + end + +end + +local function join_colors(dom) + -- find css files in the current HTML file and join the colors + process_css_files(dom) + for _, span in ipairs(dom:query_selector("span")) do + local id = span:get_attribute("id") + if id then + -- test if the id is in the saved colors + local class = colors[id] + if class then + -- remove the id + span:set_attribute("id", nil) + span:set_attribute("class", class) + end + end + end + + return dom +end + +return join_colors diff --git a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtimagesize.lua b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtimagesize.lua index 92ce68dee4c..4ce8f0d92ea 100644 --- a/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtimagesize.lua +++ b/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtimagesize.lua @@ -7,8 +7,8 @@ return function(dom) local image = images[1] local width = image:get_attribute("svg:width") local height = image:get_attribute("svg:height") - frame:set_attribute("svg:width", width) - frame:set_attribute("svg:height", height) + if widht then frame:set_attribute("svg:width", width) end + if height then frame:set_attribute("svg:height", height) end print("image dimensions", width, height) end end diff --git a/Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua b/Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua new file mode 100644 index 00000000000..182661fbdbc --- /dev/null +++ b/Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua @@ -0,0 +1,16 @@ +local M = {} + +local filter = require "make4ht-domfilter" + +-- 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 {"joincolors"} + make:match("html$", process) + return make +end +return M diff --git a/Master/texmf-dist/scripts/make4ht/formats/odt.lua b/Master/texmf-dist/scripts/make4ht/formats/odt.lua index 453c46aff5e..64b8793e2a7 100644 --- a/Master/texmf-dist/scripts/make4ht/formats/odt.lua +++ b/Master/texmf-dist/scripts/make4ht/formats/odt.lua @@ -130,7 +130,7 @@ function M.modify_build(make) -- expanded in tex4ht.env in Miktex or Debian call_xtpipes(make) -- fix the image dimensions wrongly set by xtpipes - local domfilters = domfilter {"t4htlinks","odtimagesize"} + local domfilters = domfilter {"t4htlinks"} make:match("4oo$", domfilters) -- execute it before xtpipes, because we don't want xtpipes to mess with t4htlink elements move_matches(make) diff --git a/Master/texmf-dist/scripts/make4ht/make4ht b/Master/texmf-dist/scripts/make4ht/make4ht index 44c3582134a..ab8e1cfbc6f 100755 --- a/Master/texmf-dist/scripts/make4ht/make4ht +++ b/Master/texmf-dist/scripts/make4ht/make4ht @@ -27,7 +27,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.2e" +local version = "v0.2f" mkparams.version_number = version local args = mkparams.get_args() diff --git a/Master/texmf-dist/scripts/make4ht/make4ht-config.lua b/Master/texmf-dist/scripts/make4ht/make4ht-config.lua index bd83632a574..310f5afd7bf 100755 --- a/Master/texmf-dist/scripts/make4ht/make4ht-config.lua +++ b/Master/texmf-dist/scripts/make4ht/make4ht-config.lua @@ -21,7 +21,7 @@ local xdg_config = function(filename, xdg_config_name) local dotfilename = "." .. filename local xdg_config_name = xdg_config_name or "config.lua" local xdg = os.getenv("XDG_CONFIG_HOME") or ((os.getenv("HOME") or "") .. "/.config") - local home = os.getenv("HOME") + local home = os.getenv("HOME") or os.getenv("USERPROFILE") if xdg then -- filename like ~/.config/make4ht/config.lua local fn = make_name{ xdg ,filename , xdg_config_name } |