diff options
author | Marius <mariausol@gmail.com> | 2011-12-31 14:40:26 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-12-31 14:40:26 +0200 |
commit | 11dde3f4c6c0584ff20070edc1b1aad0b9013d30 (patch) | |
tree | aa8df33f2319e97b9d1634f042504433110941fb /scripts | |
parent | 90cec652f5ae1daee6d4c252c5caa6a39ad719fc (diff) | |
download | context-11dde3f4c6c0584ff20070edc1b1aad0b9013d30.tar.gz |
beta 2011.12.31 13:16
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/lua/mtx-context.lua | 8 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 4 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 4 | ||||
-rw-r--r-- | scripts/context/stubs/unix/mtxrun | 4 |
4 files changed, 11 insertions, 9 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 7323e8b04..16e8962c4 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -642,14 +642,16 @@ scripts.context.defaultformats = { -- "plain" } +local lpegpatterns, Cs, P = lpeg.patterns, lpeg.Cs, lpeg.P + +local pattern = lpegpatterns.utfbom^-1 * (P("%% ") + P("% ")) * Cs((1-lpegpatterns.newline)^1) + local function analyze(filename) -- only files on current path local f = io.open(file.addsuffix(filename,"tex")) if f then local t = { } local line = f:read("*line") or "" - -- there can be an utf bomb in front: \254\255 or \255\254 - -- a template line starts with % or %% (used in asciimode) followed by one or more spaces - local preamble = match(line,"^[\254\255]*%%%%?%s+(.+)$") + local preamble = lpeg.match(pattern,line) if preamble then for key, value in gmatch(preamble,"(%S+)%s*=%s*(%S+)") do t[key] = value diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 175263748..f3c09d598 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -4079,8 +4079,8 @@ if not math.sind then end if not math.odd then - function math.odd (n) return n % 2 == 0 end - function math.even(n) return n % 2 ~= 0 end + function math.odd (n) return n % 2 ~= 0 end + function math.even(n) return n % 2 == 0 end end diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 175263748..f3c09d598 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -4079,8 +4079,8 @@ if not math.sind then end if not math.odd then - function math.odd (n) return n % 2 == 0 end - function math.even(n) return n % 2 ~= 0 end + function math.odd (n) return n % 2 ~= 0 end + function math.even(n) return n % 2 == 0 end end diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 175263748..f3c09d598 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -4079,8 +4079,8 @@ if not math.sind then end if not math.odd then - function math.odd (n) return n % 2 == 0 end - function math.even(n) return n % 2 ~= 0 end + function math.odd (n) return n % 2 ~= 0 end + function math.even(n) return n % 2 == 0 end end |