From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/113068 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: Mon, 11 Oct 2021 21:57:13 -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="===============5417241889307789808==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19810"; 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 Tue Oct 12 04:00:20 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 1ma75Y-0004qS-6a for gctc-ntg-context-518@m.gmane-mx.org; Tue, 12 Oct 2021 04:00:20 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id AFE0E280169; Tue, 12 Oct 2021 03:59:48 +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 LpZ2K0Oduqsh; Tue, 12 Oct 2021 03:59:47 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 1254C287C79; Tue, 12 Oct 2021 03:59:47 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 3CF092835F9 for ; Tue, 12 Oct 2021 03:59:45 +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 xVMM035r-_py for ; Tue, 12 Oct 2021 03:59:44 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.166.172; helo=mail-il1-f172.google.com; envelope-from=jmccollum20140511@gmail.com; receiver= Original-Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (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 EA612280169 for ; Tue, 12 Oct 2021 03:59:43 +0200 (CEST) Original-Received: by mail-il1-f172.google.com with SMTP id i11so19027407ila.12 for ; Mon, 11 Oct 2021 18:59:43 -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=8M6NHJ0Ti5hHC9LwhuXF4ORX1hzx/fnjJCfrxreryBE=; b=cb0HOCaUIwR+93rH0haedPaaAb4MPlnJsn5f/bn3TMVyMjSqwFJxiriyo8ryPXnvtl vfjMoACLrAXn99Md/muocYiVCi4MxfoNw+r3ltCtQz2E/QUQt+E0FPqy7VjXK9mdnnlQ gRO25wALftq5+f0/chcHQSLErXkitaomwamvRV8UTxRa8YJP6o6hhWB3mco1Bwg6l+5P DnJzuuWHyOikTW7ataZ453utOM58yenEg5ZxXA2EJbKqlRnnG9ggf1eCTcvbk18zZgBB nOwQjLqGZx048ysvTsFVSg929RZyutNojQO47T7D4kL34lMVtGITVsksNbRF4MHmsbt0 hweg== 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=8M6NHJ0Ti5hHC9LwhuXF4ORX1hzx/fnjJCfrxreryBE=; b=YTxVg+ZID4cy+PlR7/CLFJvGw8PyW29k9Ei4MwVlhA7LK9VnRvvUHiaHeFqmlcSsKW A1XyjZHepsK00MS1oiuiqbK1jOjA7bNO5vYFn1rtifLjFRUsvT4q8CLBAI7y4P3HP2vh V9HT8PE/RdM/PKX/dUYZrOpr3rWWJPfGQjSDGClVe8LjKZz//cdsQLRYI72uT/9KZjst m3adUxEu3UvcSQ/yjQwvL8vZdXvVMlv1uD/WOxQTcrAwQmTOsA9bn//Da8tJ8C84Ns0u +2LEhXVF+OftfU64sRm1jZCUBmBjukOYINfm4LrGsE4LNECXbKpxURE+i3pav5Ru/hA+ 3Y5g== X-Gm-Message-State: AOAM530KoFH9DTTHvhD/ku0nI4OlHsuC0eEQ3LiLV961pWNahHI1wRcY xn8kEpn0I78yI4w6fkLhnU9BNOC3CA3GOZC5nNY= X-Google-Smtp-Source: ABdhPJxZnWTotAt2wweD5GERLongD6QBr3+R5NU4O7fqpNr92erU0YpqBuWD+lZC1bSLjC693yxVthW4G1h+I1BZHEY= X-Received: by 2002:a05:6e02:12a3:: with SMTP id f3mr19513491ilr.54.1634003982457; Mon, 11 Oct 2021 18:59:42 -0700 (PDT) In-Reply-To: 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:113068 Archived-At: --===============5417241889307789808== Content-Type: multipart/alternative; boundary="000000000000ef9e7405ce1e324e" --000000000000ef9e7405ce1e324e Content-Type: text/plain; charset="UTF-8" An alternative solution is to isolate the setting of the autopunctuation btx option: ``` % Because some common punctuation characters are escaped in publ-ini.mkiv, % we have to set this option separately \pushcatcodetable \setcatcodetable\ctxcatcodes \setupbtx[sbl][autopunctuation={!,.:;?}]% undelimited list of trailing punctuation to move before footnote citations \popcatcodetable ``` Joey On Sun, Oct 10, 2021 at 9:40 AM Joey McCollum wrote: > 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 >> >> --000000000000ef9e7405ce1e324e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
An alternative solution is to isolate the setting of the a= utopunctuation=C2=A0btx option:

```
% Because some common punctua= tion characters are escaped in publ-ini.mkiv,
% we have to set this opti= on separately
\pushcatcodetable
\setcatcodetable\ctxcatcodes
=C2= =A0 \setupbtx[sbl][autopunctuation=3D{!,.:;?}]% undelimited list of trailin= g punctuation to move before footnote citations
\popcatcodetable
```<= div>
Joey

On Sun, Oct 10, 2021 at 9:40 AM Joey McCollum= <jmcco= llum20140511@gmail.com> wrote:
Thanks for these replies! Adding \un= expanded or \protected before \def didn't fix the problem, and surround= ing the definition with \unprotect ... \protect didn't work either. But= surrounding it with \pushcatcodetable \setcatcodetable\ctxcatcodes=C2=A0..= . \popcatcodetable worked.

I've never seen these com= mands before, but I gather from the existing documentation that the current= catcode governs which characters are treated as special when a buffer is b= eing processed. So here, it looks like I'm temporarily switching from s= ome other catcode set (it looks like in publ-ini.mkiv, \catcode\commentasci= icode\othercatcode gets invoked in=C2=A0\publ_set_publication, so perhaps t= hat's what's happening?) to the default ConTeXt catcodes and then b= ack.

Thanks again!

Joey

On Sun, Oct 10, 2021 at 6:40 AM Wolfgang Schuster <wolfgang.schuster.lis= ts@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

--000000000000ef9e7405ce1e324e-- --===============5417241889307789808== 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== --===============5417241889307789808==--