From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/113113 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ramkumar KB via ntg-context Newsgroups: gmane.comp.tex.context Subject: Reading ConTeXt metadata values into Lua Date: Sat, 16 Oct 2021 12:00:27 +0800 Message-ID: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3886381779605063441==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9642"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Ramkumar KB To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat Oct 16 06:01:18 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 1mbasn-0002Fj-T7 for gctc-ntg-context-518@m.gmane-mx.org; Sat, 16 Oct 2021 06:01:17 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 28467288B18; Sat, 16 Oct 2021 06:00:44 +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 sVLgLIJehp96; Sat, 16 Oct 2021 06:00:42 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 9CC8A288B19; Sat, 16 Oct 2021 06:00:42 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 8FF76288B16 for ; Sat, 16 Oct 2021 06:00: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 8hsm8XtR3tzB for ; Sat, 16 Oct 2021 06:00:40 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.167.50; helo=mail-lf1-f50.google.com; envelope-from=ramkumarkb@gmail.com; receiver= Original-Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.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 9E112288B14 for ; Sat, 16 Oct 2021 06:00:40 +0200 (CEST) Original-Received: by mail-lf1-f50.google.com with SMTP id x192so15035543lff.12 for ; Fri, 15 Oct 2021 21:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=Fsdk+Z/HRPSV6p3zuRwfRQA4xP7CHA94OY+8d8xkquE=; b=oKltwfK6BOO4y4yYSLmRgcum+BLkj3dZzpMncFmE2W3O2I1sry6/ftP7HixcpKZaVs eFrREvMXp/CWZ2jEm1dbF8DNqnGwQKa83Mu6z8hLmxBQHxCOnw6I5Ck6o+1htMYvWqc/ ebUh0Jf3NPulyH49PU+cgSKAcoN46NAyBMqbTZ4xDAAj7AFwt3WKBeT2Yvb8lud2wOyy /SNTq3iwvJxmN7EFiYNSs32donSxiZQqUgMnHyOsQzJeqpT1zTgQZZF6/8/atZ9jHudr rUKT/zAgKcKgjW6ZK8QU7VbIqJxtcyFhKoFKVWqBQdc7D7Ns+nu/BG1lPuUcIw5wj10l ni1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Fsdk+Z/HRPSV6p3zuRwfRQA4xP7CHA94OY+8d8xkquE=; b=ag77/bhy1PE076W7QX6RMI1I0Vd+Lae7+G7KzSrbsYdxBWbrobmLsrXBPHtvC4wJAI g/uiak81g+ee4gDe0RklN1ftvlnf+FF/iV0mSXpojYoglj+hul1IQG9yu6bOG0KhL8bY YADQ3PBBB8b/WBhBQ8IsXuqmkBFHh5sL0DOaACBz0Y9mY9/uFbsVDdvNReWX+EIjkn+j U3z9KJfyO589/AWG0cSFIhI10NWo9cKZ7xH2RRuCpw0rRABQz3HXNGk9pcF1Q3zF85SW NicjX8Qojf63l1CE/nt879rk0qOtYHvsg5FxhR6PaNIi0ZOpuB+9AAo+zDp74aUgFPtA ZJKg== X-Gm-Message-State: AOAM5331AI/GCqr9hqF7Oz3PeiePuHDLYLuJf3tZyoGozNtPnu/t40jf Sf6zcoWwkh222ZhIf4aEHc+ZMpA/JBKbSNPRx8RdCqFS08M= X-Google-Smtp-Source: ABdhPJzrwJGOvqBHJ3mPvDK4Gpea+uc4u7fg8fuXjXPUppe0n5XLXGWtA7mdI9gwSGN0NAxLEtvrdUkJbmqYV5lk+Qo= X-Received: by 2002:a2e:530b:: with SMTP id h11mr17185706ljb.260.1634356839388; Fri, 15 Oct 2021 21:00:39 -0700 (PDT) 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:113113 Archived-At: --===============3886381779605063441== Content-Type: multipart/alternative; boundary="000000000000d91be205ce705a04" --000000000000d91be205ce705a04 Content-Type: text/plain; charset="UTF-8" Hello All, I was trying to read the value of '\totalnumberofpages' into lua to do something with it. As an example, see below. Now, as I understand it, my example would not work as TeX gets the first go at this and therefore the variable 'pages' is the string '\totalnumberofpages' and not the actual value itself. And Lua cannot process this "calculation". I tried to go thru the manual - *cld-mkiv.pdf *- in the distro but could not catch on how to read a metadata value (not print). I am sure that I am missing a small trick somewhere (or is it something more involved?). \startluacode function myFancyCalculations(pages) -- some fancy stuff but as an example local myCal = tonumber(pages) + 1 return myCal \stopluacode \starttext \blah \ctxlua{context(myFancyCalculations("\\totalnumberofpages"))} \stoptext Thank you in advance for any tips. best regards, Ramkumar --000000000000d91be205ce705a04 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello All,

I was trying to read the= value of '\totalnumberofpages' into= lua to do something with it. As an=C2=A0example, see below.

=
Now, as I understand it, my example would not work as TeX gets t= he first go at this and therefore the variable 'pages' is the strin= g '\totalnumberofpages' and not the actual value itself. And Lua ca= nnot process this "calculation".

I tried= to go thru the manual -=C2=A0 cld-mkiv.pdf=C2=A0 - in the distro bu= t could not catch on how to read a metadata value (not print). I am sure th= at I am missing a small trick somewhere (or is it something more involved?)= .

= \startluacode
<= span style=3D"white-space:pre-wrap">function=C2=A0myFancyCalculations(pages= )
=C2=A0 -- some fancy stuff but as an exampl= e
local myCal =3D tonumber(pages) + 1
return myCal
\sto= pluacode

\starttext

\blah

\ctxlua= {context(myFancyCalculations("\\totalnumberofpages"))}
=

\stoptext

Thank you in=C2=A0advance for any t= ips.

best regards,
Ramkumar
--000000000000d91be205ce705a04-- --===============3886381779605063441== 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== --===============3886381779605063441==--