On 2013-10-08, at 7:22 AM, Procházka Lukáš Ing. - Pontex s. r. o.
Hello,
I'm trying to hook commands.stoptext()...
Here's a minimal example: why only the first image appears?
---- \startluacode local cmd_p local tab = {}
f = function(a) if not cmd_p then cmd_p = commands.stoptext
commands.stoptext = function(...) context("Hook")
for _, v in ipairs(tab) do context.startTEXpage() context.externalfigure{v} context.stopTEXpage() end
cmd_p(...) end end
table.insert(tab, a) end \stopluacode
\starttext A \ctxlua{f("cow")} \ctxlua{f("hacker")} \stoptext ----
When I modify the code:
---- ... for _, v in ipairs(tab) do --context.startTEXpage() context.externalfigure{v} --context.stopTEXpage() end ... ----
all figures are shown OK.
Where's the problem?
An alternative is to use (untested) \appendtoks ... \to \everystoptext Aditya