ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Can modes be used for content control?
@ 2021-11-16 23:25 Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  2021-11-17  0:23 ` Aditya Mahajan via ntg-context
  2021-11-17  7:59 ` Hans Hagen via ntg-context
  0 siblings, 2 replies; 13+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد via ntg-context @ 2021-11-16 23:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users
  Cc: Idris Samawi Hamid ادريس
	سماوي حامد

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-16 23:25 Can modes be used for content control? Idris Samawi Hamid ادريس سماوي حامد via ntg-context
@ 2021-11-17  0:23 ` Aditya Mahajan via ntg-context
  2021-11-17  3:06   ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  2021-11-17  7:59 ` Hans Hagen via ntg-context
  1 sibling, 1 reply; 13+ messages in thread
From: Aditya Mahajan via ntg-context @ 2021-11-17  0:23 UTC (permalink / raw)
  To: Idris Samawi Hamid ادريس
	سماوي حامد
	via ntg-context
  Cc: Aditya Mahajan

[-- Attachment #1: Type: text/plain, Size: 1532 bytes --]

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

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-17  0:23 ` Aditya Mahajan via ntg-context
@ 2021-11-17  3:06   ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  2021-11-17 11:32     ` Henning Hraban Ramm via ntg-context
  2021-11-17 17:56     ` Aditya Mahajan via ntg-context
  0 siblings, 2 replies; 13+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد via ntg-context @ 2021-11-17  3:06 UTC (permalink / raw)
  To: Idris Samawi Hamid ادريس
	سماوي حامد
	via ntg-context
  Cc: Idris Samawi Hamid ادريس
	سماوي حامد

Hi Aditya,

Many thanks; see below:

On Tue, 16 Nov 2021 17:23:59 -0700, Aditya Mahajan via ntg-context  
<ntg-context@ntg.nl> 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.

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-16 23:25 Can modes be used for content control? Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  2021-11-17  0:23 ` Aditya Mahajan via ntg-context
@ 2021-11-17  7:59 ` Hans Hagen via ntg-context
  1 sibling, 0 replies; 13+ messages in thread
From: Hans Hagen via ntg-context @ 2021-11-17  7:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users
  Cc: Hans Hagen,
	Idris Samawi Hamid ادريس
	سماوي حامد

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-17  3:06   ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
@ 2021-11-17 11:32     ` Henning Hraban Ramm via ntg-context
  2021-11-17 15:08       ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  2021-11-17 17:56     ` Aditya Mahajan via ntg-context
  1 sibling, 1 reply; 13+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2021-11-17 11:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Henning Hraban Ramm


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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-17 11:32     ` Henning Hraban Ramm via ntg-context
@ 2021-11-17 15:08       ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  2021-11-17 15:51         ` Henning Hraban Ramm via ntg-context
  2021-11-17 15:57         ` Taco Hoekwater via ntg-context
  0 siblings, 2 replies; 13+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد via ntg-context @ 2021-11-17 15:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users
  Cc: Idris Samawi Hamid ادريس
	سماوي حامد

Hi Hraban,

Many thanks; see below:

On Wed, 17 Nov 2021 04:32:56 -0700, Henning Hraban Ramm via ntg-context  
<ntg-context@ntg.nl> wrote:

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-17 15:08       ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
@ 2021-11-17 15:51         ` Henning Hraban Ramm via ntg-context
  2021-11-17 19:52           ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  2021-11-17 15:57         ` Taco Hoekwater via ntg-context
  1 sibling, 1 reply; 13+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2021-11-17 15:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Henning Hraban Ramm


> 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

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-17 15:08       ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  2021-11-17 15:51         ` Henning Hraban Ramm via ntg-context
@ 2021-11-17 15:57         ` Taco Hoekwater via ntg-context
  1 sibling, 0 replies; 13+ messages in thread
From: Taco Hoekwater via ntg-context @ 2021-11-17 15:57 UTC (permalink / raw)
  To: mailing list for ConTeXt users
  Cc: Taco Hoekwater,
	Idris Samawi Hamid ادريس
	سماوي حامد

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)



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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-17  3:06   ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  2021-11-17 11:32     ` Henning Hraban Ramm via ntg-context
@ 2021-11-17 17:56     ` Aditya Mahajan via ntg-context
  2021-11-17 18:54       ` Hans Hagen via ntg-context
  2021-11-17 19:36       ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  1 sibling, 2 replies; 13+ messages in thread
From: Aditya Mahajan via ntg-context @ 2021-11-17 17:56 UTC (permalink / raw)
  To: Idris Samawi Hamid ادريس
	سماوي حامد
	via ntg-context
  Cc: Aditya Mahajan

[-- Attachment #1: Type: text/plain, Size: 3154 bytes --]

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
> <ntg-context@ntg.nl> 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

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-17 17:56     ` Aditya Mahajan via ntg-context
@ 2021-11-17 18:54       ` Hans Hagen via ntg-context
  2021-11-17 19:45         ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  2021-11-17 19:36       ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  1 sibling, 1 reply; 13+ messages in thread
From: Hans Hagen via ntg-context @ 2021-11-17 18:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen

On 11/17/2021 6:56 PM, Aditya Mahajan via ntg-context wrote:
> 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
>> <ntg-context@ntg.nl> 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 
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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-17 17:56     ` Aditya Mahajan via ntg-context
  2021-11-17 18:54       ` Hans Hagen via ntg-context
@ 2021-11-17 19:36       ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  1 sibling, 0 replies; 13+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد via ntg-context @ 2021-11-17 19:36 UTC (permalink / raw)
  To: Idris Samawi Hamid ادريس
	سماوي حامد
	via ntg-context
  Cc: Idris Samawi Hamid ادريس
	سماوي حامد

On Wed, 17 Nov 2021 10:56:46 -0700, Aditya Mahajan via ntg-context  
<ntg-context@ntg.nl> wrote:

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-17 18:54       ` Hans Hagen via ntg-context
@ 2021-11-17 19:45         ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  0 siblings, 0 replies; 13+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد via ntg-context @ 2021-11-17 19:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users
  Cc: Idris Samawi Hamid ادريس
	سماوي حامد

