diff options
author | Karl Berry <karl@freefriends.org> | 2017-04-19 23:04:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-04-19 23:04:15 +0000 |
commit | f74161ca4e7eb3c5af9afcbe92522ae3b58987c1 (patch) | |
tree | 3c30a13df5ac7968195c85070a2b074578e669d2 /Master/texmf-dist/tex/context/base/mkiv/meta-ini.lua | |
parent | 1d5a55ac8f5506a7ae9cfca52f4b588182e199d4 (diff) |
context beta/cont-tmf.zip (Apr 16 12:55)
git-svn-id: svn://tug.org/texlive/trunk@43931 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/meta-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/meta-ini.lua | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/meta-ini.lua index 8f713126323..d3865c4330d 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/meta-ini.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/meta-ini.lua @@ -75,45 +75,53 @@ local dimenorname = + (C(lpegpatterns.float) + Cc(1)) * lpegpatterns.space^0 * P("\\") * C(lpegpatterns.letter^1) / function(f,s) local t = textype(s) if t == "dimen" then - context("\\the\\dimexpr %s\\%s",f,s) + context("\\the\\dimexpr %s\\%s\\relax",f,s) elseif t == "count" then context("\\the\\numexpr \\%s * %s\\relax",s,f) -- <n>\scratchcounter is not permitted end end -local splitter = lpeg.splitat(":",true) - -function commands.prepareMPvariable(v) -- slow but ok - if v == "" then - MPcolor("black") - else - local typ, var = lpegmatch(splitter,v) - if not var then - -- parse - if colorhash[v] then - MPcolor(v) - elseif tonumber(v) then - context(v) - elseif not lpegmatch(dimenorname,v) then - context("\\number %s",v) -- 0.4 ... - end - elseif typ == "d" then -- to be documented - -- dimension - context("\\the\\dimexpr %s",var) - elseif typ == "n" then -- to be documented - -- number - context("\\the\\numexpr %s",var) - elseif typ == "s" then -- to be documented - -- string - context(var) - elseif typ == "c" then -- to be documented - -- color - MPcolor(var) +local splitter = lpeg.splitat("::",true) + +interfaces.implement { + name = "prepareMPvariable", + arguments = "string", + actions = function(v) + if v == "" then + -- MPcolor("black") + context("black") else - context(var) + local typ, var = lpegmatch(splitter,v) + if not var then + -- parse + if colorhash[v] then + -- MPcolor(v) + context("%q",var) + elseif tonumber(v) then + context(v) + elseif not lpegmatch(dimenorname,v) then + context("\\number %s",v) -- 0.4 ... + end + elseif typ == "d" then -- to be documented + -- dimension + context("\\the\\dimexpr %s\\relax",var) + elseif typ == "n" then -- to be documented + -- number + context("\\the\\numexpr %s\\relax",var) + elseif typ == "s" then -- to be documented + -- string + -- context(var) + context("%q",var) + elseif typ == "c" then -- to be documented + -- color + -- MPcolor(var) + context("%q",var) + else + context(var) + end end end -end +} -- function metapost.formatnumber(f,n) -- just lua format -- f = gsub(f,"@(%d)","%%.%1") |