diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkxl/node-par.lmt')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkxl/node-par.lmt | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkxl/node-par.lmt b/Master/texmf-dist/tex/context/base/mkxl/node-par.lmt new file mode 100644 index 00000000000..125c1b687c1 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/mkxl/node-par.lmt @@ -0,0 +1,101 @@ +if not modules then modules = { } end modules ['node-par'] = { + version = 1.001, + comment = "companion to node-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local starttiming = statistics.starttiming +local stoptiming = statistics.stoptiming + +local sequencers = utilities.sequencers + +-- This is called a lot! I'm a bit reluctant with this one because it is +-- sensitive for order. In many other callbacks ther eis no action at the +-- tex end but here ... Anyway, it has been around for a while now (2019) +-- and so far I had no need for extensive usage so we're okay. + +do + + local actions = nodes.tasks.actions("everypar") + + local function everypar(head) + starttiming(builders) + head = actions(head) + stoptiming(builders) + return head + end + + callbacks.register("insert_par",everypar,"after paragraph start") + +end + +-- Originally this one was meant to deal with the indentation (like turn a box into +-- a skip or prevent it) but that never really was used. The return value still +-- detemines if an indentation box or skip is injected. Will I change that? + +do + + local actions = sequencers.new { + name = "paragraph", + arguments = "mode,indented,context", + returnvalues = "indented", + results = "indented", + } + + sequencers.appendgroup(actions,"before") -- user + sequencers.appendgroup(actions,"system") -- private + sequencers.appendgroup(actions,"after" ) -- user + + local function paragraph(mode,indented,context) -- context used to be the cmd code + local runner = actions.runner + if runner then + starttiming(builders) + indented = runner(mode,indented,context) + stoptiming(builders) + end + return indented + end + + callbacks.register("begin_paragraph",paragraph,"before paragraph start") + +end + +-- This one is a playground for some old metafun gimmicks that I want to improve +-- while I'm updating the manual to lmtx. but it might also be useful for other +-- purposes. It fits in the category obscure and probably takes while to stabelize +-- (if it stays at all). Again, this is one that has the danger of interference, +-- so when it finally got an action handler it only got a system one. + +do + + local actions = sequencers.new { + name = "paragraphcontext", + arguments = "context", + returnvalues = "ignore", + results = "ignore", + } + + ----------.appendgroup(actions,"before") -- user + sequencers.appendgroup(actions,"system") -- private + ----------.appendgroup(actions,"after" ) -- user + + local function parcontext(parcontext) + local runner = actions.runner + if runner then + starttiming(builders) + local ignore = runner(parcontext) + stoptiming(builders) + return ignore + end + end + + callbacks.register("paragraph_context",parcontext,"when the context is dealt with") + +end + +-- This means that we now have most callbacks in use, even the ones that I'm not sure +-- about. It also means that with the above enabled we might have performance now at +-- its worst. I can optimize this a little but it's not worth the effort (and added +-- complication). |