texlive[50511] trunk: make4ht (21mar19)

commits+karl at tug.org commits+karl at tug.org
Thu Mar 21 21:55:02 CET 2019


Revision: 50511
          http://tug.org/svn/texlive?view=revision&revision=50511
Author:   karl
Date:     2019-03-21 21:55:01 +0100 (Thu, 21 Mar 2019)
Log Message:
-----------
make4ht (21mar19)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht
    trunk/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl
    trunk/Master/texmf-dist/doc/support/make4ht/README
    trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex
    trunk/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf
    trunk/Master/texmf-dist/doc/support/make4ht/readme.tex
    trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtimagesize.lua
    trunk/Master/texmf-dist/scripts/make4ht/formats/odt.lua
    trunk/Master/texmf-dist/scripts/make4ht/make4ht
    trunk/Master/texmf-dist/scripts/make4ht/make4ht-config.lua

Added Paths:
-----------
    trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincolors.lua
    trunk/Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua

Modified: trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht	2019-03-21 20:54:31 UTC (rev 50510)
+++ trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht	2019-03-21 20:55:01 UTC (rev 50511)
@@ -27,7 +27,7 @@
 
 -- 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()

Modified: trunk/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl	2019-03-21 20:54:31 UTC (rev 50510)
+++ trunk/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl	2019-03-21 20:55:01 UTC (rev 50511)
@@ -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 @@
 # 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 @@
     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 @@
 # 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 @@
   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 @@
   # 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 @@
   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 @@
     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 @@
   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 @@
     }
     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 @@
   .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 @@
   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 @@
     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.

Modified: trunk/Master/texmf-dist/doc/support/make4ht/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/make4ht/README	2019-03-21 20:54:31 UTC (rev 50510)
+++ trunk/Master/texmf-dist/doc/support/make4ht/README	2019-03-21 20:55:01 UTC (rev 50511)
@@ -134,6 +134,10 @@
 `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 @@
 
 :  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.

Modified: trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex	2019-03-21 20:54:31 UTC (rev 50510)
+++ trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex	2019-03-21 20:55:01 UTC (rev 50511)
@@ -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

Modified: trunk/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/make4ht/readme.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/make4ht/readme.tex	2019-03-21 20:54:31 UTC (rev 50510)
+++ trunk/Master/texmf-dist/doc/support/make4ht/readme.tex	2019-03-21 20:55:01 UTC (rev 50511)
@@ -168,6 +168,8 @@
 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 @@
 \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.

Added: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincolors.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincolors.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincolors.lua	2019-03-21 20:55:01 UTC (rev 50511)
@@ -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


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-joincolors.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtimagesize.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtimagesize.lua	2019-03-21 20:54:31 UTC (rev 50510)
+++ trunk/Master/texmf-dist/scripts/make4ht/domfilters/make4ht-odtimagesize.lua	2019-03-21 20:55:01 UTC (rev 50511)
@@ -7,8 +7,8 @@
       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

Added: trunk/Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua	2019-03-21 20:55:01 UTC (rev 50511)
@@ -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


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/extensions/join_colors.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/make4ht/formats/odt.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/formats/odt.lua	2019-03-21 20:54:31 UTC (rev 50510)
+++ trunk/Master/texmf-dist/scripts/make4ht/formats/odt.lua	2019-03-21 20:55:01 UTC (rev 50511)
@@ -130,7 +130,7 @@
   -- 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)

Modified: trunk/Master/texmf-dist/scripts/make4ht/make4ht
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht	2019-03-21 20:54:31 UTC (rev 50510)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht	2019-03-21 20:55:01 UTC (rev 50511)
@@ -27,7 +27,7 @@
 
 -- 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()

Modified: trunk/Master/texmf-dist/scripts/make4ht/make4ht-config.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht-config.lua	2019-03-21 20:54:31 UTC (rev 50510)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht-config.lua	2019-03-21 20:55:01 UTC (rev 50511)
@@ -21,7 +21,7 @@
   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 }



More information about the tex-live-commits mailing list