diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2014-05-05 20:29:55 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2014-05-05 20:29:55 +0000 |
commit | ba9a57343987f1c2c72396e7c38f1fa30352c24c (patch) | |
tree | 66a8b12cdf67427ce96770fd0e9e581759aade1c /Master/texmf-dist/tex/context/base/syst-aux.lua | |
parent | 15242121b8ddf7d4a041fb3998d295dd8232e1eb (diff) |
ConTeXt 2014.04.28 23:24
git-svn-id: svn://tug.org/texlive/trunk@33856 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/syst-aux.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/syst-aux.lua | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/Master/texmf-dist/tex/context/base/syst-aux.lua b/Master/texmf-dist/tex/context/base/syst-aux.lua index b0fb8483b35..de15428f966 100644 --- a/Master/texmf-dist/tex/context/base/syst-aux.lua +++ b/Master/texmf-dist/tex/context/base/syst-aux.lua @@ -16,7 +16,8 @@ local commands, context = commands, context local settings_to_array = utilities.parsers.settings_to_array local format = string.format local utfsub = utf.sub -local P, C, Carg, lpegmatch, utf8char = lpeg.P, lpeg.C, lpeg.Carg, lpeg.match, lpeg.patterns.utf8char +local P, S, C, Cc, Cs, Carg, lpegmatch, utf8char = lpeg.P, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Carg, lpeg.match, lpeg.patterns.utf8char + local setvalue = context.setvalue @@ -28,6 +29,15 @@ function commands.getfirstcharacter(str) setvalue("remainingcharacters",rest) end +function commands.thefirstcharacter(str) + local first, rest = lpegmatch(pattern,str) + context(first) +end +function commands.theremainingcharacters(str) + local first, rest = lpegmatch(pattern,str) + context(rest) +end + local pattern = C(utf8char^-1) function commands.doiffirstcharelse(chr,str) @@ -68,7 +78,7 @@ end -- end -- end -local pattern = (C((1-P("%"))^1) * Carg(1)) /function(n,d) return format("%.0fsp",d * tonumber(n)/100) end * P("%") * P(-1) +local pattern = (C((1-P("%"))^1) * Carg(1)) /function(n,d) return format("%.0fsp",d * tonumber(n)/100) end * P("%") * P(-1) -- .0 ? -- commands.percentageof("10%",65536*10) @@ -78,3 +88,29 @@ end -- \gdef\setpercentdimen#1#2% -- {#1=\ctxcommand{percentageof("#2",\number#1)}\relax} + +local spaces = P(" ")^0/"" + +local pattern = Cs( + ( P("global") / "\\global" )^0 + * spaces + * ( P("unexpanded") / "\\unexpanded" )^0 + * spaces + * Cc("\\expandafter\\") + * spaces + * ( P("expanded") / "e" )^0 + * spaces + * ( P((1-S(" #"))^1) / "def\\csname %0\\endcsname" ) + * spaces + * Cs( (P("##")/"#" + P(1))^0 ) +) + +function commands.thetexdefinition(str) + context(lpegmatch(pattern,str)) +end + +local upper, lower, strip = utf.upper, utf.lower, string.strip + +function commands.upper(s) context(upper(s)) end +function commands.lower(s) context(lower(s)) end +function commands.strip(s) context(strip(s)) end |