diff options
author | Hans Hagen <pragma@wxs.nl> | 2019-08-20 19:19:52 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2019-08-20 19:19:52 +0200 |
commit | f6e7648f6126ffe087071531f03c674be32930f1 (patch) | |
tree | 2f2346b6d7cc3178c1ea7b3239b603c6f00e3493 /tex/context/base/mkiv/util-str.lua | |
parent | f72c2cf29d36ae836c894bad29dfd965d1af0236 (diff) | |
download | context-f6e7648f6126ffe087071531f03c674be32930f1.tar.gz |
2019-08-20 17:28:00
Diffstat (limited to 'tex/context/base/mkiv/util-str.lua')
-rw-r--r-- | tex/context/base/mkiv/util-str.lua | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/tex/context/base/mkiv/util-str.lua b/tex/context/base/mkiv/util-str.lua index 92e17b550..432b39ec5 100644 --- a/tex/context/base/mkiv/util-str.lua +++ b/tex/context/base/mkiv/util-str.lua @@ -633,7 +633,7 @@ local environment = { stripzeros = patterns.stripzeros, escapedquotes = string.escapedquotes, - FORMAT = string.f9, + FORMAT = string.f6, } -- -- -- @@ -938,13 +938,30 @@ end -- end -- end -local format_N = function(f) -- strips leading and trailing zeros - n = n + 1 - -- stripzero (singular) as we only have a number - if not f or f == "" then - f = ".9" - end -- always a leading number ! - return format("(((a%s %% 1 == 0) and format('%%i',a%s)) or lpegmatch(stripzero,format('%%%sf',a%s)))",n,n,f,n) +local format_N if environment.FORMAT then + + format_N = function(f) + n = n + 1 + if not f or f == "" then + return format("FORMAT(a%s,'%%.9f')",n) + elseif f == ".6" then + return format("FORMAT(a%s)",n) + else + return format("FORMAT(a%s,'%%%sf')",n,f) + end + end + +else + + format_N = function(f) -- strips leading and trailing zeros + n = n + 1 + -- stripzero (singular) as we only have a number + if not f or f == "" then + f = ".9" + end -- always a leading number ! + return format("(((a%s %% 1 == 0) and format('%%i',a%s)) or lpegmatch(stripzero,format('%%%sf',a%s)))",n,n,f,n) + end + end local format_a = function(f) |