summaryrefslogtreecommitdiff
path: root/tex/context/base/publ-ini.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/publ-ini.lua')
-rw-r--r--tex/context/base/publ-ini.lua32
1 files changed, 29 insertions, 3 deletions
diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua
index 91ace76fa..1ec88521e 100644
--- a/tex/context/base/publ-ini.lua
+++ b/tex/context/base/publ-ini.lua
@@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['publ-ini'] = {
-- we could store the destinations in the user list entries
local next, rawget, type, tostring, tonumber = next, rawget, type, tostring, tonumber
-local match, gmatch, format, gsub = string.match, string.gmatch, string.format, string.gsub
+local match, gmatch, format, gsub, find = string.match, string.gmatch, string.format, string.gsub, string.find
local concat, sort, tohash = table.concat, table.sort, table.tohash
local utfsub = utf.sub
local formatters = string.formatters
@@ -431,17 +431,43 @@ local function getdetail(dataset,tag,name)
return d and d[name]
end
-function commands.btxsingularorplural(dataset,tag,name) -- todo: make field dependent
+function commands.btxsingularorplural(dataset,tag,name)
local d = datasets[dataset].details[tag]
if d then
d = d[name]
end
- if d then
+ if type(d) == "table" then
d = #d <= 1
+ else
+ d = false
end
commands.doifelse(d)
end
+function commands.oneorrange(dataset,tag,name)
+ local d = datasets[dataset].luadata[tag] -- details ?
+ if d then
+ d = d[name]
+ end
+ if type(d) == "string" then
+ d = find(d,"%-")
+ else
+ d = false
+
+ end
+ commands.doifelse(not d) -- so singular is default
+end
+
+function commands.firstinrange(dataset,tag,name)
+ local d = datasets[dataset].luadata[tag] -- details ?
+ if d then
+ d = d[name]
+ end
+ if type(d) == "string" then
+ context(match(d,"([^%-]+)"))
+ end
+end
+
-- basic loading
function commands.usebtxdataset(name,filename)