summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2013-03-05 20:20:17 +0200
committerMarius <mariausol@gmail.com>2013-03-05 20:20:17 +0200
commita88e6c978e2848ed6a557b13a39c39dd2eb7d7f3 (patch)
treebf6d62b0ea5d8d7a0d6b476517ca59db8979ead0 /tex
parenta51f6cf6ee087046a2ae5927ed4edff0a1acec1b (diff)
downloadcontext-a88e6c978e2848ed6a557b13a39c39dd2eb7d7f3.tar.gz
beta 2013.03.05 19:10
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4135 -> 4131 bytes
-rw-r--r--tex/context/base/context-version.pngbin40313 -> 40017 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/status-files.pdfbin24803 -> 24817 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin209215 -> 209244 bytes
-rw-r--r--tex/context/base/util-ran.lua107
-rw-r--r--tex/context/base/util-tpl.lua92
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
11 files changed, 184 insertions, 25 deletions
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index d48699773..43e85bbda 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2013.03.05 16:40}
+\newcontextversion{2013.03.05 19:10}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 5f1458551..458c168af 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2013.03.05 16:40}
+\newcontextversion{2013.03.05 19:10}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index b4229a6ae..597c8952e 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 429cde9e0..2940bcabd 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 6295767a5..a24c9939b 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2013.03.05 16:40}
+\edef\contextversion{2013.03.05 19:10}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 991356070..d846c90c3 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -25,7 +25,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2013.03.05 16:40}
+\edef\contextversion{2013.03.05 19:10}
%D For those who want to use this:
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 3bd3b5a33..af6e79ce9 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index bd56f837b..f6e8fb0a8 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/util-ran.lua b/tex/context/base/util-ran.lua
new file mode 100644
index 000000000..50d0a7082
--- /dev/null
+++ b/tex/context/base/util-ran.lua
@@ -0,0 +1,107 @@
+if not modules then modules = { } end modules ['util-ran'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local random = math.random
+local concat = table.concat
+local sub, upper = string.sub, string.upper
+
+local randomizers = utilities.randomizers or { }
+utilities.randomizers = randomizers
+
+local l_one = "bcdfghjklmnpqrstvwxz"
+local l_two = "aeiouy"
+
+local u_one = upper(l_one)
+local u_two = upper(l_two)
+
+local n_one = #l_one
+local n_two = #l_two
+
+function randomizers.word(min,max,separator)
+ local t = { }
+ for i=1,random(min,max) do
+ if i % 2 == 0 then
+ local r = random(1,n_one)
+ t[i] = sub(l_one,r,r)
+ else
+ local r = random(1,n_two)
+ t[i] = sub(l_two,r,r)
+ end
+ end
+ return concat(t,separator)
+end
+
+function randomizers.initials(min,max)
+ if not min then
+ if not max then
+ min, max = 1, 3
+ else
+ min, max = 1, min
+ end
+ elseif not max then
+ max = min
+ end
+ local t = { }
+ local n = random(min or 1,max or 3)
+ local m = 0
+ for i=1,n do
+ m = m + 1
+ if i % 2 == 0 then
+ local r = random(1,n_one)
+ t[m] = sub(u_one,r,r)
+ else
+ local r = random(1,n_two)
+ t[m] = sub(u_two,r,r)
+ end
+ m = m + 1
+ t[m] = "."
+ end
+ return concat(t)
+end
+
+function randomizers.firstname(min,max)
+ if not min then
+ if not max then
+ min, max = 3, 10
+ else
+ min, max = 1, min
+ end
+ elseif not max then
+ max = min
+ end
+ local t = { }
+ local n = random(min,max)
+ local b = true
+ if n % 2 == 0 then
+ local r = random(1,n_two)
+ t[1] = sub(u_two,r,r)
+ b = true
+ else
+ local r = random(1,n_one)
+ t[1] = sub(u_one,r,r)
+ b = false
+ end
+ for i=2,n do
+ if b then
+ local r = random(1,n_one)
+ t[i] = sub(l_one,r,r)
+ b = false
+ else
+ local r = random(1,n_two)
+ t[i] = sub(l_two,r,r)
+ b = true
+ end
+ end
+ return concat(t,separator)
+end
+
+randomizers.surname = randomizers.firstname
+
+-- for i=1,10 do
+-- print(randomizers.initials(1,3),randomizers.firstname(5,10),randomizers.surname(5,15))
+-- end
diff --git a/tex/context/base/util-tpl.lua b/tex/context/base/util-tpl.lua
index 31b2ae1f1..304c9c739 100644
--- a/tex/context/base/util-tpl.lua
+++ b/tex/context/base/util-tpl.lua
@@ -17,14 +17,14 @@ local trace_template = false trackers.register("templates.trace",function(v) t
local report_template = logs.reporter("template")
local tostring = tostring
-local format = string.format
+local format, sub = string.format, string.sub
local P, C, Cs, Carg, lpegmatch = lpeg.P, lpeg.C, lpeg.Cs, lpeg.Carg, lpeg.match
-- todo: make installable template.new
local replacer
-local function replacekey(k,t,recursive)
+local function replacekey(k,t,how,recursive)
local v = t[k]
if not v then
if trace_template then
@@ -37,7 +37,7 @@ local function replacekey(k,t,recursive)
report_template("setting key %q to value %q",k,v)
end
if recursive then
- return lpegmatch(replacer,v,1,t)
+ return lpegmatch(replacer,v,1,t,how,recursive)
else
return v
end
@@ -52,38 +52,87 @@ local sqlescape = lpeg.replacer {
-- { "\t", "\\t" },
}
+local sqlquotedescape = lpeg.Cs(lpeg.Cc("'") * sqlescape * lpeg.Cc("'"))
+
+-- escapeset : \0\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\"\\\127
+-- test string: [[1\0\31test23"\\]] .. string.char(19) .. "23"
+--
+-- slow:
+--
+-- local luaescape = lpeg.replacer {
+-- { '"', [[\"]] },
+-- { '\\', [[\\]] },
+-- { R("\0\9") * #R("09"), function(s) return "\\00" .. byte(s) end },
+-- { R("\10\31") * #R("09"), function(s) return "\\0" .. byte(s) end },
+-- { R("\0\31") , function(s) return "\\" .. byte(s) end },
+-- }
+--
+-- slightly faster:
+--
+-- local luaescape = Cs ((
+-- P('"' ) / [[\"]] +
+-- P('\\') / [[\\]] +
+-- Cc("\\00") * (R("\0\9") / byte) * #R("09") +
+-- Cc("\\0") * (R("\10\31") / byte) * #R("09") +
+-- Cc("\\") * (R("\0\31") / byte) +
+-- P(1)
+-- )^0)
+
local escapers = {
lua = function(s)
- return format("%q",s)
+ return sub(format("%q",s),2,-2)
end,
sql = function(s)
return lpegmatch(sqlescape,s)
end,
}
+local quotedescapers = {
+ lua = function(s)
+ return format("%q",s)
+ end,
+ sql = function(s)
+ return lpegmatch(sqlquotedescape,s)
+ end,
+}
+
lpeg.patterns.sqlescape = sqlescape
+lpeg.patterns.sqlescape = sqlquotedescape
+
+local luaescaper = escapers.lua
+local quotedluaescaper = quotedescapers.lua
local function replacekeyunquoted(s,t,how,recurse) -- ".. \" "
- local escaper = how and escapers[how] or escapers.lua
- return escaper(replacekey(s,t,recurse))
+ local escaper = how and escapers[how] or luaescaper
+ return escaper(replacekey(s,t,how,recurse))
end
-local single = P("%") -- test %test% test : resolves test
-local double = P("%%") -- test 10%% test : %% becomes %
-local lquoted = P("%[") -- test %[test]" test : resolves test with escaped "'s
-local rquoted = P("]%") --
-
-local escape = double / '%%'
-local nosingle = single / ''
-local nodouble = double / ''
-local nolquoted = lquoted / ''
-local norquoted = rquoted / ''
+local function replacekeyquoted(s,t,how,recurse) -- ".. \" "
+ local escaper = how and quotedescapers[how] or quotedluaescaper
+ return escaper(replacekey(s,t,how,recurse))
+end
-local key = nosingle * (C((1-nosingle)^1 * Carg(1) * Carg(2) * Carg(3))/replacekey) * nosingle
-local unquoted = nolquoted * ((C((1 - norquoted)^1) * Carg(1) * Carg(2) * Carg(3))/replacekeyunquoted) * norquoted
+local single = P("%") -- test %test% test : resolves test
+local double = P("%%") -- test 10%% test : %% becomes %
+local lquoted = P("%[") -- test '%[test]%' test : resolves to test with escaped "'s
+local rquoted = P("]%") --
+local lquotedq = P("%(") -- test %(test)% test : resolves to 'test' with escaped "'s
+local rquotedq = P(")%") --
+
+local escape = double / '%%'
+local nosingle = single / ''
+local nodouble = double / ''
+local nolquoted = lquoted / ''
+local norquoted = rquoted / ''
+local nolquotedq = lquotedq / ''
+local norquotedq = rquotedq / ''
+
+local key = nosingle * ((C((1-nosingle )^1) * Carg(1) * Carg(2) * Carg(3)) / replacekey ) * nosingle
+local quoted = nolquotedq * ((C((1-norquotedq)^1) * Carg(1) * Carg(2) * Carg(3)) / replacekeyquoted ) * norquotedq
+local unquoted = nolquoted * ((C((1-norquoted )^1) * Carg(1) * Carg(2) * Carg(3)) / replacekeyunquoted) * norquoted
local any = P(1)
- replacer = Cs((unquoted + escape + key + any)^0)
+ replacer = Cs((unquoted + quoted + escape + key + any)^0)
local function replace(str,mapping,how,recurse)
if mapping and str then
@@ -95,7 +144,10 @@ end
-- print(replace("test '%[x]%' test",{ x = [[a 'x'  a]] }))
-- print(replace("test '%[x]%' test",{ x = true }))
--- print(replace("test '%[x]%' test",{ x = [[a 'x'  a]] },'sql'))
+-- print(replace("test '%[x]%' test",{ x = [[a 'x'  a]], y = "oeps" },'sql'))
+-- print(replace("test '%[x]%' test",{ x = [[a '%y%'  a]], y = "oeps" },'sql',true))
+-- print(replace([[test %[x]% test]],{ x = [[a "x"  a]]}))
+-- print(replace([[test %(x)% test]],{ x = [[a "x"  a]]}))
templates.replace = replace
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 9b7689ac1..9dd1797e9 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 03/05/13 16:40:59
+-- merge date : 03/05/13 19:10:20
do -- begin closure to overcome local limits and interference