Hello again, Hans! On Thu, 26 Nov 2020 at 09:18, Hans Hagen wrote: > (this mechanism is already kind of old, there are also other cheats > possible) > Diving into functions and using context.stepwise() worked, until I've got to: /cldf-stp.lua:48: bad argument #1 to 'resume' (thread expected) and other errors. It was triar/error approach, not exactly knowing how context.stepwise() works, and I was some more lua functions and iterations before needing expansion. Therefore I've changed the strategy (cannot give up): - Create named buffers with formatted content (and store measures) before they are needed. - When needed, use the reference to the buffer. Tests looked promising. After \starttext buffers and measures are known (both TeX & Lua). Also tested in functions, etc. But inside the first \xmlsetup, they are not expanded anymore, they are typeset (like \typebuffer). - How to have them expanded in \xmlsetup? - Is other mechanism better suited for storing typeset blocks than buffers (and will survive \xmlsetup)? - If none of them is possible, what are the *other **cheats *then? Thanks, Jano MWE attached % BUFFERS \startluacode -- fill buffers for i=1,1000 do local content = "framed-" .. i context.startbuffer( { i } ) context.StartBox() context.bold(i)context.par() context.color( { "red" }, content ) context.StopBox() context.copy(false,0) context.stopbuffer() print(">>", i) end \stopluacode \def\StartBox{\setbox0=\hbox\bgroup\framed[width=50mm, background=color, backgroundcolor=gray, frame=off,align={flushleft}]% \bgroup% \vbox\bgroup} \def\StopBox{\egroup\egroup\egroup}% close vbox, framed, hbox \def\MeasureBuffer[#1]{\setbox0\hbox{\getbuffer[#1]}% ht: \the\ht0\par} % XML \startbuffer[doc]
section
section
\stopbuffer \startxmlsetups xml:name \xmlsetsetup{\xmldocument}{*}{-} \xmlsetsetup{\xmldocument}{document}{xml:name:*} \stopxmlsetups \xmlregistersetup{xml:name} \startxmlsetups xml:name:document \Title{inside xml:name:document} \Title{TeX} \MeasureBuffer[333] \getbuffer[333] \Title{Lua} \startluacode context.MeasureBuffer({"444"}) context.getbuffer({"444"}) \stopluacode \stopxmlsetups \def\Title#1{\blank{\bf #1}\par} \starttext \Title{TeX} \MeasureBuffer[111] \getbuffer[111] \Title{Lua} \startluacode context.MeasureBuffer({"222"}) context.getbuffer({"222"}) \stopluacode \xmlprocessbuffer{xml:name}{doc}{} \stoptext