From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/109185 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Jairo A. del Rio" Newsgroups: gmane.comp.tex.context Subject: Re: context.delayed as parameter of setuphead[before=...] Date: Mon, 2 Nov 2020 23:03:23 -0500 Message-ID: References: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5314219601354709571==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6451"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Nov 03 05:03:58 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 1kZnY5-0001Ys-IT for gctc-ntg-context-518@m.gmane-mx.org; Tue, 03 Nov 2020 05:03:57 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 5B2C01A95FB; Tue, 3 Nov 2020 05:03:38 +0100 (CET) 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 zLlw-kN7jT9H; Tue, 3 Nov 2020 05:03:37 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 4B4A51A9D16; Tue, 3 Nov 2020 05:03:37 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 857501A97A5 for ; Tue, 3 Nov 2020 05:03:36 +0100 (CET) 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 nEk0G_bsHSaF for ; Tue, 3 Nov 2020 05:03:35 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.128.42; helo=mail-wm1-f42.google.com; envelope-from=jairoadelrio6@gmail.com; receiver= Original-Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 A03181A95FB for ; Tue, 3 Nov 2020 05:03:35 +0100 (CET) Original-Received: by mail-wm1-f42.google.com with SMTP id c16so11418258wmd.2 for ; Mon, 02 Nov 2020 20:03:35 -0800 (PST) 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=00XMqF+OBcu7Rwyyyv+3VrQDdVXjZR+fgA7Q20hcidk=; b=p7x7mJNmkpW9W+WeviyaNLFGtDtCdj2Z9BxGOblpeUICTJXN3+9qPBcMZMZQjj/Fjv NUppVBGzy1JLay1c+TS7k4CD/YoEulA0pet4bnsKAiKJZTSNMvDs5yodGgcudmSZMo3T xxEHdhiS1D8T1W4N6E5mejmxOSmvcpPpu6EWiyCEL1gAGKGyxl2lUyy2aNqOR6x1RSk4 PR6JPeyyjEjMf+vbfFD1nKMIOMI//dn5Lo32UH0E/2yq+GzTVZhb+F+d0s17iNXlezZU vXbQTxsAp7AWjv15qaPAylSE6RNVzp2tEUceJknmo/PETpLOdnjnPKzHBnSDeMPd73l1 CMQg== 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=00XMqF+OBcu7Rwyyyv+3VrQDdVXjZR+fgA7Q20hcidk=; b=jsCFuhkv8CHhXqzf9u9E2iZxeCEw934k3fCPCyiExN5ExgDu0jjIghzx6qUImJiEmv onmlqAG9jIHU26eg58Riwck1pPb+dLVSdbw6/VrDoUtbwnhkm3i0a84N+ekF/YP+A36d WkyWqkJ4CfpqkTP1jQ8bXPsFu79eS2CD6+73a9Krc3E6RQe5pDw9jN3+EUqyj5UI7sMQ U2gD5orGqCTaKe1WoPhBg2ljeh3cKpyvIfw1iZ/Vwxny2pGjRTVG5YHNm8X2iEeTosgU xdPrcmjzaD5Q1utXeeBIjIfn16CpCPDTYh8RWAuf9VhZ8QQ9/DkQ2CItjwAeTpdGCTt0 Dsgg== X-Gm-Message-State: AOAM531v1gZ0CyFLD8p9QxU2x5k2kdu2Ks3r8vCBGESZRiP1kB/jY/3l 5NJFm82S8sc3zdJO0fcmA20R+aEFvEF2+i4XJSJzO3/UJexNVg== X-Google-Smtp-Source: ABdhPJz2ICflIPk4muaREyo/vg9GLKo5GGBVfK1KjneqWZ/V0/iApv5hTF3ngk805JcRgjnchNh8VyCrCKtKLw1+tHs= X-Received: by 2002:a1c:2d8f:: with SMTP id t137mr1246723wmt.26.1604376214961; Mon, 02 Nov 2020 20:03:34 -0800 (PST) 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:109185 Archived-At: --===============5314219601354709571== Content-Type: multipart/alternative; boundary="00000000000061012005b32bf2f5" --00000000000061012005b32bf2f5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sorry. What I meant is: when you use context.setuphead({'chapter'}, {title=3D"Some text"}) at the Lua end, {'chapter'} and {title=3D"Some text"} (notice "Some text" i= s a string, not a function) are Lua tables. TeX will print "Some text", but it won't work for context.delayed as it is another table (metatable trickery to allow nesting, I guess). Try: \starttext \startluacode context(type(context.delayed)) \stopluacode \stoptext Long story short: context.cmda(context.delayed.cmdb(something)) will (possibly) work; context.cmdc({key=3Dcontext.delayed.cmdd(somethingelse)}) won't. Hans and Wolfgang can elaborate in case I've missed something. Jairo :) El lun., 2 de nov. de 2020 a la(s) 22:06, Sylvain Hubert ( champignoom@gmail.com) escribi=C3=B3: > > as tables like those in setuphead({somehead}, {somesettings}) are actua= l > Lua tables and follow Lua, not TeX, rules > But there are lua apis that support delayed TeX like > `context.chapter(context.delayed'text')`. > Whether or not the function is stored in a table should be theoretically > irrelevant. > I guess there should be a switch somewhere that let the command recognize= d > delayed function. > > On Tue, 3 Nov 2020 at 03:29, Jairo A. del Rio > wrote: > >> On the Lua side, you'll have to pass strings so your example works, as >> tables like those in setuphead({somehead}, {somesettings}) are actual Lu= a >> tables and follow Lua, not TeX, rules (see e.g. Lua reference in >> https://www.lua.org/manual/5.4/ or, better, CLD manual in >> http://www.pragma-ade.nl/general/manuals/cld-mkiv.pdf): >> >> >> \starttext >> >> \startluacode >> >> --First example >> >> for m =3D 1, 3 do >> >> context.setuphead({'chapter'}, {before=3D'hello'}) >> >> context.startchapter({title=3D"I'm a chapter!"}) >> >> for i =3D 1, 3 do >> >> context.input("knuth") >> >> end >> >> context.stopchapter() >> >> end >> >> >> --Second example >> >> --We'll pass some strings to TeX >> >> local nice =3D "ConTeXt is love, ConTeXt is life" >> >> local somehead =3D 'chapter' >> >> local sometext =3D 'vallejo-trilce-es' >> >> >> context.setuphead({somehead}, {before=3Dnice}) >> >> context.startchapter({title=3Dsomehead}) >> >> context.input(sometext) >> >> context.stopchapter() >> >> \stopluacode >> >> \stoptext >> >> >> I hope examples help. >> >> Regards, >> >> Jairo :) >> >> >> >> El lun., 2 de nov. de 2020 a la(s) 21:09, Sylvain Hubert ( >> champignoom@gmail.com) escribi=C3=B3: >> >>> Dear List, >>> >>> I'm trying to mirror the context command >>> `\setuphead[chapter][before=3Dhello]` >>> into lua with delayed typesetting of 'hello', but >>> `\ctxlua{context.setuphead({'chapter'}, >>> {before=3Dcontext.delayed'hello'})}` >>> does not have any effect. Could anyone help me on this? Thanks! >>> >>> Best, >>> Sylvain >>> >>> _______________________________________________________________________= ____________ >>> 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 >>> >>> _______________________________________________________________________= ____________ >>> >> >> ________________________________________________________________________= ___________ >> If your question is of interest to others as well, please add an entry t= o >> 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 >> >> ________________________________________________________________________= ___________ >> > > _________________________________________________________________________= __________ > 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 > > _________________________________________________________________________= __________ > --00000000000061012005b32bf2f5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Sorry. What I meant is: when you use

