From 16aa5a7c87f18a2483d0d61795899f886781b51c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 18 Apr 2015 22:52:45 +0000 Subject: context, from www.pragma-ade.com/context/beta/cont-tmf.zip (18apr15) git-svn-id: svn://tug.org/texlive/trunk@36923 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/context/base/strc-mar.lua | 40 +++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'Master/texmf-dist/tex/context/base/strc-mar.lua') 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" } -- cgit v1.2.3