On Tue, 16 Nov 2021, Idris Samawi Hamid ادريس سماوي حامد wrote:
Hi Aditya,
Many thanks; see below:
On Tue, 16 Nov 2021 17:23:59 -0700, Aditya Mahajan via ntg-context
wrote: On Tue, 16 Nov 2021, Idris Samawi Hamid ادريس سماوي حامد via ntg-context wrote:
Dear gang,
For creating/authoring content in ConTeXt: Can modes or the like be used for content control? For example, someone wants to write at least two versions of a book managed from a single file. So, e.g., we may have
a) abridged content b) unabridged content - includes a) c) abridged content + translation d) unabridged content + translation [:]
One can author and organize this in XML - pre-ConteXt - but perhaps one prefers to write in ConTeXt (take advantage of shortcuts etc.). So maybe
\defineparagraphs[unabridged] \defineparagraphs[abridged] \defineparagraphs[translation]
Then one authors the complete work in a single project, but you can produce a variety of versions, depending on the mode chosen:
\definemode[unabridged] etc.
Can one do this in context?
Yes!
This is what I do (for solutions in homework assignments):
\definebuffer[solution][local=yes,nested=yes]
\startmode[solution] \defineenumeration[solution][....fancy setup...] \stopmode
Then, in the main tex file:
.... \startsolution ... \stopsolution ....
By default, gives the version without solution. Compile with --mode=solution to get the version with solution. The same thing should work in your case by defining two modes: unabridged and translation. And then use --mode=unabridged,translate etc to get multiple modes.
Here's a working sample:
======= % \definebuffer[unabridged] % \definebuffer[abridged]
\setupwhitespace[big]
\starttext \startmode[unabridged] \input knuth
\startblockquote \input ward \stopblockquote
% \startmode[abridged] % \input knuth % \stopmode \stopmode
\startmode[abridged] \input knuth \stopmode
% \startmode[abridged] % \input zapf % \stopmode \stoptext =======
Unfortunately - as pointed out on the wiki - modes cannot be nested.
But you don't have to directly use the modes. The following will work:
\definestartstop[abridged]
% By default, don't show the unabridged text \definebuffer[unabridged][local=yes, nested=yes]
\startmode[unabridged] % In the unabridged mode, show the abridged text \definestartstop[unabridged] \stopmode
\starttext \startabridged \input knuth
\startunabridged \startblockquote \input ward \stopblockquote \stopunabridged
\input zapf \stopabridged
Blocks are a better mechanism, but I still prefer modes here because I find the \beginblock ... \endblock syntax to be a bit awkward in a context document. it also depends on usage ... you can have blocks and delay them or reuse
On 11/17/2021 6:56 PM, Aditya Mahajan via ntg-context wrote: them or call them up later etc .. so you can code answers with questions and then call them up in an appendix ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------