summaryrefslogtreecommitdiff
path: root/tex/generic
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2012-08-10 19:40:00 +0200
committerHans Hagen <pragma@wxs.nl>2012-08-10 19:40:00 +0200
commitfda5a913473511bc21c6424069fcbd520d12b6f0 (patch)
tree52ffb3158983f3eafd3a3cd4831c894bc9c6d0cc /tex/generic
parentb9367ecbb2e7dcb9993f2cf30e56c3e4031edfa8 (diff)
downloadcontext-fda5a913473511bc21c6424069fcbd520d12b6f0.tar.gz
beta 2012.08.10 19:40
Diffstat (limited to 'tex/generic')
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua31
1 files changed, 29 insertions, 2 deletions
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 4e9816bd8..fb1bba060 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 : 08/10/12 00:32:43
+-- merge date : 08/10/12 19:40:14
do -- begin closure to overcome local limits and interference
@@ -1121,6 +1121,23 @@ local lpeg = require("lpeg")
local report = texio and texio.write_nl or print
+-- Watch this: Lua does some juggling with replacement values and although lpeg itself is agnostic of
+-- % characters, the replacement isn't. Now, in all of the context sources these are only a few cases
+-- where capture replacement instring happens. Interesting is that the string parsing already happens
+-- when the lpeg is made, but nevertheless is a not that useful (at least for me) feature that has the
+-- side effect that one always has to do %% in order to get a %. Okay, now that I know it is there, I
+-- might use it more often.
+--
+-- local p = P("@") / "%"
+-- lpeg.print(p) print(lpeg.match(p,"@"))
+--
+-- local p = P("@") / "%%"
+-- lpeg.print(p) print(lpeg.match(p,"@"))
+--
+-- local p = C("@") * C("!") / "%2%1"
+-- lpeg.print(p) print(lpeg.match(p,"@!"))
+
+
-- local lpmatch = lpeg.match
-- local lpprint = lpeg.print
-- local lpp = lpeg.P
@@ -1156,7 +1173,7 @@ local report = texio and texio.write_nl or print
-- function lpeg.Carg (l) local p = lpcarg(l) report("LPEG Carg =") lpprint(l) return p end
local type = type
-local byte, char, gmatch = string.byte, string.char, string.gmatch
+local byte, char, gmatch, format = string.byte, string.char, string.gmatch, string.format
-- Beware, we predefine a bunch of patterns here and one reason for doing so
-- is that we get consistent behaviour in some of the visualizers.
@@ -1873,6 +1890,16 @@ end
-- utfchar(0x205F), -- math thinspace
-- } )
+-- handy from within tex:
+
+local lpegmatch = lpeg.match
+
+local replacer = lpeg.replacer("@","%%") -- Watch the escaped % in lpeg!
+
+function string.tformat(fmt,...)
+ return format(lpegmatch(replacer,fmt),...)
+end
+
end -- closure
do -- begin closure to overcome local limits and interference