summaryrefslogtreecommitdiff
path: root/tex/context/base/util-tpl.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2014-10-07 11:14:00 +0530
committerHans Hagen <pragma@wxs.nl>2014-10-07 11:14:00 +0530
commitccdd2d9e98ac3bbf794eefd5a42ed063832a61b3 (patch)
tree6d4ce4ebf4876b443cdb40cfa74caf7970c61ebe /tex/context/base/util-tpl.lua
parent2b89b4ede02fd02fe66597e9c314dbfcfa4c0ecb (diff)
downloadcontext-ccdd2d9e98ac3bbf794eefd5a42ed063832a61b3.tar.gz
beta 2014.10.07 11:14
Diffstat (limited to 'tex/context/base/util-tpl.lua')
-rw-r--r--tex/context/base/util-tpl.lua20
1 files changed, 15 insertions, 5 deletions
diff --git a/tex/context/base/util-tpl.lua b/tex/context/base/util-tpl.lua
index 67d058221..bd0e261a9 100644
--- a/tex/context/base/util-tpl.lua
+++ b/tex/context/base/util-tpl.lua
@@ -52,7 +52,7 @@ local sqlescape = lpeg.replacer {
-- { "\t", "\\t" },
}
-local sqlquoted = lpeg.Cs(lpeg.Cc("'") * sqlescape * lpeg.Cc("'"))
+local sqlquoted = Cs(Cc("'") * sqlescape * Cc("'"))
lpegpatterns.sqlescape = sqlescape
lpegpatterns.sqlquoted = sqlquoted
@@ -111,13 +111,21 @@ local luaescaper = escapers.lua
local quotedluaescaper = quotedescapers.lua
local function replacekeyunquoted(s,t,how,recurse) -- ".. \" "
- local escaper = how and escapers[how] or luaescaper
- return escaper(replacekey(s,t,how,recurse))
+ if how == false then
+ return replacekey(s,t,how,recurse)
+ else
+ local escaper = how and escapers[how] or luaescaper
+ return escaper(replacekey(s,t,how,recurse))
+ end
end
local function replacekeyquoted(s,t,how,recurse) -- ".. \" "
- local escaper = how and quotedescapers[how] or quotedluaescaper
- return escaper(replacekey(s,t,how,recurse))
+ if how == false then
+ return replacekey(s,t,how,recurse)
+ else
+ local escaper = how and quotedescapers[how] or quotedluaescaper
+ return escaper(replacekey(s,t,how,recurse))
+ end
end
local single = P("%") -- test %test% test : resolves test
@@ -188,3 +196,5 @@ end
-- inspect(utilities.templates.replace("test %one% test", { one = "%two%", two = "two" }))
-- inspect(utilities.templates.resolve({ one = "%two%", two = "two", three = "%three%" }))
+-- inspect(utilities.templates.replace("test %one% test", { one = "%two%", two = "two" },false,true))
+-- inspect(utilities.templates.replace("test %one% test", { one = "%two%", two = "two" },false))