diff options
author | Karl Berry <karl@freefriends.org> | 2019-03-21 20:55:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-03-21 20:55:01 +0000 |
commit | 042522d56eecc50b11be37d5284fc43d2a6b51fe (patch) | |
tree | 2db37cb0741816116a1ce464676f8966b14f5c2d | |
parent | 15bbde433ae20973daca814631a22c558eaecd57 (diff) |
make4ht (21mar19)
git-svn-id: svn://tug.org/texlive/trunk@50511 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/make4ht/make4ht | 2 | ||||
-rwxr-xr-x | Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl | 52 | ||||
-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 |
12 files changed, 187 insertions, 33 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/make4ht/make4ht b/Build/source/texk/texlive/linked_scripts/make4ht/make4ht index 44c3582134a..ab8e1cfbc6f 100755 --- a/Build/source/texk/texlive/linked_scripts/make4ht/make4ht +++ b/Build/source/texk/texlive/linked_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/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl b/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl index 658e5313111..a1352ebbc9d 100755 --- a/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl +++ b/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl @@ -1,6 +1,6 @@ #!/usr/bin/env wish -# Copyright 2017, 2018 Siep Kroonenberg +# Copyright 2017-2019 Siep Kroonenberg # This file is licensed under the GNU General Public License version 2 # or any later version. @@ -10,8 +10,7 @@ package require Tk # security: disable send catch {rename send {}} -# unix: make sure TL comes first on process searchpath -# on windows, runscript takes care of this. +# make sure TL comes first on process searchpath if {$::tcl_platform(platform) ne "windows"} { set texbin [file dirname [file normalize [info script]]] set savedir [pwd] @@ -132,6 +131,7 @@ proc long_message {str type {p "."}} { err_exit "Unsupported type $type for long_message" } create_dlg .tlmg $p + wm title .tlmg "" # wallpaper frame; see populate_main pack [ttk::frame .tlmg.bg] -fill both -expand 1 @@ -523,18 +523,6 @@ proc run_cmd_waiting {cmd} { # display_packages_info is mostly invoked by collect_filtered, but # also when the search term or the search option changes. -proc check_tlmgr_updatable {} { - run_cmd_waiting "update --self --list" - foreach l $::out_log { - if [regexp {^total-bytes[ \t]+([0-9]+)$} $l m b] { - do_debug "matches, $b" - set ::need_update_tlmgr [expr {$b > 0 ? 1 : 0}] - return - } - } - do_debug "check_tlmgr_uptodate: should not get here" -} ; # check_tlmgr_uptodate - proc is_updatable {nm} { set pk [dict get $::pkgs $nm] set lr [dict get $pk localrev] @@ -548,7 +536,7 @@ proc update_globals {} { foreach nm [dict keys $::pkgs] { if [is_updatable $nm] {incr ::n_updates} } - check_tlmgr_updatable + set ::need_update_tlmgr [is_updatable texlive.infra] set ::tlshell_updatable [is_updatable tlshell] # also update displayed status info @@ -843,7 +831,7 @@ proc show_logs {} { # collect pages in notebook widget pack [ttk::notebook .tllg.logs] -in .tllg.bg -side top -fill both -expand 1 .tllg.logs add .tllg.log -text [__ "Output"] - .tllg.logs add .tllg.err -text [__ "Errors"] + .tllg.logs add .tllg.err -text [__ "Other"] if $::ddebug { .tllg.logs add .tllg.dbg -text "Debug" raise .tllg.dbg .tllg.logs @@ -1209,6 +1197,7 @@ proc repository_dialog {} { ppack .tlr.abort -in .tlr.closebuttons -side right bind .tlr <Escape> {.tlr.abort invoke} + wm protocol .tlr WM_DELETE_WINDOW {.tlr.abort invoke} wm resizable .tlr 1 0 place_dlg .tlr . } ; # repository_dialog @@ -1522,6 +1511,13 @@ proc update_tlmgr {} { tk_messageBox -message [__ "Nothing to do!"] return } + if {$::tcl_platform(platform) eq "windows"} { + set ans [tk_messageBox -type okcancel -icon info -message \ + [string cat [__ "If update fails, try on a command-line:"] \ + "\ntlmgr update --self\n" \ + [__ "Use an admininstative command prompt for an admin install."]]] + if {$ans eq "cancel"} return + } run_cmd "update --self" 1 vwait ::done_waiting # tlmgr restarts itself automatically @@ -1829,7 +1825,7 @@ proc set_paper {p} { run_cmd "paper paper $p" 1 } -proc set_language {l} { +proc set_language_no_restart {l} { set ok 1 if [catch {exec kpsewhich -var-value "TEXMFCONFIG"} d] {set ok 0} if $ok { @@ -1861,12 +1857,16 @@ proc set_language {l} { } catch {chan close $fid} } - if $ok { + return $ok +} ; # set_language_no_restart + +proc set_language {l} { + if [set_language_no_restart $l] { restart_self } else { tk_messageBox -message [__ "Cannot set default GUI language"] -icon error } -} ; # set_language +} ##### running external commands ##### @@ -2022,11 +2022,9 @@ proc populate_main {} { .mn add cascade -label [__ "Help"] -menu .mn.help -underline 0 menu .mn.help .mn.help add command -label [__ "About"] -command { - tk_messageBox -message [__ "Copyright 2017, 2018 Siep Kroonenberg + tk_messageBox -message [string cat "\u00a9 2017-2019 Siep Kroonenberg -GUI interface for TeX Live Manager -Implemented in Tcl/Tk -"]} +" [__ "GUI interface for TeX Live Manager\nImplemented in Tcl/Tk"]]} .mn.help add command -label [__ "tlmgr help"] -command show_help # wallpaper frame @@ -2070,7 +2068,8 @@ Implemented in Tcl/Tk ttk::label .topf.luptodate -text [__ "Unknown"] -anchor w pgrid .topf.luptodate -row 2 -column 1 -sticky w - ttk::label .topf.llcmd -anchor w -text [__ "Last tlmgr command:"] -anchor w + ttk::label .topf.llcmd -anchor w -text [__ "Last tlmgr command:"] -anchor w \ + -wraplength [expr {60*$::cw}] -justify left pgrid .topf.llcmd -row 3 -column 0 -sticky w ttk::label .topf.lcmd -anchor w -textvariable ::last_cmd -anchor w pgrid .topf.lcmd -row 3 -column 1 -sticky w @@ -2250,6 +2249,9 @@ proc initialize {} { lappend ::langs [string range [file tail $l] 0 end-3] } + # store language in tlmgr configuration + set_language_no_restart $::lang + # in case we are going to do something with json: # add json subdirectory to auto_path, but at low priority # since the tcl/tk installation may already have a better implementation. 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 } |