texlive[47548] Master: make4ht lua files in runtime

commits+karl at tug.org commits+karl at tug.org
Tue May 1 19:59:55 CEST 2018


Revision: 47548
          http://tug.org/svn/texlive?view=revision&revision=47548
Author:   karl
Date:     2018-05-01 19:59:54 +0200 (Tue, 01 May 2018)
Log Message:
-----------
make4ht lua files in runtime

Modified Paths:
--------------
    trunk/Master/tlpkg/libexec/ctan2tds

Added Paths:
-----------
    trunk/Master/texmf-dist/scripts/make4ht/extensions/
    trunk/Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua
    trunk/Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua
    trunk/Master/texmf-dist/scripts/make4ht/extensions/latexmk.lua
    trunk/Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua
    trunk/Master/texmf-dist/scripts/make4ht/extensions/tidy.lua
    trunk/Master/texmf-dist/scripts/make4ht/formats/
    trunk/Master/texmf-dist/scripts/make4ht/formats/html5.lua
    trunk/Master/texmf-dist/scripts/make4ht/formats/odt.lua
    trunk/Master/texmf-dist/scripts/make4ht/formats/xhtml.lua

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/support/make4ht/extensions/
    trunk/Master/texmf-dist/doc/support/make4ht/formats/

Added: trunk/Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua	2018-05-01 17:59:54 UTC (rev 47548)
@@ -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


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/extensions/common_domfilters.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua	2018-05-01 17:59:54 UTC (rev 47548)
@@ -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


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/extensions/common_filters.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/make4ht/extensions/latexmk.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/extensions/latexmk.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/extensions/latexmk.lua	2018-05-01 17:59:54 UTC (rev 47548)
@@ -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


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/extensions/latexmk.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua	2018-05-01 17:59:54 UTC (rev 47548)
@@ -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


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/extensions/mathjaxnode.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/make4ht/extensions/tidy.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/extensions/tidy.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/extensions/tidy.lua	2018-05-01 17:59:54 UTC (rev 47548)
@@ -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 <meta name="hello" content="world">)
+-- 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


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/extensions/tidy.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/make4ht/formats/html5.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/formats/html5.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/formats/html5.lua	2018-05-01 17:59:54 UTC (rev 47548)
@@ -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


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/formats/html5.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/make4ht/formats/odt.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/formats/odt.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/formats/odt.lua	2018-05-01 17:59:54 UTC (rev 47548)
@@ -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


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/formats/odt.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/make4ht/formats/xhtml.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/formats/xhtml.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/make4ht/formats/xhtml.lua	2018-05-01 17:59:54 UTC (rev 47548)
@@ -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


Property changes on: trunk/Master/texmf-dist/scripts/make4ht/formats/xhtml.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2018-05-01 17:57:42 UTC (rev 47547)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2018-05-01 17:59:54 UTC (rev 47548)
@@ -2834,7 +2834,7 @@
  'luamesh'		=> '\.lua$',
  'luasseq'              => '\.lua$',
  'lyluatex'		=> '\.lua$',
- 'make4ht'		=> 'filters|\.lua$',
+ 'make4ht'		=> '(extensions|filters|formats|\.lua)$',
  'mycv'                 => 'mycv_split_contents\.pl',
  'pgfmolbio'		=> '\.lua$',
  'placeat'              => '\.lua$',



More information about the tex-live-commits mailing list