-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathepub2.mk4
55 lines (47 loc) · 1.18 KB
/
epub2.mk4
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
Make:add("dvisvgm","dvisvgm -n -TS1,1 -c 1,1 -p 1- ${input}.idv")
local max_count = 5
local image_format = "${input}-${zeroes}${page}.${ext}"
local oneimage_format = "${input}.${ext}"
local function file_exists(fn)
local f = io.open(fn,"r")
if f == nil then return false else f:close() return true end
end
local function locate_file(par,ext, count)
local count = count or 0
par.ext = ext
local zeroes = string.rep("0",count)
par.zeroes = zeroes
if count > max_count then
local one = oneimage_format % par
if file_exists(one) then
return one
else
return false, "max_count exceeded"
end
end
local fn = image_format % par
if file_exists(fn) then
return fn
else
return locate_file(par, ext, count+1)
end
end
Make:htlatex{}
Make:htlatex{}
Make:htlatex{}
Make:tex4ht{}
Make:t4ht{}
Make:dvisvgm{}
Make:image("svg$",function(arg)
arg.input = arg.source:gsub(".idv$","")
local fn,msg = locate_file(arg, "svg")
if not fn then
print("Image processing error: "..msg)
else
arg.filename = fn
local cmd = "mv ${filename} ${output}" % arg
print(cmd)
os.execute(cmd)
end
end
)