forked from sile-typesetter/sile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsile.in
executable file
·54 lines (54 loc) · 1.7 KB
/
sile.in
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
#!@LUA@
package.path = '?.lua;@SILE_PATH@/?.lua;@SILE_PATH@/lua-libraries/?.lua;@SILE_PATH@/lua-libraries/?/init.lua;lua-libraries/?.lua;lua-libraries/?/init.lua;' .. package.path
local pathvar = os.getenv("SILE_PATH")
if pathvar then
for path in string.gmatch(pathvar, "[^;]+") do
package.path = path .. "/?.lua;" .. package.path
end
end
package.cpath = package.cpath .. ";core/?.@SHARED_LIB_EXT@;@SILE_LIB_PATH@/?.@SHARED_LIB_EXT@;"
SILE = require("core/sile")
io.stdout:setvbuf 'no'
SILE.parseArguments()
if not os.getenv 'LUA_REPL_RLWRAP' then
io.stderr:write('This is SILE '..SILE.version..'\n')
end
SILE.init()
if SILE.masterFilename then
if SILE.preamble then
for _, preamble in pairs(SILE.preamble) do
io.stderr:write("Loading "..preamble)
local c = SILE.resolveFile("classes/"..preamble)
local f = SILE.resolveFile(preamble)
if c then
SILE.readFile(c)
elseif f then
SILE.readFile(f)
else
SILE.require("classes/"..preamble)
end
end
end
if SU.debugging("profile") and pcall(function () require("ProFi") end) then
ProFi = require 'ProFi'
ProFi:start()
end
p,e = pcall(function() SILE.readFile(unparsed[1]) end)
if not p then
if type(e) == "string" and e:match(": interrupted!") then
SILE.outputter:finish()
else
io.stderr:write("\nError detected:\n"..e.."\n")
end
os.exit(1)
end
if SILE.preamble then SILE.documentState.documentClass:finish() end
io.stderr:write("\n")
if SU.debugging("profile") and pcall(function () require("ProFi") end) then
ProFi:stop()
ProFi:writeReport( 'sile-profile.txt' )
end
if SU.debugging("versions") then SILE.shaper.debugVersions() end
else
SILE.repl()
end