From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/111591 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Jairo A. del Rio" Newsgroups: gmane.comp.tex.context Subject: Re: ctxlua percentage format escape Date: Sat, 29 May 2021 08:02:23 -0500 Message-ID: References: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1543825419720304685==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23268"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat May 29 15:03:05 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 1lmycK-0005sj-Vp for gctc-ntg-context-518@m.gmane-mx.org; Sat, 29 May 2021 15:03:05 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 64C66283BD8; Sat, 29 May 2021 15:02:41 +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 bxlLtMs4xu_L; Sat, 29 May 2021 15:02:39 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 97F67283EBD; Sat, 29 May 2021 15:02:39 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 1569C283EBD for ; Sat, 29 May 2021 15:02:37 +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 Sowu5nAzkvty for ; Sat, 29 May 2021 15:02:36 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.221.50; helo=mail-wr1-f50.google.com; envelope-from=jairoadelrio6@gmail.com; receiver= Original-Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 1C3CD283BD8 for ; Sat, 29 May 2021 15:02:36 +0200 (CEST) Original-Received: by mail-wr1-f50.google.com with SMTP id v12so5933690wrq.6 for ; Sat, 29 May 2021 06:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=msksPXs3IG0CUJAADlE3bHfH8EcjfR7hK4wExp93stw=; b=UQ9elZFWkInEBg9kp244LxT9D6bxR9tEUUvRABaCUEbORalQThSvKC1rEbnAX0kHxi 5La6vVhn8t1Drsnj3IOjGSktxhaezArjfKxCSn/MARM03TDUZ2ginkHLxFu2ZOr5L5+O Xhmfx7X2fL9UA7wkbCCBRCB73gGEtXEIZs6DN1JKudvBDXEAgTuR7iVLBusZcbUnu4BA LaWBezrfYGWQN044mLGL0V0P511kdz+E9g/ViJxc0C4G+5g0Kchd6vsWPiNi9giHuFOt EjWdz8jw8fA88IIYPjUPo/ZPO18YrZ/+IAVnjmKv340gcZPY0VRKKUzDvdRSYPJI8E0a oimw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=msksPXs3IG0CUJAADlE3bHfH8EcjfR7hK4wExp93stw=; b=n3FpIvDzHOJOrkXAQYiKWdhRr7Xjfg1rAAlDLz/7z5EOqxQfyYsKBE1vVRzcSclg6N olmGEw0A77w4EdfGnASWT0oftfGkI/gOGiJBTXjQrw1uvianuYIViHCkbb01mObxIId7 gjFdx9/x0goNAvtdRP3P/1VcEXqXrYbpxUvAhwkWn+N4g+430Va8jqqGaUDkI+5N5sIF c8xyZFq9/kx28cHy6ydPeB03in61+WTbwM1Eed3WZ00htB0X23yBI7GvC+EAzTIZGid7 e/u37hxipj5OgImTPv2blkwF7Ln6HH0daogSI10iuPo1ITvB+sFg8DwiH7b2qFWTNN6B 1rRQ== X-Gm-Message-State: AOAM53305zPvryGYUqXftjeqhRQrIq+xp6gh5NdbNywsT9h09EjbeALu yJVsWPdNpUoJl71+9YU0iJUNNOigYc1Eo2TiwXXrTqeehkHrLg== X-Google-Smtp-Source: ABdhPJygoBX1m9ubgm/eAP0VGcCfKV3FV32+vLAzn01s/3IMsTaVs7RhoUjFbl2Z3iNaDfYgtIi806RGec9dHYGDYAo= X-Received: by 2002:a5d:6803:: with SMTP id w3mr13520483wru.285.1622293355531; Sat, 29 May 2021 06:02:35 -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:111591 Archived-At: --===============1543825419720304685== Content-Type: multipart/alternative; boundary="0000000000002d903c05c3779b3c" --0000000000002d903c05c3779b3c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Adam. There are some ways to do it. I'm sure there are many more, but I don't remember them right now. Hi, Hans. There's a bug (?) in syst-lua.lua related to \expression in MkIV (xmath and xcomplex aren't defined). Please fix that %Temporary hack for MkIV %Only use it in case \expression ... \relax doesn't work \startmkivmode \startluacode xmath =3D xmath or math xcomplex =3D xcomplex or {} --maybe math too??? \stopluacode \stopmkivmode \starttext $\pi =3D \ctxlua{context("\letterpercent.6f", math.pi)}$ $\pi =3D \expression string.format("\letterpercent.6f", pi)\relax$ %Changing catcodes so $ and % are letter characters \startasciimode \m{\pi =3D \expression ("%.6f"):format(pi) \relax} \m{\pi =3D \ctxlua{context("%.6f", math.pi)}} \stopasciimode \stoptext Regards, Jairo El s=C3=A1b, 29 de may. de 2021 a la(s) 07:32, Adam Reviczky (reviczky@gmai= l.com) escribi=C3=B3: > Hi, > > I was trying to use a quick calculation like the new mathfun in lmtx for > an older mkiv document. > > MWE from the wiki: > https://wiki.contextgarden.net/Programming_in_LuaTeX#Examples > > \starttext > $\pi =3D \ctxlua{context("\%.6f", math.pi)}$ > \stoptext > > But that gives an error (actually for both lmtx and mkiv): token call, > syntax: [ctxlua]:1: invalid escape sequence near '"\%' > > Whereas > > \starttext > $\pi =3D \startluacode context("%.6f", math.pi) \stopluacode$ > \stoptext > > Works fine as expected. > > Is there a way to escape the percentage sign in ctxlua as a format value? > > Adam > > _________________________________________________________________________= __________ > 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 > > _________________________________________________________________________= __________ > --0000000000002d903c05c3779b3c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi, Adam. Ther= e are some ways to do it. I'm sure there are many more, but I don't= remember them right now. Hi, Hans. There's a bug (?) in syst-lua.lua r= elated to \expression in MkIV (xmath and xcomplex aren't defined). Plea= se fix that


