diff options
author | Hans Hagen <pragma@wxs.nl> | 2014-06-11 15:52:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2014-06-11 15:52:00 +0200 |
commit | 04d53999d96e5526ac6f587ae30215b29213c753 (patch) | |
tree | 6f93a7f05fbbdbbaa596b1efd0ecfbb74fe8d0c6 /tex/context/base/publ-ini.lua | |
parent | b7bf9474dd20221297fb47bf90c1ab6c6a2d9306 (diff) | |
download | context-04d53999d96e5526ac6f587ae30215b29213c753.tar.gz |
beta 2014.06.11 15:52
Diffstat (limited to 'tex/context/base/publ-ini.lua')
-rw-r--r-- | tex/context/base/publ-ini.lua | 32 |
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) |