On 8/2/2021 8:54 PM, Benjamin Buchmuller via ntg-context wrote:
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.
just for fun I made this:
\starttext
\startbuffer[test]
test
\stopbuffer
\startbuffer[oeps]
oeps
\stopbuffer
\typebuffer[test] \getbuffer[test]
\startbuffer[test = * + test]
prepend
\stopbuffer
\typebuffer[test] \getbuffer[test]
\startbuffer[test = test + *]
append
\stopbuffer
\typebuffer[test] \getbuffer[test]
\startbuffer[test = * +++ test]
before
\stopbuffer
\typebuffer[test] \getbuffer[test]
\startbuffer[test = test +++ *]
after
\stopbuffer
\typebuffer[test] \getbuffer[test]
\startbuffer[test = * + oeps + test + oeps + * ]
DONE
\stopbuffer
\typebuffer[test] \getbuffer[test]
\stoptext
which results in
test
test
prependtest
prependtest
prependtestappend
prependtestappend
before
prependtestappend
before
prependtestappend
before
prependtestappend
after
before
prependtestappend
after
DONEoepsbefore
prependtestappend
afteroepsDONE
DONEoepsbefore
prependtestappend
afteroepsDONE
so basically one can combine buffers any way
+ : nothing in between
++ : space in between
+++ : empty line in between
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________