On 1/2/2022 2:14 PM, Benjamin Buchmuller wrote:
Thanks, Hans, for the answer, but I'm not sure if I get the point.

While this is possible in ConTeXt:

\startsection[title={My Title}]

\beginMyBlock
bla bla
\endMyBlock

\stopsection

The following won't work (end of file error):

\startMyCommand[optional={Maybe}]

\beginMyBlock
bla bla
\endMyBlock

\stopMyCommand

I had hoped for a simple command/modifier like 
\pleaseacceptblocks\def\startMyCommand[#1]#2\stopMyCommand  to have #2 work in 
a similar way.

But maybe, as Wolfgang stated here 
(https://www.mail-archive.com/ntg-context@ntg.nl/msg73956.html), buffers and 
blocks can't be used in commands. (To add: Even when passed as arguments during 
compilation?)

You can bet that WS is right.

You really have to go dirty tex for this kind of magic:

\defineblock[MyBlock]
\keepblocks[MyBlock]

\starttext

\tolerant\def\startMyCommand[#1]%
  {\begingroup
   \setcatcodetable\notcatcodes
   \dostartMyCommand[#1]}

\let\stopMyCommand\relax

\normalexpanded{\def\noexpand\dostartMyCommand[#1]#2\expandtoken\notcatcodes92 stopMyCommand}%
  {\endgroup
   % whatever #1 does
   \setbuffer[foo]#2\endbuffer
   \typebuffer[foo]
   \getbuffer[foo]}

or

\normalexpanded{\def\noexpand\dostartMyCommand[#1]#2\retokenized\notcatcodes {\stopMyCommand}}%
  {\endgroup
   % whatever #1 does
   \setbuffer[foo]#2\endbuffer
   \typebuffer[foo]
   \getbuffer[foo]}

\startMyCommand[optional={Maybe}]

\beginMyBlock
bla bla
\endMyBlock

\stopMyCommand

\stoptext

and then of course further nesting mess ...

Hans

-----------------------------------------------------------------
                                          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
___________________________________________________________________________________

Reply via email to