summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/util-str.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/util-str.lua')
-rw-r--r--tex/context/base/mkiv/util-str.lua33
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)