summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/util-tbs.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/util-tbs.lua')
-rw-r--r--tex/context/base/mkiv/util-tbs.lua21
1 files changed, 19 insertions, 2 deletions
diff --git a/tex/context/base/mkiv/util-tbs.lua b/tex/context/base/mkiv/util-tbs.lua
index 140e43a03..339abcfcc 100644
--- a/tex/context/base/mkiv/util-tbs.lua
+++ b/tex/context/base/mkiv/util-tbs.lua
@@ -57,7 +57,7 @@ end
do
- local find, gmatch = string.find, string.gmatch
+ local find, gmatch, formatters = string.find, string.gmatch, string.formatters
local P, C, Ct, Cc, R = lpeg.P, lpeg.C, lpeg.Ct, lpeg.Cc, lpeg.R
@@ -72,7 +72,7 @@ do
local specifier = Ct ((entry + (separator + index + test))^1)
- function tablestore.field(namespace,name,default)
+ local function field(namespace,name,default)
local data = loaded[namespace] or current
if data then
-- if find(name,"%[") then
@@ -111,4 +111,21 @@ do
end
end
+
+ function length(namespace,name,default)
+ local data = field(namespace,name)
+ return type(data) == "table" and #data or 0
+ end
+
+ function formatted(namespace,name,fmt)
+ local data = field(namespace,name)
+ if data then
+ return formatters[fmt](data)
+ end
+ end
+
+ tablestore.field = field
+ tablestore.length = length
+ tablestore.formatted = formatted
+
end