texlive[49840] trunk: make4ht

commits+karl at tug.org commits+karl at tug.org
Sun Jan 27 23:49:22 CET 2019


Revision: 49840
          http://tug.org/svn/texlive?view=revision&revision=49840
Author:   karl
Date:     2019-01-27 23:49:22 +0100 (Sun, 27 Jan 2019)
Log Message:
-----------
make4ht

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht
    trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex
    trunk/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf
    trunk/Master/texmf-dist/scripts/make4ht/filters/make4ht-odttemplate.lua
    trunk/Master/texmf-dist/scripts/make4ht/make4ht

Modified: trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht	2019-01-27 22:48:57 UTC (rev 49839)
+++ trunk/Build/source/texk/texlive/linked_scripts/make4ht/make4ht	2019-01-27 22:49:22 UTC (rev 49840)
@@ -27,7 +27,7 @@
 
 -- set version number. the template should be replaced by the
 -- actual version number by the build script
-local version = "v0.2d"
+local version = "v0.2e"
 mkparams.version_number = version
 
 local args = mkparams.get_args()

Modified: trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex	2019-01-27 22:48:57 UTC (rev 49839)
+++ trunk/Master/texmf-dist/doc/support/make4ht/changelog.tex	2019-01-27 22:49:22 UTC (rev 49840)
@@ -3,6 +3,17 @@
 
 \begin{itemize}
 \item
+  2019/01/22
+
+  \begin{itemize}
+  \tightlist
+  \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
 
   \begin{itemize}

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

Modified: trunk/Master/texmf-dist/scripts/make4ht/filters/make4ht-odttemplate.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/filters/make4ht-odttemplate.lua	2019-01-27 22:48:57 UTC (rev 49839)
+++ trunk/Master/texmf-dist/scripts/make4ht/filters/make4ht-odttemplate.lua	2019-01-27 22:49:22 UTC (rev 49840)
@@ -1,5 +1,6 @@
 local mkutils = require "mkutils"
 local zip = require "zip"
+local domobject = require "luaxml-domobject"
 
 
 local function get_template_filename(settings)
@@ -12,6 +13,34 @@
   return settings.template or filtersettings.template
 end
 
+local function join_styles(old, new)
+  local old_dom = domobject.parse(old)
+  local new_dom = domobject.parse(new)
+
+  local template_styles = {}
+  local template_obj  -- <office:styles> element, we will add new styles from the generated ODT here
+
+  -- detect style names in the template file and save them in a table for easy accesss
+  for _, style in ipairs(new_dom:query_selector("office|styles *")) do
+    template_obj = template_obj or style:get_parent()
+    local name = style:get_attribute("style:name") -- get the <office:styles> element
+    if name then
+      template_styles[name] = true
+    end
+  end
+
+  -- process the generated styles and add ones not used in the template
+  for _, style in ipairs(old_dom:query_selector("office|styles *")) do
+    local name = style:get_attribute("style:name")
+    if name and not template_styles[name] then
+      template_obj:add_child_node(style)
+    end
+  end
+
+  -- return template with additional styles from the generated file
+  return new_dom:serialize()
+end
+
 return function(content, settings)
   -- use settings added from the Make:match, or default settings saved in Make object
   local templatefile = get_template_filename(settings)
@@ -23,7 +52,8 @@
     -- just break if the styles cannot be found
     if not stylesfile then return content end
     local styles = stylesfile:read("*all")
-    return styles
+    local newstyle = join_styles(content, styles)
+    return newstyle
   end
   -- just return content in the case of problems
   return content

Modified: trunk/Master/texmf-dist/scripts/make4ht/make4ht
===================================================================
--- trunk/Master/texmf-dist/scripts/make4ht/make4ht	2019-01-27 22:48:57 UTC (rev 49839)
+++ trunk/Master/texmf-dist/scripts/make4ht/make4ht	2019-01-27 22:49:22 UTC (rev 49840)
@@ -27,7 +27,7 @@
 
 -- set version number. the template should be replaced by the
 -- actual version number by the build script
-local version = "v0.2d"
+local version = "v0.2e"
 mkparams.version_number = version
 
 local args = mkparams.get_args()



More information about the tex-live-commits mailing list