summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/strc-mar.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-mar.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/strc-mar.lua40
1 files changed, 21 insertions, 19 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-mar.lua b/Master/texmf-dist/tex/context/base/strc-mar.lua
index 9c6259de4c4..3af9113bf85 100644
--- a/Master/texmf-dist/tex/context/base/strc-mar.lua
+++ b/Master/texmf-dist/tex/context/base/strc-mar.lua
@@ -10,12 +10,14 @@ if not modules then modules = { } end modules ['strc-mar'] = {
-- todo: only commands.* print to tex, native marks return values
local insert, concat = table.insert, table.concat
-local tostring, next, rawget = tostring, next, rawget
+local tostring, next, rawget, type = tostring, next, rawget, type
local lpegmatch = lpeg.match
local context = context
local commands = commands
+local implement = interfaces.implement
+
local allocate = utilities.storage.allocate
local setmetatableindex = table.setmetatableindex
@@ -29,7 +31,6 @@ local getprev = nuts.getprev
local getid = nuts.getid
local getlist = nuts.getlist
local getattr = nuts.getattr
-local setattr = nuts.setattr
local getbox = nuts.getbox
local traversenodes = nuts.traverse
@@ -217,7 +218,11 @@ local function resolve(t,k)
end
function marks.define(name,settings)
- settings = settings or { }
+ if not settings then
+ settings = { }
+ elseif type(settings) == "string" then
+ settings = { parent = settings }
+ end
data[name] = settings
local parent = settings.parent
if parent == nil or parent == "" or parent == name then
@@ -712,20 +717,17 @@ end
-- interface
-commands.markingtitle = marks.title
-commands.markingnumber = marks.number
-
-commands.definemarking = marks.define
-commands.relatemarking = marks.relate
-commands.setmarking = marks.set
-commands.resetmarking = marks.reset
-commands.synchronizemarking = marks.synchronize
-commands.getmarking = marks.fetch
-commands.fetchonemark = marks.fetchonemark
-commands.fetchtwomarks = marks.fetchtwomarks
-commands.fetchallmarks = marks.fetchallmarks
-
-function commands.doifelsemarking(str) -- can be shortcut
- commands.doifelse(marks.exists(str))
-end
+implement { name = "markingtitle", actions = marks.title, arguments = { "string", "string" } }
+implement { name = "markingnumber", actions = marks.number, arguments = { "string", "string" } }
+
+implement { name = "definemarking", actions = marks.define, arguments = { "string", "string" } }
+implement { name = "relatemarking", actions = marks.relate, arguments = { "string", "string" } }
+implement { name = "setmarking", actions = marks.set, arguments = { "string", "string" } }
+implement { name = "resetmarking", actions = marks.reset, arguments = { "string" } }
+implement { name = "synchronizemarking", actions = marks.synchronize, arguments = { "string", "integer", "string" } }
+implement { name = "getmarking", actions = marks.fetch, arguments = { "string", "string", "string" } }
+implement { name = "fetchonemark", actions = marks.fetchonemark, arguments = { "string", "string", "string" } }
+implement { name = "fetchtwomarks", actions = marks.fetchtwomarks, arguments = { "string", "string" } }
+implement { name = "fetchallmarks", actions = marks.fetchallmarks, arguments = { "string", "string" } }
+implement { name = "doifelsemarking", actions = { marks.exists, commands.doifelse }, arguments = "string" }