Can modes be used for content control?
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? If so, does anyone have some working example of how to do it? Might even be worth a MyWay if not too unwieldy.. Thank you in advance! Best wishes Idris -- Idris Samawi Hamid, Professor Department of Philosophy Colorado State University Fort Collins, CO 80512
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. Aditya
Hi Aditya,
Many thanks; see below:
On Tue, 16 Nov 2021 17:23:59 -0700, Aditya Mahajan via ntg-context
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. Furthermore, each mode is unique and there is apparently no inheritance/continuance. So using this method appears to be quite unwieldy for book-length projects. What is needed is something like this \startmode[abridged] \input knuth \startmode[unabridged] \startblockquote \input ward \stopblockquote \stopmode \input zapf \stopmode That is not supported, so need to find another method - assuming there even is one. Otherwise will have to consider XML authoring and process the selected tags in ConTeXt.. Best wishes Idris -- Idris Samawi Hamid, Professor Department of Philosophy Colorado State University Fort Collins, CO 80512
Am 17.11.2021 um 04:06 schrieb Idris Samawi Hamid ادريس سماوي حامد via ntg-context <ntg-context@ntg.nl>:
Unfortunately - as pointed out on the wiki - modes cannot be nested.
Why would you need that? You know about \startnotmode and that you can use lists of modes? \startmode[short,long] Something that appears everywhere. \stopmode \startmode[long] % or \startnotmode[short] Something that’s only in the long version. \stopmode There are also language modes (\startmode[*en]) that might be handy with translations.
Furthermore, each mode is unique and there is apparently no inheritance/continuance.
Can you give an example for a use case?
What is needed is something like this
\startmode[abridged] \input knuth
\startmode[unabridged] \startblockquote \input ward \stopblockquote \stopmode
\input zapf \stopmode
That looks to me like flawed logic – why should content for the unabridged version appear within the abridged version? It might be a bit annoying, but you could end the previous mode before starting the next. And, as mentioned above, you can use \startmode with lists. HTH Hraban
Hi Hraban,
Many thanks; see below:
On Wed, 17 Nov 2021 04:32:56 -0700, Henning Hraban Ramm via ntg-context
Am 17.11.2021 um 04:06 schrieb Idris Samawi Hamid ادريس سماوي حامد via ntg-context <ntg-context@ntg.nl>:
You know about \startnotmode and that you can use lists of modes? \startmode[short,long] Something that appears everywhere. \stopmode \startmode[long] % or \startnotmode[short] Something that’s only in the long version. \stopmode
Many thanks; will study this.
Unfortunately - as pointed out on the wiki - modes cannot be nested. : Why would you need that? : Can you give an example for a use case? : That looks to me like flawed logic – why should content for the unabridged version appear within the abridged version?
TeX comments will illustrate: ============== This text goes into the abridged version. % This text will appear in the unabridged version. And this text goes into the abridged version. % And this text goes into the unabridged version. And this additional text goes into the abridged version. % And this additional text goes into the unabridged version. ============== An abridged run will ignore the commented text, and an unabridged run will include it. Consider variant texts: ======= Here is some text that contains % mode=variantone includes % mode=varianttwo is comprised of % mode=variantthree some variants. Here is some more text that features % mode=variantone exhibits % mode=varianttwo illustrates % mode=variantthree some variants. ======= This example is to be processed to produce exactly three distinct results. So, e.g., "contains" and "features" belong to variantone. Etc. So like XML.
It might be a bit annoying, but you could end the previous mode before starting the next.
Assuming that I'm not misunderstanding you: For a book-length project, that would be beyond annoying.
And, as mentioned above, you can use \startmode with lists.
Will try it. Thank you again! Best wishes Idris -- Idris Samawi Hamid, Professor Department of Philosophy Colorado State University Fort Collins, CO 80512
Am 17.11.2021 um 16:08 schrieb Idris Samawi Hamid ادريس سماوي حامد <Idris.Hamid@colostate.edu>:
That looks to me like flawed logic – why should content for the unabridged version appear within the abridged version?
TeX comments will illustrate:
============== This text goes into the abridged version.
% This text will appear in the unabridged version.
And this text goes into the abridged version.
% And this text goes into the unabridged version.
And this additional text goes into the abridged version.
% And this additional text goes into the unabridged version. ==============
An abridged run will ignore the commented text, and an unabridged run will include it.
Ok, it it’s about such small snippets, consider \doifmode{mode1,mode2}{Conditional text}. I don’t think you would get shorter markup with nesting. More possibilities see https://wiki.contextgarden.net/Modes
Consider variant texts:
======= Here is some text that contains % mode=variantone includes % mode=varianttwo is comprised of % mode=variantthree some variants.
Here is some more text that features % mode=variantone exhibits % mode=varianttwo illustrates % mode=variantthree some variants. =======
This example is to be processed to produce exactly three distinct results. So, e.g., "contains" and "features" belong to variantone. Etc. So like XML.
How about: Here is some text that \startmodeset [variantone] {contains} [varianttwo] {includes} [variantthree] {is comprised of} [default] {doesn’t contain} \stopmodeset some variants.
It might be a bit annoying, but you could end the previous mode before starting the next. Assuming that I'm not misunderstanding you: For a book-length project, that would be beyond annoying.
Well, it looks like you’ll need a lot of markup anyway. HTH Hraban
On Wed, 17 Nov 2021 08:51:03 -0700, Henning Hraban Ramm via ntg-context
TeX comments will illustrate:
============== This text goes into the abridged version.
% This text will appear in the unabridged version.
And this text goes into the abridged version.
% And this text goes into the unabridged version.
And this additional text goes into the abridged version.
% And this additional text goes into the unabridged version. ==============
An abridged run will ignore the commented text, and an unabridged run will include it.
Ok, it it’s about such small snippets, consider \doifmode{mode1,mode2}{Conditional text}.
I don’t think you would get shorter markup with nesting.
More possibilities see https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.conte...
Started there before starting this thread, but the focus appears to be global and the one and only working example near the end is pretty trivial -) But armed with the answers received here, will look at it again for ideas.
Consider variant texts:
======= Here is some text that contains % mode=variantone includes % mode=varianttwo is comprised of % mode=variantthree some variants.
Here is some more text that features % mode=variantone exhibits % mode=varianttwo illustrates % mode=variantthree some variants. =======
This example is to be processed to produce exactly three distinct results. So, e.g., "contains" and "features" belong to variantone. Etc. So like XML.
How about:
Here is some text that \startmodeset [variantone] {contains} [varianttwo] {includes} [variantthree] {is comprised of} [default] {doesn’t contain} \stopmodeset some variants.
Very nice, many thanks! Will experiment with this method as well, comparing and contrasting with blocks and Aditya's modes method.
It might be a bit annoying, but you could end the previous mode before starting the next. Assuming that I'm not misunderstanding you: For a book-length project, that would be beyond annoying.
Well, it looks like you’ll need a lot of markup anyway.
Indeed. And that's ok, as long as the structure is simple enough.. Occam's razor! Best wishes -- Idris Samawi Hamid, Professor Department of Philosophy Colorado State University Fort Collins, CO 80512
Hi Idris, I think Hans was trying to point you to the blocks mechanism. Blocks *do* nest: \defineblock[sectionblock] \defineblock[myblock] \startmode[variantone] \keepblocks[sectionblock] \keepblocks[myblock] \stopmode \startmode[varianttwo] \keepblocks[sectionblock] \stopmode \starttext \beginsectionblock \section{A to B} \beginmyblock A is for Amy, who fell down the stairs. \endmyblock \beginmyblock B is for Basil, assaulted by bears. \endmyblock \endsectionblock \stoptext — Taco Hoekwater E: taco@bittext.nl genderfluid (all pronouns)
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. Aditya
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 -----------------------------------------------------------------
On Wed, 17 Nov 2021 11:54:52 -0700, Hans Hagen via ntg-context
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 them or call them up later etc .. so you can code answers with questions and then call them up in an appendix
Many thanks. Will do some comparison-and-contrast tests for research writing with both methods. The pedagogical use of blocks will certainly come in handy at some point. Best wishes -- Idris Samawi Hamid, Professor Department of Philosophy Colorado State University Fort Collins, CO 80512
On Wed, 17 Nov 2021 10:56:46 -0700, Aditya Mahajan via ntg-context
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
Excellent, many thanks! Starting to get the feel of the matter now. Will put together some tests.. Best wishes -- Idris Samawi Hamid, Professor Department of Philosophy Colorado State University Fort Collins, CO 80512
On 11/17/2021 12:25 AM, 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? If so, does anyone have some working example of how to do it? Might even be worth a MyWay if not too unwieldy.. Thank you in advance! see tests files in blocks path of test suite ... one of the oldest mechanisms in context (as we needed it for on source multiple output in educational documents)
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 -----------------------------------------------------------------
participants (5)
-
Aditya Mahajan
-
Hans Hagen
-
Henning Hraban Ramm
-
Idris Samawi Hamid ادريس سماوي ح امد
-
Taco Hoekwater