From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/113039 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joey McCollum via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Unusual error with \doifinstring in \startbtxrenderingdefinitions ... \stopbtxrenderingdefinitions Date: Sun, 10 Oct 2021 09:40:53 -0400 Message-ID: References: <2342fc45-5ac0-9504-d94f-5a0ee3a3f50f@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7059865848791385888==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8598"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Joey McCollum , mailing list for ConTeXt users To: Wolfgang Schuster Original-X-From: ntg-context-bounces@ntg.nl Sun Oct 10 15:43:55 2021 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 1mZZ7L-00024T-6O for gctc-ntg-context-518@m.gmane-mx.org; Sun, 10 Oct 2021 15:43:55 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B3BA82889A1; Sun, 10 Oct 2021 15:43:24 +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 ACvrzW4yZVh4; Sun, 10 Oct 2021 15:43:23 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7EC3F2889D0; Sun, 10 Oct 2021 15:43:23 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 97E8E2889CD for ; Sun, 10 Oct 2021 15:43:21 +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 6LKgSKq3TBbr for ; Sun, 10 Oct 2021 15:43:20 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.166.177; helo=mail-il1-f177.google.com; envelope-from=jmccollum20140511@gmail.com; receiver= Original-Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (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 5B0382889A1 for ; Sun, 10 Oct 2021 15:43:20 +0200 (CEST) Original-Received: by mail-il1-f177.google.com with SMTP id y17so15319556ilb.9 for ; Sun, 10 Oct 2021 06:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qVR4Q8k+iN115K9L98SLUE8dHMTqWW+9mPbC7NwGZX8=; b=hkStm5kFCWIvwmv6QaUbr2aiaYlA6+OXJXOGDVfOU6i1m4UjxJQJNFWhu+rXO/vXxL mZqx/pynthR56KO7WPLAHhDT6MQ54McIG2+3EJJae97iCxLSx4j8BdxK2+ARI2cBwkd/ LfrIp6VfuoUHmhKYgjMgK5rOCAVaUpemCovsvr9b86V58u7lYks5mqf1+zuXQIFaP3lK 1pG7j0wm+oc5epVaKUauWllp7ZcPvQGjqRHzAtfLRwJyjvH/+cjKNXOo+ILT+CYQUf1j 3U3FgOkqQRAIvj0VmHXUM66iRVO6RQXLsWNjKh0p9i8rztjZzHmGYUHrgVbLqtcwnvak i4EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qVR4Q8k+iN115K9L98SLUE8dHMTqWW+9mPbC7NwGZX8=; b=Iso2+EQXOKKLKcjgzzpx65KC5MAX+UDkDZARphlUcWoMGc86n1cElW5HB0fKGJVGQ9 TomwQeAPlEKF33ADpcBh6Zk/bYEtIih7CcueyXC7Yb18BQcZwdN0PA1uuBqNojLyJ1D2 P1uUMXDYznMDwBepM1CufRr7cYdTMxRRPrYfuAIKO2LTgMkg6B434ms/hhnFLz5vnPjG GyAItXYKpD1tek1SqjEIU+JiN7V9o0eqL6qnb78udKrJXEBQAK1uiVUIM04lr9YAkRJl umfE0mBY7t3DDrUY6imG8SPSZpCmmDAYqVOz58hnQJ0QaLF5WDa4YrYq3PXjeNYIS7Pl rnPA== X-Gm-Message-State: AOAM532MTv2raegGJHDLB83x3kWad0SfmdfaI9zAr238iE0p55kIxCaF bfunvgYzR/GKA+gFX2yXfsQhVeAXagwPiij0fFk= X-Google-Smtp-Source: ABdhPJxYtRCGdvgu4B6MRAE+C8LVio0o5WJPbDF6qmR05afovIv4yzgOQ2kS/Yyll//Totk+LOrQm+pSv/tZmK6QW+s= X-Received: by 2002:a05:6e02:14d3:: with SMTP id o19mr15186792ilk.257.1633873398643; Sun, 10 Oct 2021 06:43:18 -0700 (PDT) In-Reply-To: <2342fc45-5ac0-9504-d94f-5a0ee3a3f50f@gmail.com> 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:113039 Archived-At: --===============7059865848791385888== Content-Type: multipart/alternative; boundary="00000000000088c19f05cdffcb66" --00000000000088c19f05cdffcb66 Content-Type: text/plain; charset="UTF-8" Thanks for these replies! Adding \unexpanded or \protected before \def didn't fix the problem, and surrounding the definition with \unprotect ... \protect didn't work either. But surrounding it with \pushcatcodetable \setcatcodetable\ctxcatcodes ... \popcatcodetable worked. I've never seen these commands before, but I gather from the existing documentation that the current catcode governs which characters are treated as special when a buffer is being processed. So here, it looks like I'm temporarily switching from some other catcode set (it looks like in publ-ini.mkiv, \catcode\commentasciicode\othercatcode gets invoked in \publ_set_publication, so perhaps that's what's happening?) to the default ConTeXt catcodes and then back. Thanks again! Joey On Sun, Oct 10, 2021 at 6:40 AM Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> wrote: > Joey McCollum via ntg-context schrieb am 10.10.2021 um 05:42: > > The test using \removepunctuation that you provided does what it should be > doing (it produces 6 instances of "test-test" with the intervening > punctuation mark in each case removed), but it doesn't do what I'm trying > to do in the MWE above. I'm trying to take certain punctuation marks that > follow the \autopuncttest macro and place them before it instead. Looking > at the typo-chr .lua and .mkiv files, I see that there are \pushpunctuation > and \poppunctuation methods in addition to the \removepunctuation method. > These might be useful for this purpose, but in any case, I still have to > check if the trailing character is one of the characters in a specified > set/string, and this is where the error is arising. > > > Add \protected (or \unexpanded) to your command definition. > > \startbtxrenderingdefinitions[myspec] > \protected\def\autopuncttest#1#2% > {\removeunwantedspaces% > \doifinstring{#2}{,.!?;:}{#2}% > \footnote{#1}% > \doifnotinstring{#2}{,.!?;:}{#2}} > \stopbtxrenderingdefinitions > > Wolfgang > > --00000000000088c19f05cdffcb66 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for these replies! Adding \unexpanded or \protected= before \def didn't fix the problem, and surrounding the definition wit= h \unprotect ... \protect didn't work either. But surrounding it with \= pushcatcodetable \setcatcodetable\ctxcatcodes=C2=A0... \popcatcodetable wor= ked.

