diff options
author | Hans Hagen <pragma@wxs.nl> | 2013-01-27 21:24:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2013-01-27 21:24:00 +0100 |
commit | fa502d65e5e502ef6a26eeb246267ced520ed139 (patch) | |
tree | 01a1ec7a640311bf0af1ae1996675cae04000810 /tex/context/base/util-str.lua | |
parent | 33fc570519a96f61b586ade8e4833326caaeaf7a (diff) | |
download | context-fa502d65e5e502ef6a26eeb246267ced520ed139.tar.gz |
beta 2013.01.27 21:24
Diffstat (limited to 'tex/context/base/util-str.lua')
-rw-r--r-- | tex/context/base/util-str.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tex/context/base/util-str.lua b/tex/context/base/util-str.lua index bade3493a..a4889d252 100644 --- a/tex/context/base/util-str.lua +++ b/tex/context/base/util-str.lua @@ -185,6 +185,23 @@ end local format_d = format_i +function number.signed(i) + if i > 0 then + return "+", i + else + return "-", -i + end +end + +local format_I = function(f) + n = n + 1 + if f and f ~= "" then + return format("format('%%s%%%si',signed((select(%s,...))))",f,n) + else + return format("format('%%s%%i',signed((select(%s,...))))",n) + end +end + local format_f = function(f) n = n + 1 return format("format('%%%sf',(select(%s,...)))",f,n) @@ -317,6 +334,7 @@ local builder = Ct { "start", + V("p") + V("b") + V("t") + V("l") + + V("I") ) + V("a") )^0, @@ -345,6 +363,7 @@ local builder = Ct { "start", ["b"] = (prefix_any * P("b")) / format_b, -- %b => 12.342bp / maybe: B (and more units) ["t"] = (prefix_tab * P("t")) / format_t, -- %t => concat ["l"] = (prefix_tab * P("l")) / format_l, -- %l => boolean + ["I"] = (prefix_any * P("I")) / format_I, -- %I => signed integer -- ["a"] = Cs(((1-P("%"))^1 + P("%%")/"%%")^1) / format_a, -- %a => text (including %%) } @@ -354,6 +373,7 @@ local builder = Ct { "start", local template = [[ local format = string.format local concat = table.concat +local signed = number.signed local points = number.points local basepoints = number.basepoints local utfchar = utf.char |