From ed42bd4c79946716033bf5dbedbd54bbe81f49e8 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Fri, 19 Aug 2016 01:38:26 +0200 Subject: 2016-08-19 00:35:00 --- tex/context/base/mkiv/mlib-pps.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tex/context/base/mkiv/mlib-pps.lua') diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index 8d200ac63..23091342f 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -971,6 +971,25 @@ local ctx_MPLIBsettext = context.MPLIBsettext -- we always create at least one instance (for dimensions) -- we make sure we don't do that when we use one (else counter issues with e.g. \definelabel) +local eol = S("\n\r")^1 +local cleaner = Cs((P("@@")/"@" + P("@")/"%%" + P(1))^0) +local splitter = Ct( + ( ( + P("s:") * C((1-eol)^1) + + P("n:") * ((1-eol)^1/tonumber) + + P("b:") * ((1-eol)^1/toboolean) + ) * eol^0 )^0) + +local function applyformat(s) + local t = lpegmatch(splitter,s) + if #t == 1 then + return s + else + local f = lpegmatch(cleaner,t[1]) + return formatters[f](unpack(t,2)) + end +end + local function tx_analyze(object,prescript) local data = top.texdata[metapost.properties.number] local tx_stage = prescript.tx_stage @@ -986,6 +1005,9 @@ local function tx_analyze(object,prescript) c = lpegmatch(pat,txc) end end + if prescript.tx_type == "format" then + s = applyformat(s) + end local a = tonumber(prescript.tr_alternative) local t = tonumber(prescript.tr_transparency) local h = fmt(tx_number,a or "-",t or "-",c or "-") -- cgit v1.2.3