summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/make4ht/make4ht
blob: 15bda54aca8d20640ac10ae62028b47ac48b755b (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env texlua
-- Package make4ht. Author Michal Hoftich <michal.h21@gmail.com>
-- This package is subject of LPPL license, version 1.3 
kpse.set_program_name("luatex")



local make4ht = require("make4ht-lib")
local lapp    = require("lapp-mk4")
local mkutils = require("mkutils")
local mkparams = require("mkparams")
-- args string is here just as sample, we dont pass it it to 
-- mkparams.get_args() so default args string is used
local args    =  [[
make4ht - build system for tex4ht
Usage:
make4ht [options] filename ["tex4ht.sty op." "tex4ht op." "t4ht op" "latex op"]
-c,--config (default xhtml) Custom config file
-d,--output-dir (default nil)  Output directory
-l,--lua  Use lualatex for document compilation
-s,--shell-escape Enables running external programs from LaTeX
-u,--utf8  For output documents in utf8 encoding
-x,--xetex Use xelatex for document compilation
<filename> (string) Input file name
]]

-- set version number. the template should be replaced by the
-- actual version number by the build script
local version = "v0.1c"
mkparams.version_number = version

local args = mkparams.get_args()

local parameters = mkparams.process_args(args) 

local mode = parameters.mode
local build_file = parameters.build_file 

local make = mkutils.load_config(parameters, build_file)["Make"]
make.params = parameters
if make:length() < 1 then
	if mode == "draft" then
		make:htlatex()
	else
		make:htlatex()
		make:htlatex()
		make:htlatex()
	end
end


if not args["no-tex4ht"] then
  make:tex4ht()
end

local ext = args.xetex and "xdv" or "dvi"
if #make.image_patterns > 0 then
  make.params.t4ht_par = make.params.t4ht_par .. " -p"
end
make:t4ht {ext = ext}
make:match("tmp$", function() return false,"tmp file" end)
make:match(".*",function(filename,par)
	local outdir =  '' --par["outdir"] and par["outdir"] .."/" or ''
	if par['outdir'] ~= "" then outdir = par['outdir'] .. '/' end
	print("outdir: "..outdir)
	local outfilename = outdir .. filename
	mkutils.copy(filename,outfilename)
	return true
end)
make:run()