From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Hans Hagen <j.hagen@xs4all.nl>,
Benjamin Buchmuller <benjamin.buchmuller@gmail.com>
Subject: Re: How to check if buffer or block has content
Date: Tue, 3 Aug 2021 17:02:11 +0200 [thread overview]
Message-ID: <1d327de0-4d8c-4db9-13db-438784ffbd5f@xs4all.nl> (raw)
In-Reply-To: <EB5A0710-CC5A-4B2C-9A69-9B995A1D6C02@gmail.com>
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
___________________________________________________________________________________
next prev parent reply other threads:[~2021-08-03 15:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1176.1627917453.1143.ntg-context@ntg.nl>
2021-08-02 18:54 ` Benjamin Buchmuller via ntg-context
2021-08-03 12:26 ` Hans Hagen via ntg-context
2021-08-03 15:02 ` Hans Hagen via ntg-context [this message]
2021-08-03 17:51 ` Benjamin Buchmuller via ntg-context
2021-08-02 14:19 Benjamin Buchmuller via ntg-context
2021-08-02 14:43 ` Aditya Mahajan via ntg-context
2021-08-02 15:17 ` Hans Hagen via ntg-context
2021-08-02 16:21 ` Hans van der Meer via ntg-context
2021-08-02 16:28 ` Wolfgang Schuster via ntg-context
2021-08-02 16:31 ` Wolfgang Schuster via ntg-context
2021-08-03 7:35 ` Hans Hagen via ntg-context
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1d327de0-4d8c-4db9-13db-438784ffbd5f@xs4all.nl \
--to=ntg-context@ntg.nl \
--cc=benjamin.buchmuller@gmail.com \
--cc=j.hagen@xs4all.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).