I've never seen these commands before, but I ga= ther from the existing documentation that the current catcode governs which= characters are treated as special when a buffer is being processed. So her= e, it looks like I'm temporarily switching from some other catcode set = (it looks like in publ-ini.mkiv, \catcode\commentasciicode\othercatcode get= s invoked in=C2=A0\publ_set_publication, so perhaps that's what's h= appening?) to the default ConTeXt catcodes and then back.

Thanks again!

Joey

On Sun, Oct 10, 20= 21 at 6:40 AM Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:
Joey McCollum via ntg-context schrieb=20 am 10.10.2021 um 05:42:
=20
The test using \removepunctuation that you provided=20 does what it should be doing (it produces 6 instances of "test-test&qu= ot;=20 with the intervening punctuation=C2=A0mark in each case removed), but it=20 doesn't do what I'm trying to do in the MWE above. I'm trying t= o take=20 certain punctuation marks that follow the \autopuncttest macro and place them before it instead. Looking at the typo-chr .lua and .mkiv files, I see that there are \= pushpunctuation and \poppunctuation methods in additi= on to the \removepunctuation method. These might be useful for this purpose= , but in any case, I still have to check if the trailing character is one o= f the characters in a specified set/string, and this is where the error is = arising.

Add \protected (or \unexpanded) to your command definition.

\startbtxrenderingdefinitions[myspec]
\protected\def\autopuncttest#1#2%
=C2=A0 {\removeunwantedspaces%
=C2=A0=C2=A0 \doifinstring{#2}{,.!?;:}{#2}%
=C2=A0=C2=A0 \footnote{#1}%
=C2=A0=C2=A0 \doifnotinstring{#2}{,.!?;:}{#2}}
\stopbtxrenderingdefinitions

Wolfgang

--00000000000088c19f05cdffcb66-- --===============7059865848791385888== 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== --===============7059865848791385888==--