summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/make4ht
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-12-11 23:15:24 +0000
committerKarl Berry <karl@freefriends.org>2015-12-11 23:15:24 +0000
commit7b226b60f1c5dce3911375f82c4711dc6ff30fc3 (patch)
tree748db231119c3d8b41dc7101de867c1a6ebb8689 /Master/texmf-dist/scripts/make4ht
parent7870a781c1a56b03d9e4fa902003361b9119b090 (diff)
make4ht (11dec15)
git-svn-id: svn://tug.org/texlive/trunk@39075 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/make4ht')
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/lapp-mk4.lua14
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht3
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/mkparams.lua34
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/mkutils.lua14
4 files changed, 56 insertions, 9 deletions
diff --git a/Master/texmf-dist/scripts/make4ht/lapp-mk4.lua b/Master/texmf-dist/scripts/make4ht/lapp-mk4.lua
index 71ed3704077..89d5c7061ac 100755
--- a/Master/texmf-dist/scripts/make4ht/lapp-mk4.lua
+++ b/Master/texmf-dist/scripts/make4ht/lapp-mk4.lua
@@ -52,6 +52,15 @@ local function quit(msg,no_usage)
os.exit(1);
end
+local function help()
+ print(usage)
+ os.exit()
+end
+
+local function version()
+ return {version = true}
+end
+
local function error(msg,no_usage)
quit(arg[0]:gsub('.+[\\/]','')..':'..msg,no_usage)
end
@@ -258,7 +267,10 @@ function process_options_string(str)
end
end
if parm == 'h' or parm == 'help' then
- quit()
+ help()
+ end
+ if parm == "v" or parm == "version" then
+ return version()
end
if aliases[parm] then parm = aliases[parm] end
ps = parms[parm]
diff --git a/Master/texmf-dist/scripts/make4ht/make4ht b/Master/texmf-dist/scripts/make4ht/make4ht
index 22b2e7cf2fb..49b1d0159a5 100755
--- a/Master/texmf-dist/scripts/make4ht/make4ht
+++ b/Master/texmf-dist/scripts/make4ht/make4ht
@@ -1,7 +1,10 @@
#!/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")
diff --git a/Master/texmf-dist/scripts/make4ht/mkparams.lua b/Master/texmf-dist/scripts/make4ht/mkparams.lua
index 04b2827e102..0dc74a0ce16 100755
--- a/Master/texmf-dist/scripts/make4ht/mkparams.lua
+++ b/Master/texmf-dist/scripts/make4ht/mkparams.lua
@@ -11,12 +11,14 @@ ${progname} [options] filename ["tex4ht.sty op." "tex4ht op." "t4ht op" "latex o
-c,--config (default xhtml) Custom config file
-d,--output-dir (default nil) Output directory
-e,--build-file (default nil) If build file is different than `filename`.mk4
+-h,-- help Display this message
-l,--lua Use lualatex for document compilation
-m,--mode (default default) Switch which can be used in the makefile
-n,--no-tex4ht Disable dvi file processing with tex4ht command
-s,--shell-escape Enables running external programs from LaTeX
-u,--utf8 For output documents in utf8 encoding
-x,--xetex Use xelatex for document compilation
+-v,--version Display version number
]]
local function get_args(parameters, optiontext)
local parameters = parameters or {}
@@ -40,11 +42,16 @@ local function process_args(args)
end
end
+ if args.version ==true then
+ print "make4ht version 0.1b"
+ os.exit()
+ end
+
local outdir = ""
local packages = ""
if args["output-dir"] ~= "nil" then
- outdir = args["output-dir"]
+ outdir = args["output-dir"] or ""
outdir = outdir:gsub('\\','/')
outdir = outdir:gsub('/$','')
end
@@ -62,10 +69,30 @@ local function process_args(args)
local input = mkutils.remove_extension(args.filename)
local latex_params = {}
+ local tex_file = input
local insert_latex = get_inserter(args,latex_params)
insert_latex("shell-escape","-shell-escape")
- table.insert(latex_params,"-jobname="..input)
- table.insert(latex_params,args[4] or "")
+ local latex_cli_params = args[4] or ""
+ if not latex_cli_params:match("%-jobname") then
+ table.insert(latex_params,"-jobname="..input)
+ else
+ -- when user specifies -jobname, we must change name of the input file,
+ -- in order to be able to process correct dvi file with tex4ht and t4ht
+ local newinput
+ local first, rest = latex_cli_params:match("%-jobname=(.)(.*)")
+ if first=='"' then
+ newinput=rest:match('([^"]+)')
+ elseif first=="'" then
+ newinput=rest:match("([^']+)")
+ elseif type(first)== "string" then
+ rest = first.. rest
+ newinput = rest:match("([^ ]+)")
+ end
+ if newinput then
+ input = newinput
+ end
+ end
+ table.insert(latex_params, latex_cli_params)
--table.insert(latex_params,args["shell-escape"] and "-shell-escape")
@@ -111,6 +138,7 @@ local function process_args(args)
local parameters = {
htlatex = compiler
,input=input
+ ,tex_file=tex_file
,packages=packages
,latex_par=table.concat(latex_params," ")
--,config=ebookutils.remove_extension(args.config)
diff --git a/Master/texmf-dist/scripts/make4ht/mkutils.lua b/Master/texmf-dist/scripts/make4ht/mkutils.lua
index ca9e2ff208a..e550ead9801 100755
--- a/Master/texmf-dist/scripts/make4ht/mkutils.lua
+++ b/Master/texmf-dist/scripts/make4ht/mkutils.lua
@@ -248,7 +248,7 @@ env.Make:add("htlatex",function(par)
"\\HCode\\expandafter\\def\\csname tex4ht\\endcsname{#1,html}\\def"..
"\\HCode####1{\\documentstyle[tex4ht,}\\@ifnextchar[{\\HCode}{"..
"\\documentstyle[tex4ht]}}}\\makeatother\\HCode ${tex4ht_sty_par}.a.b.c."..
-"\\input ${input}'"
+"\\input ${tex_file}'"
if os.type == "windows" then
command = command:gsub("'",'')
end
@@ -270,16 +270,20 @@ env.Make:add("htlatex",function(par)
return 0
end
,{correct_exit=0})
-env.Make:add("tex4ht","tex4ht ${tex4ht_par} ${input}", nil, 1)
-env.Make:add("t4ht","t4ht ${t4ht_par} ${input}.${ext}",{ext="dvi"},1)
+env.Make:add("tex4ht","tex4ht ${tex4ht_par} \"${input}\"", nil, 1)
+env.Make:add("t4ht","t4ht ${t4ht_par} \"${input}.${ext}\"",{ext="dvi"},1)
function load_config(settings, config_name)
local settings = settings or main_settings
env.settings = settings
env.mode = settings.mode
- local config_name = config_name or "config.lua"
+ local config_name = kpse.find_file(config_name, 'texmfscripts') or config_name
local f = io.open(config_name,"r")
- if not f then return env, "Cannot open config file" end
+ if not f then
+ print("Cannot open config file", config_name)
+ return env
+ end
+ print("Using build file", config_name)
local code = f:read("*all")
local fn, msg = run(code,env)
if not fn then print(msg) end