On Wed, 17 Nov 2021 11:54:52 -0700, Hans Hagen via ntg-context  
<ntg-context@ntg.nl> wrote:

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Can modes be used for content control?
  2021-11-17 15:51         ` Henning Hraban Ramm via ntg-context
@ 2021-11-17 19:52           ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
  0 siblings, 0 replies; 13+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد via ntg-context @ 2021-11-17 19:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users
  Cc: Idris Samawi Hamid ادريس
	سماوي حامد

On Wed, 17 Nov 2021 08:51:03 -0700, Henning Hraban Ramm via ntg-context  
<ntg-context@ntg.nl> wrote:

>> 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.contextgarden.net%2FModes&amp;data=04%7C01%7CIdris.Hamid%40ColoState.EDU%7C14c5b723751a4eb2bb9308d9a9e42f31%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637727619814441586%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=tljjceauaTpF%2FYlSHYhna05nmXP5ppCsMVHDj0VNBWk%3D&amp;reserved=0

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-11-17 19:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 23:25 Can modes be used for content control? Idris Samawi Hamid ادريس سماوي حامد via ntg-context
2021-11-17  0:23 ` Aditya Mahajan via ntg-context
2021-11-17  3:06   ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
2021-11-17 11:32     ` Henning Hraban Ramm via ntg-context
2021-11-17 15:08       ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
2021-11-17 15:51         ` Henning Hraban Ramm via ntg-context
2021-11-17 19:52           ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
2021-11-17 15:57         ` Taco Hoekwater via ntg-context
2021-11-17 17:56     ` Aditya Mahajan via ntg-context
2021-11-17 18:54       ` Hans Hagen via ntg-context
2021-11-17 19:45         ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
2021-11-17 19:36       ` Idris Samawi Hamid ادريس سماوي حامد via ntg-context
2021-11-17  7:59 ` Hans Hagen via ntg-context

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).