summaryrefslogtreecommitdiff
path: root/support/make4ht/extensions/make4ht-ext-common_domfilters.lua
blob: 6219c95fbd2b5cb4f8a05b93667509ffdae2125f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local M = {}


-- this variable will hold the output format name
local current_format 

local filter = require "make4ht-domfilter"
-- local process = filter {"fixinlines", "idcolons", "joincharacters" }

-- filters support only html formats
function M.test(format)
  current_format = format
  -- if format == "odt" then return false end
  return true
end

function M.modify_build(make)
  -- number of filters that should be moved to the beginning
  local count = 0
  if current_format == "odt" then
    -- some formats doesn't make sense in the ODT format
    local process = filter {"joincharacters", "mathmlfixes"}
    local charclasses = {mn = true, ["text:span"] = true, mi=true}
    make:match("4oo$", process, {charclasses= charclasses})
    -- match math documents
    make:match("4om$", process, {charclasses= charclasses})
    count = 2
  else
    local process = filter {"fixinlines", "idcolons", "joincharacters", "mathmlfixes", "tablerows","booktabs", "sectionid", "itemparagraphs"}
    make:match("html?$", process)
    count = 1
  end
  return make
end

return M