That's great, I wikified a Note for testing if a buffer exists or has content (using the \getbuffer[…] approach for the moment). If I was asked, I'd opt for \doifelseemptybuffer (doifemptyelse?) since one could think of similar commands that test for empty "objects". Is there an option for testing blocks? (I actually use blocks quite frequently …) I just realized they are probably handled very differently during the typesetting. Basically I would just need to test if during the first run any of \beginBLOCK … \endBLOCK was invoked (but if one gets a test for some content in-between that's even better). As an alternative solution, is there a way to add content to buffers? Unfortunately, I can't use \getbuffer[first,second], but \startbuffer[first][add=yes] … \stopbuffer would be nice. Thanks! Benjamin
On Aug 2, 2021, at 17:17, ntg-context-request@ntg.nl wrote:
\starttext
\startbuffer[test] test \stopbuffer
\doifelsebuffer{test} {YES} {NOP}
\permanent\protected\def\doifelsebuffercontent#1% {\doifelse{\luaexpr{(string.strip(buffers.getcontent("#1")) ~= "" and "yes")}}{yes}}
\startbuffer[test] \stopbuffer
\doifelsebuffercontent{test} {YES} {NOP}
\startbuffer[test]
\stopbuffer
\doifelsebuffercontent{test} {YES} {NOP}
\stoptext