context.setuphead({'chapter'}, {title=3D"Some text"})
at the Lua end, {'chapter'} and {title=3D"Some tex= t"} (notice "Some text" is a string, not a function) are Lua= tables. TeX will print "Some text", but it won't work for co= ntext.delayed as it is another table (metatable trickery to allow nesting, = I guess). Try:

\starttext

\startluacode<= /p>

context(type(c= ontext.delayed))

\stopluacode

\stoptext

<= p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">

Long story short: con= text.cmda(context.delayed.cmdb(something)) will (possibly) work; context.cm= dc({key=3Dcontext.delayed.cmdd(somethingelse)}) won't.

Hans and Wolfgang can = elaborate in case I've missed something.


Jairo :)


El lun., 2 de nov. de 2020 = a la(s) 22:06, Sylvain Hubert (cha= mpignoom@gmail.com) escribi=C3=B3:
> as tables like those in s= etuphead({somehead}, {somesettings}) are actual Lua tables and follow Lua, = not TeX, rules
But there are lua apis that support delayed TeX li= ke `context.chapter(context.delayed'text')`.
Whether or n= ot the function is stored in a table should be theoretically irrelevant.
I guess there should be a switch somewhere that let the command re= cognized delayed function.

On Tue, 3 Nov 2020 at 03:29, Jairo A. del R= io <jairoad= elrio6@gmail.com> wrote:

On the Lua sid= e, you'll have to pass strings so your example works, as tables like th= ose in setuphead({somehead}, {somesettings}) are actual Lua tables and foll= ow Lua, not TeX, rules (see e.g. Lua reference in https://www.lua.org/manual/5.4/ or= , better, CLD manual in http://www.pragma-ade.nl/general/manuals/c= ld-mkiv.pdf):


\starttext

\startluacode =

--First exampl= e

for m =3D 1, 3= do

context.se= tuphead({'chapter'}, {before=3D'hello'})

context.st= artchapter({title=3D"I'm a chapter!"})

for i =3D = 1, 3 do

contex= t.input("knuth")

end

context.st= opchapter()

end


--Second examp= le

--We'll pa= ss some strings to TeX

local nice =3D "ConTeXt is love, ConTeXt is life"=

local somehead= =3D 'chapter'

local sometext= =3D 'vallejo-trilce-es'


context.setuph= ead({somehead}, {before=3Dnice})

context.startc= hapter({title=3Dsomehead})

context.input(= sometext)

context.stopch= apter()

\stopluacode

\stoptext

<= p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">

I hope examples help.=

Regard= s,

Jairo :)



___________________________________________________________________________= ________
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
___________________________________________________________________________= ________
___________________________________________________________________________= ________
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
___________________________________________________________________________= ________
--00000000000061012005b32bf2f5-- --===============5314219601354709571== 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== --===============5314219601354709571==--