%Temporary hack for MkIV

%Only use it i= n case \expression ... \relax doesn't work

\startmkivmode=

\startluacode<= /p>

xmath =3D= xmath or math

xcomplex =3D x= complex or {} --maybe math too???

\stopluacode

\stopmkivmode<= /p>

\starttext

$\pi =3D \ctxl= ua{context("\letterpercent.6f", math.pi)}$


$\pi =3D \expr= ession string.format("\letterpercent.6f", pi)\relax$


%Changing catcodes s= o $ and % are letter characters

\startasciimod= e

\m{\pi =3D \ex= pression ("%.6f"):format(pi) \relax}


\m{\pi =3D \ct= xlua{context("%.6f", math.pi)}}

\stopasciimode=

\stoptext
<= br>

Regards= ,


<= /p>

Jairo


El s=C3=A1b, 29 de may. de 2021 a la(s) 07:32, Adam Reviczky (reviczky@gmail.com) escribi=C3=B3:
=
Hi,=

I was trying to use a quick calculation like the new mathfun in lmt= x for an older mkiv document.

MWE from the wiki:
https://wiki.contextgarden.net/Programming_in_LuaTeX#Examples

\= starttext
$\pi =3D \ctxlua{context("\%.6f", math.pi)}$
\sto= ptext

But that gives an error (actually for both lmtx and mkiv): tok= en call, syntax: [ctxlua]:1: invalid escape sequence near '"\%'= ;

Whereas

\starttext
$\pi =3D= \startluacode context("%.6f", math.pi) \stopluacode$
\stoptex= t

Works fine as expected.

Is there a way to escape the percentage sign in ctxlua as a format value?<= /div>

Adam
___________________________________________________________________________= ________
If your question is of interest to others as well, please add an entry to t= he Wiki!

maillist : ntg-cont= ext@ntg.nl / http://www.ntg.nl/mailman/listinfo/nt= g-context
webpage=C2=A0 : http://www.pragma-ade.nl / http://context.aanhet.net=
archive=C2=A0 : https://bitbucket.org/phg/context-m= irror/commits/
wiki=C2=A0 =C2=A0 =C2=A0: http://contextgarden.net
___________________________________________________________________________= ________
--0000000000002d903c05c3779b3c-- --===============1543825419720304685== 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== --===============1543825419720304685==--