* start/stop executed conditionally on mode ? @ 2020-06-08 3:08 Fabrice L 2020-06-08 3:19 ` Aditya Mahajan 0 siblings, 1 reply; 10+ messages in thread From: Fabrice L @ 2020-06-08 3:08 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 1698 bytes --] Dear List, I would like to insert a page using (ideally) start/stop instructions. The problem is that this page should be inserted only in a certain mode. Consulting the mailing list, I thought the following code was working, but it’s not ! The code is executed in the mode as expected, but the following instructions ("Some other text... » in the exemple) is not typeset. Here is a minimal (not working!) example: % ———————————————————————————————————— \unexpanded\def\StartQuestionsList{ \startmode[ClassRoom] \page[yes] Here are some questions: \blank } \unexpanded\def\StopQuestionsList{ \page[yes] \stopmode } \definestartstop[Questions][ before=\StartQuestionsList, after=\StopQuestionsList ] \startQuestions Question A…. Question B…. \stopQuestions Some other text... % ———————————————————————————————————— So to be clear, I would like the result in the « ClassRoom » mode to be: % ———————————————————————————————————— Here are some questions: Question A…. Question B…. Some other text... % ———————————————————————————————————— Otherwise to be: % ———————————————————————————————————— Some other text... % ———————————————————————————————————— Thanks for any help ! Fabrice. [-- Attachment #1.2: Type: text/html, Size: 4404 bytes --] [-- 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] 10+ messages in thread
* Re: start/stop executed conditionally on mode ? 2020-06-08 3:08 start/stop executed conditionally on mode ? Fabrice L @ 2020-06-08 3:19 ` Aditya Mahajan 2020-06-08 14:54 ` Fabrice L 2020-06-08 19:53 ` Fabrice L 0 siblings, 2 replies; 10+ messages in thread From: Aditya Mahajan @ 2020-06-08 3:19 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1: Type: text/plain, Size: 2049 bytes --] On Sun, 7 Jun 2020, Fabrice L wrote: > Dear List, > > I would like to insert a page using (ideally) start/stop instructions. The problem is that this page should be inserted only in a certain mode. Consulting the mailing list, I thought the following code was working, but it’s not ! The code is executed in the mode as expected, but the following instructions ("Some other text... » in the exemple) is not typeset. > > Here is a minimal (not working!) example: > > % ———————————————————————————————————— > \unexpanded\def\StartQuestionsList{ > \startmode[ClassRoom] \page[yes] Here are some questions: \blank > } > \unexpanded\def\StopQuestionsList{ > \page[yes] \stopmode > } > \definestartstop[Questions][ > before=\StartQuestionsList, > after=\StopQuestionsList > ] > > > \startQuestions > Question A…. > Question B…. > \stopQuestions > > Some other text... > % ———————————————————————————————————— > > > So to be clear, I would like the result in the « ClassRoom » mode to be: > % ———————————————————————————————————— > Here are some questions: > > Question A…. > Question B…. > > Some other text... > % ———————————————————————————————————— > > Otherwise to be: > % ———————————————————————————————————— > Some other text... > % ———————————————————————————————————— If you only set `ClassRoom` mode at compile time (rather than setting and unsetting it the middle of the document), then you can do: \definebuffer[Questions] \startmode[ClassRoom] \define\StopQuestionsList {...} \definestartstop[Questions][...] \stopmode 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] 10+ messages in thread
* Re: start/stop executed conditionally on mode ? 2020-06-08 3:19 ` Aditya Mahajan @ 2020-06-08 14:54 ` Fabrice L 2020-06-08 19:53 ` Fabrice L 1 sibling, 0 replies; 10+ messages in thread From: Fabrice L @ 2020-06-08 14:54 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 2274 bytes --] Dear Aditya, > Le 7 juin 2020 à 23:19, Aditya Mahajan <adityam@umich.edu> a écrit : > > On Sun, 7 Jun 2020, Fabrice L wrote: > >> Dear List, >> >> I would like to insert a page using (ideally) start/stop instructions. The problem is that this page should be inserted only in a certain mode. Consulting the mailing list, I thought the following code was working, but it’s not ! The code is executed in the mode as expected, but the following instructions ("Some other text... » in the exemple) is not typeset. >> >> Here is a minimal (not working!) example: >> >> % ———————————————————————————————————— >> \unexpanded\def\StartQuestionsList{ >> \startmode[ClassRoom] \page[yes] Here are some questions: \blank >> } >> \unexpanded\def\StopQuestionsList{ >> \page[yes] \stopmode >> } >> \definestartstop[Questions][ >> before=\StartQuestionsList, >> after=\StopQuestionsList >> ] >> >> >> \startQuestions >> Question A…. >> Question B…. >> \stopQuestions >> >> Some other text... >> % ———————————————————————————————————— >> >> >> So to be clear, I would like the result in the « ClassRoom » mode to be: >> % ———————————————————————————————————— >> Here are some questions: >> >> Question A…. >> Question B…. >> >> Some other text... >> % ———————————————————————————————————— >> >> Otherwise to be: >> % ———————————————————————————————————— >> Some other text... >> % ———————————————————————————————————— > > If you only set `ClassRoom` mode at compile time (rather than setting and unsetting it the middle of the document), then you can do: > > \definebuffer[Questions] > > \startmode[ClassRoom] > \define\StopQuestionsList {...} > > \definestartstop[Questions][...] > \stopmode > Thanks for your answer, I will try that. Fabrice, [-- Attachment #1.2: Type: text/html, Size: 11086 bytes --] [-- 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] 10+ messages in thread
* Re: start/stop executed conditionally on mode ? 2020-06-08 3:19 ` Aditya Mahajan 2020-06-08 14:54 ` Fabrice L @ 2020-06-08 19:53 ` Fabrice L 2020-06-08 20:22 ` Wolfgang Schuster 2020-06-09 7:37 ` Hans Hagen 1 sibling, 2 replies; 10+ messages in thread From: Fabrice L @ 2020-06-08 19:53 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 4067 bytes --] > Le 7 juin 2020 à 23:19, Aditya Mahajan <adityam@umich.edu> a écrit : > > On Sun, 7 Jun 2020, Fabrice L wrote: > >> Dear List, >> >> I would like to insert a page using (ideally) start/stop instructions. The problem is that this page should be inserted only in a certain mode. Consulting the mailing list, I thought the following code was working, but it’s not ! The code is executed in the mode as expected, but the following instructions ("Some other text... » in the exemple) is not typeset. >> >> Here is a minimal (not working!) example: >> >> % ———————————————————————————————————— >> \unexpanded\def\StartQuestionsList{ >> \startmode[ClassRoom] \page[yes] Here are some questions: \blank >> } >> \unexpanded\def\StopQuestionsList{ >> \page[yes] \stopmode >> } >> \definestartstop[Questions][ >> before=\StartQuestionsList, >> after=\StopQuestionsList >> ] >> >> >> \startQuestions >> Question A…. >> Question B…. >> \stopQuestions >> >> Some other text... >> % ———————————————————————————————————— >> >> >> So to be clear, I would like the result in the « ClassRoom » mode to be: >> % ———————————————————————————————————— >> Here are some questions: >> >> Question A…. >> Question B…. >> >> Some other text... >> % ———————————————————————————————————— >> >> Otherwise to be: >> % ———————————————————————————————————— >> Some other text... >> % ———————————————————————————————————— > > If you only set `ClassRoom` mode at compile time (rather than setting and unsetting it the middle of the document), then you can do: > > \definebuffer[Questions] > > \startmode[ClassRoom] > \define\StopQuestionsList {...} > > \definestartstop[Questions][...] > \stopmode > Thanks to Aditya, I have succeeded, but it was not trivial for me. So, in case somebody someday would need a detailed solution, here is a minimal example, and an explanation. A buffer « Questions » is defined. If in « ClassRoom » mode, a start/stop « Questions » is also defined. So when ConTeXt encounters the \startQuestions / \stopQuestions, if the « ClassRoom » mode is enabled, the buffer is processed (with some format if needed - framed here for the example), and if the mode « ClassRoom » is disabled, then nothing is process. You can add as many \startQuestions / \stopQuestions you wish. % ---------------------------------------------- \definebuffer[Questions] \enablemode[ClassRoom] % Try "On / Off » to process "\startQuestions / \stopQuestions » or not. \startmode[ClassRoom] \definestartstop[Questions][before={\startframedtext\red},after={\stopframedtext\blue}] \stopmode \starttext Before... \startQuestions The content of the buffer ! \stopQuestions After... \stoptext % ---------------------------------------------- Thanks Aditya ! Fabrice. > Aditya___________________________________________________________________________________ > If your question is of interest to others as well, please add an entry to the Wiki! > > maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> / http://www.ntg.nl/mailman/listinfo/ntg-context <http://www.ntg.nl/mailman/listinfo/ntg-context> > webpage : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / http://context.aanhet.net <http://context.aanhet.net/> > archive : https://bitbucket.org/phg/context-mirror/commits/ <https://bitbucket.org/phg/context-mirror/commits/> > wiki : http://contextgarden.net <http://contextgarden.net/> > ___________________________________________________________________________________ [-- Attachment #1.2: Type: text/html, Size: 21797 bytes --] [-- 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] 10+ messages in thread
* Re: start/stop executed conditionally on mode ? 2020-06-08 19:53 ` Fabrice L @ 2020-06-08 20:22 ` Wolfgang Schuster 2020-06-09 7:37 ` Hans Hagen 1 sibling, 0 replies; 10+ messages in thread From: Wolfgang Schuster @ 2020-06-08 20:22 UTC (permalink / raw) To: mailing list for ConTeXt users, Fabrice L Fabrice L schrieb am 08.06.2020 um 21:53: > Thanks to Aditya, I have succeeded, but it was not trivial for me. So, > in case somebody someday would need a detailed solution, here is a > minimal example, and an explanation. > > A buffer « Questions » is defined. If in « ClassRoom » mode, a > start/stop « Questions » is also defined. So when ConTeXt encounters the > \startQuestions / \stopQuestions, if the « ClassRoom » mode is enabled, > the buffer is processed (with some format if needed - framed here for > the example), and if the mode « ClassRoom » is disabled, then nothing is > process. You can add as many \startQuestions / \stopQuestions you wish. Let me give a better explanation. The line \definebuffer [Questions] serves two purposes: 1. It create a Questions environment (\startQuestions ... \stopQuestions) 2. I gobbles the content of the environment. When you enable the ClassRoom mode ConTeXt encounters this line \definestartstop [Questions] which redefines the Questions environment which uses now the startstop-mechanism but the previously created environment buffer based environment no longer exists. The reason for this redefinition is to keep the content of the environment in the document although you could have used other methods to achieve the same as \definestartstop. Wolfgang ___________________________________________________________________________________ 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] 10+ messages in thread
* Re: start/stop executed conditionally on mode ? 2020-06-08 19:53 ` Fabrice L 2020-06-08 20:22 ` Wolfgang Schuster @ 2020-06-09 7:37 ` Hans Hagen 2020-06-09 16:35 ` Fabrice L 2020-06-10 6:42 ` Jan Willem Flamma 1 sibling, 2 replies; 10+ messages in thread From: Hans Hagen @ 2020-06-09 7:37 UTC (permalink / raw) To: mailing list for ConTeXt users, Fabrice L On 6/8/2020 9:53 PM, Fabrice L wrote: > > >> Le 7 juin 2020 à 23:19, Aditya Mahajan <adityam@umich.edu >> <mailto:adityam@umich.edu>> a écrit : >> >> On Sun, 7 Jun 2020, Fabrice L wrote: >> >>> Dear List, >>> >>> I would like to insert a page using (ideally) start/stop >>> instructions. The problem is that this page should be inserted only >>> in a certain mode. Consulting the mailing list, I thought the >>> following code was working, but it’s not ! The code is executed in >>> the mode as expected, but the following instructions ("Some other >>> text... » in the exemple) is not typeset. >>> >>> Here is a minimal (not working!) example: >>> >>> % ———————————————————————————————————— >>> \unexpanded\def\StartQuestionsList{ >>> \startmode[ClassRoom] \page[yes] Here are some questions: \blank >>> } >>> \unexpanded\def\StopQuestionsList{ >>> \page[yes] \stopmode >>> } >>> \definestartstop[Questions][ >>> before=\StartQuestionsList, >>> after=\StopQuestionsList >>> ] >>> >>> >>> \startQuestions >>> Question A…. >>> Question B…. >>> \stopQuestions >>> >>> Some other text... >>> % ———————————————————————————————————— One of the oldest mechanism available ... blocks: \enablemode[classroom] % comment this \defineblock[Question] \doifmode {classroom} { \keepblocks[Question] } \starttext Text A \beginQuestion Question A…. \endQuestion Text B \beginQuestion Question B…. \endQuestion \page \doifnotmode {classroom} { \useblocks[Question] } \stoptext ----------------------------------------------------------------- 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] 10+ messages in thread
* Re: start/stop executed conditionally on mode ? 2020-06-09 7:37 ` Hans Hagen @ 2020-06-09 16:35 ` Fabrice L 2020-06-10 6:42 ` Jan Willem Flamma 1 sibling, 0 replies; 10+ messages in thread From: Fabrice L @ 2020-06-09 16:35 UTC (permalink / raw) To: mailing list for ConTeXt users > Le 9 juin 2020 à 03:37, Hans Hagen <j.hagen@xs4all.nl> a écrit : > > On 6/8/2020 9:53 PM, Fabrice L wrote: >>> Le 7 juin 2020 à 23:19, Aditya Mahajan <adityam@umich.edu <mailto:adityam@umich.edu>> a écrit : >>> >>> On Sun, 7 Jun 2020, Fabrice L wrote: >>> >>>> Dear List, >>>> >>>> I would like to insert a page using (ideally) start/stop instructions. The problem is that this page should be inserted only in a certain mode. Consulting the mailing list, I thought the following code was working, but it’s not ! The code is executed in the mode as expected, but the following instructions ("Some other text... » in the exemple) is not typeset. >>>> >>>> Here is a minimal (not working!) example: >>>> >>>> % ———————————————————————————————————— >>>> \unexpanded\def\StartQuestionsList{ >>>> \startmode[ClassRoom] \page[yes] Here are some questions: \blank >>>> } >>>> \unexpanded\def\StopQuestionsList{ >>>> \page[yes] \stopmode >>>> } >>>> \definestartstop[Questions][ >>>> before=\StartQuestionsList, >>>> after=\StopQuestionsList >>>> ] >>>> >>>> >>>> \startQuestions >>>> Question A…. >>>> Question B…. >>>> \stopQuestions >>>> >>>> Some other text... >>>> % ———————————————————————————————————— > One of the oldest mechanism available ... blocks: > > \enablemode[classroom] % comment this > > \defineblock[Question] > > \doifmode {classroom} { > \keepblocks[Question] > } > > \starttext > > Text A > > \beginQuestion > Question A…. > \endQuestion > > Text B > > \beginQuestion > Question B…. > \endQuestion > > \page > > \doifnotmode {classroom} { > \useblocks[Question] > } > > \stoptext You are right of course... In fact I already use blocks, for another purpose, but I did not think about this solution because I needed a lot of formatting (these blocks should occupy whole page, different background color…), but blocks can adapt to my current need (I have try this morning) using the \setupblock[][before=..,after=…] command. And there is a bonus; I can « collect » these blocks and put them all together at the end of my courses notes, this is perfect. ___________________________________________________________________________________ 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] 10+ messages in thread
* Re: start/stop executed conditionally on mode ? 2020-06-09 7:37 ` Hans Hagen 2020-06-09 16:35 ` Fabrice L @ 2020-06-10 6:42 ` Jan Willem Flamma 2020-06-10 7:33 ` Hans Hagen 1 sibling, 1 reply; 10+ messages in thread From: Jan Willem Flamma @ 2020-06-10 6:42 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1: Type: text/html, Size: 8339 bytes --] [-- 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] 10+ messages in thread
* Re: start/stop executed conditionally on mode ? 2020-06-10 6:42 ` Jan Willem Flamma @ 2020-06-10 7:33 ` Hans Hagen 2020-06-15 17:41 ` Henning Hraban Ramm 0 siblings, 1 reply; 10+ messages in thread From: Hans Hagen @ 2020-06-10 7:33 UTC (permalink / raw) To: mailing list for ConTeXt users, Jan Willem Flamma On 6/10/2020 8:42 AM, Jan Willem Flamma wrote: > Dear list, > > I have seen the use of blocks mechanism with and without a start/stop > combination. > > It is not clear to me in which cases it is required to also include a > start/stop combination in this mechanism. > > \beginquestion > > \startquestion > > Question A > > \stopquestion > > \endquestion > > \beginanswer > > \startanswer > > Answer A > > \stopanswer > > \endanswer the begin/end are used for marking blobs of content (kind of buffers) that can be mixed in, reused, moved, while start/stop is for structure so, begin/end is independent it is an already old mechanism that was made for educational material where one source had to result in teacher, student, examns, extra, materials but it's there to stay ... 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] 10+ messages in thread
* Re: start/stop executed conditionally on mode ? 2020-06-10 7:33 ` Hans Hagen @ 2020-06-15 17:41 ` Henning Hraban Ramm 0 siblings, 0 replies; 10+ messages in thread From: Henning Hraban Ramm @ 2020-06-15 17:41 UTC (permalink / raw) To: mailing list for ConTeXt users > Am 10.06.2020 um 09:33 schrieb Hans Hagen <j.hagen@xs4all.nl>: > > the begin/end are used for marking blobs of content (kind of buffers) that can be mixed in, reused, moved, while start/stop is for structure > > so, begin/end is independent > > it is an already old mechanism that was made for educational material where one source had to result in teacher, student, examns, extra, materials > > but it's there to stay ... Wow, I think this is the first time I encounter blocks in my 20 years of using ConTeXt. Probably I just didn’t recognize they were special. Astonished: 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] 10+ messages in thread
end of thread, other threads:[~2020-06-15 17:41 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-06-08 3:08 start/stop executed conditionally on mode ? Fabrice L 2020-06-08 3:19 ` Aditya Mahajan 2020-06-08 14:54 ` Fabrice L 2020-06-08 19:53 ` Fabrice L 2020-06-08 20:22 ` Wolfgang Schuster 2020-06-09 7:37 ` Hans Hagen 2020-06-09 16:35 ` Fabrice L 2020-06-10 6:42 ` Jan Willem Flamma 2020-06-10 7:33 ` Hans Hagen 2020-06-15 17:41 ` Henning Hraban Ramm
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).