From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107643 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Fabrice L Newsgroups: gmane.comp.tex.context Subject: Re: start/stop executed conditionally on mode ? Date: Mon, 8 Jun 2020 15:53:51 -0400 Message-ID: References: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Content-Type: multipart/mixed; boundary="===============9007835076017326790==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="96287"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Jun 08 21:54:11 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jiNqU-000Ou9-Pg for gctc-ntg-context-518@m.gmane-mx.org; Mon, 08 Jun 2020 21:54:10 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id D525D1849E3; Mon, 8 Jun 2020 21:53:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gBcF9UGtV_R5; Mon, 8 Jun 2020 21:53:57 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id E40DC1849E5; Mon, 8 Jun 2020 21:53:57 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 97C8F1849C2 for ; Mon, 8 Jun 2020 21:53:56 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2hg0ss8Cse_K for ; Mon, 8 Jun 2020 21:53:55 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.222.169; helo=mail-qk1-f169.google.com; envelope-from=fabrice.alpha@gmail.com; receiver= Original-Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 0B8E11847F0 for ; Mon, 8 Jun 2020 21:53:54 +0200 (CEST) Original-Received: by mail-qk1-f169.google.com with SMTP id c12so18511226qkk.13 for ; Mon, 08 Jun 2020 12:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:subject:date:references:to:in-reply-to:message-id; bh=Z0MTVQnDBQUioVlS4boL0+x1b29ONftX3sFoTJw4iy0=; b=QYVxBr5SH5NBYSA7pQgWKkFTKMHjAwxrT3ylCRu+Db/SVPzsR5vA4TyuKGY8pcw9Pj RaZKwb7ERaPv/SkOHXT3wq4RkZsibB1tn5YbDEZOheSewVS7gYV7+Ryxz1CLJvCwJT2X E0SBNEQtqPwS3V8a1MZ6bGhnwcH/1yWYR5f1zaxNaaav75CApF6e74EN35M7a37j/Fg+ 19JG5/NX6utDUWVTj1gAYh9j/Df4mwJXlO4D2tTW0pz4S1Vlt+iGaXCoFYIuaVqMPfhu AsD/8wRMiKZ7v2+u4viX2UuoIkY2jJalpTrzdZ9gUezw2kPRCMzrX5k+bs99JMwc//SD njDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:date:references:to :in-reply-to:message-id; bh=Z0MTVQnDBQUioVlS4boL0+x1b29ONftX3sFoTJw4iy0=; b=AkUeMb6x4kTZ1PO42okQPFkfWkYNyA0A/Paall8pcZQxz2auAPvaIwT+zBtRqcEkEA qYE1l1BQu1LU3gHvak5+ExvhCdN+7NMsJ/LdoFwVr8bzlMNudIREFcMwpqlQTCPGncJ2 DuN8caM2eQLQJllVYhtxDrtQetpUw/qruXkwAqkSRChrMpEjXEFubDex4eEr1I4zkhH+ rdipubY0eB2h/NZNr5t+uJF4kOJKC1RUu84a6+WsHJ4yeTDx2D5meQnZyaMA1EKEdIpK QeZ3VLCHJdWEeuerLVI7Gg+yxpTn6y5VN+1M572pyr3OeS3kMDuwFL5sUb5drTHLO6gB Zimg== X-Gm-Message-State: AOAM530daqv3Hez2c4ftmd3NPKZt1x1/4/uQ5ioePIKaTBo0+14sqHVr 5m4IdOPfd1e+VB+umcF1S+zZtfJg X-Google-Smtp-Source: ABdhPJwxUb3EIAkm91qta+2Ap9+pr8EQ2a3sSl/W+jPfikE0gl7NbwIferxN2srxWwMCTsJdSON9fg== X-Received: by 2002:a37:488c:: with SMTP id v134mr24372051qka.318.1591646032788; Mon, 08 Jun 2020 12:53:52 -0700 (PDT) Original-Received: from phenotype.lan ([38.74.28.141]) by smtp.gmail.com with ESMTPSA id f7sm7365982qkk.88.2020.06.08.12.53.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jun 2020 12:53:52 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3608.80.23.2.2) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:107643 Archived-At: --===============9007835076017326790== Content-Type: multipart/alternative; boundary="Apple-Mail=_B478F4DA-94FE-47C1-8BDE-78417138105E" --Apple-Mail=_B478F4DA-94FE-47C1-8BDE-78417138105E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 7 juin 2020 =C3=A0 23:19, Aditya Mahajan a = =C3=A9crit : >=20 > On Sun, 7 Jun 2020, Fabrice L wrote: >=20 >> Dear List, >>=20 >> 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=E2=80=99s not ! The code is executed in the mode as = expected, but the following instructions ("Some other text... =C2=BB in = the exemple) is not typeset. >>=20 >> Here is a minimal (not working!) example: >>=20 >> % = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94 >> \unexpanded\def\StartQuestionsList{ >> \startmode[ClassRoom] \page[yes] Here are some questions: = \blank >> } >> \unexpanded\def\StopQuestionsList{ >> \page[yes] \stopmode >> } >> \definestartstop[Questions][ >> before=3D\StartQuestionsList, >> after=3D\StopQuestionsList >> ] >>=20 >>=20 >> \startQuestions >> Question A=E2=80=A6. >> Question B=E2=80=A6. >> \stopQuestions >>=20 >> Some other text... >> % = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94 >>=20 >>=20 >> So to be clear, I would like the result in the =C2=AB ClassRoom =C2=BB = mode to be: >> % = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94 >> Here are some questions: >>=20 >> Question A=E2=80=A6. >> Question B=E2=80=A6. >>=20 >> Some other text... >> % = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94 >>=20 >> Otherwise to be: >> % = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94 >> Some other text... >> % = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94 >=20 > If you only set `ClassRoom` mode at compile time (rather than setting = and unsetting it the middle of the document), then you can do: >=20 > \definebuffer[Questions] >=20 > \startmode[ClassRoom] > \define\StopQuestionsList {...} >=20 > \definestartstop[Questions][...] > \stopmode >=20 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.=20 A buffer =C2=AB Questions =C2=BB is defined. If in =C2=AB ClassRoom =C2=BB= mode, a start/stop =C2=AB Questions =C2=BB is also defined. So when = ConTeXt encounters the \startQuestions / \stopQuestions, if the =C2=AB = ClassRoom =C2=BB mode is enabled, the buffer is processed (with some = format if needed - framed here for the example), and if the mode =C2=AB = ClassRoom =C2=BB is disabled, then nothing is process. You can add as = many \startQuestions / \stopQuestions you wish.=20 % ---------------------------------------------- \definebuffer[Questions] \enablemode[ClassRoom] % Try "On / Off =C2=BB to process = "\startQuestions / \stopQuestions =C2=BB or not. \startmode[ClassRoom] = \definestartstop[Questions][before=3D{\startframedtext\red},after=3D{\stop= framedtext\blue}] \stopmode \starttext Before... \startQuestions The content of the buffer !=20 \stopQuestions After... \stoptext % ---------------------------------------------- Thanks Aditya ! Fabrice. > = Aditya____________________________________________________________________= _______________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ --Apple-Mail=_B478F4DA-94FE-47C1-8BDE-78417138105E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Le 7 juin 2020 =C3=A0 23:19, Aditya Mahajan <adityam@umich.edu> a = =C3=A9crit :

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=E2=80=99s not ! The code is executed in the mode as = expected, but the following instructions ("Some other text... =C2=BB in = the exemple) is not typeset.

Here is a = minimal (not working!) example:

% = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94
\unexpanded\def\StartQuestionsList{
= \startmode[ClassRoom]  \page[yes] Here are some questions: = \blank
}
\unexpanded\def\StopQuestionsList{ = \page[yes] \stopmode
}
\definestartstop[Questions][
= before=3D\StartQuestionsList,
= after=3D\StopQuestionsList
]


\startQuestions
= Question A=E2=80=A6.
Question B=E2=80=A6.
\stopQuestions

Some other = text...
% = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94


So = to be clear, I would like the result in the =C2=AB ClassRoom =C2=BB mode = to be:
% = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94
Here are some questions:

Question A=E2=80=A6.
= Question B=E2=80=A6.

Some other = text...
% = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94

Otherwise to = be:
% = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94
Some other text...
% = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94

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 =C2=AB Questions =C2=BB is defined. If in = =C2=AB ClassRoom =C2=BB mode, a start/stop = =C2=AB Questions =C2=BB is also defined. So when ConTeXt = encounters the \startQuestions / \stopQuestions, if the = =C2=AB ClassRoom =C2=BB mode is enabled, the buffer is = processed (with some format if needed - framed here for the example), = and if the mode =C2=AB ClassRoom =C2=BB is disabled, then = nothing is process. You can add as many \startQuestions / \stopQuestions = you wish. 


% = ----------------------------------------------
\definebuffer[Que= stions]

\enablemode[ClassRoom] % Try = "On / Off =C2=BB to process "\startQuestions / = \stopQuestions =C2=BB or not.

\startmode[ClassRoom]
 \definestartst= op[Questions][before=3D{\startframedtext\red},after=3D{\stopframedtext\blu= e}]
\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 / 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
_______________________________________________________________= ____________________

= --Apple-Mail=_B478F4DA-94FE-47C1-8BDE-78417138105E-- --===============9007835076017326790== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============9007835076017326790==--