From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/92038 Path: news.gmane.org!not-for-mail From: Rik Newsgroups: gmane.comp.tex.context Subject: Re: User-Defined Commands With Key-Value Options Date: Thu, 23 Jul 2015 16:32:36 -0400 Message-ID: <55B14F64.6030306@panix.com> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1295540253==" X-Trace: ger.gmane.org 1437683629 21351 80.91.229.3 (23 Jul 2015 20:33:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 Jul 2015 20:33:49 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Thu Jul 23 22:33:36 2015 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([5.39.185.229]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZINBM-0007Cs-U3 for gctc-ntg-context-518@m.gmane.org; Thu, 23 Jul 2015 22:33:33 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 00F781022C for ; Thu, 23 Jul 2015 22:33:31 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 04Le4QsRtUr0 for ; Thu, 23 Jul 2015 22:33:30 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 32BC410235 for ; Thu, 23 Jul 2015 22:32:58 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id C1A92101FD for ; Thu, 23 Jul 2015 22:32:54 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id E10ZrdBABtSi for ; Thu, 23 Jul 2015 22:32:53 +0200 (CEST) Original-Received: from filter4-ams.mf.surf.net (filter4-ams.mf.surf.net [192.87.102.72]) by balder.ntg.nl (Postfix) with ESMTP id 7D6DE101E6 for ; Thu, 23 Jul 2015 22:32:53 +0200 (CEST) Original-Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by filter4-ams.mf.surf.net (8.14.4/8.14.4/Debian-4) with ESMTP id t6NKWcTE015520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 23 Jul 2015 22:32:45 +0200 Original-Received: from [192.168.9.13] (pool-71-183-246-38.nycmny.fios.verizon.net [71.183.246.38]) by mailbackend.panix.com (Postfix) with ESMTPSA id 5A60216F89 for ; Thu, 23 Jul 2015 16:32:37 -0400 (EDT) User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 In-Reply-To: X-Bayes-Prob: 0.0001 (Score 0, tokens from: ntg-context@ntg.nl, base:default, @@RPTN) X-CanIt-Geo: ip=166.84.1.89; country=US; region=New York; city=New York; latitude=40.7553; longitude=-73.9924; http://maps.google.com/maps?q=40.7553,-73.9924&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 01OTUwDiT - 37790e93c261 - 20150723 (trained as not-spam) Received-SPF: pass (filter4-ams.mf.surf.net: domain of rik@panix.com designates 166.84.1.89 as permitted sender) receiver=filter4-ams.mf.surf.net; client-ip=166.84.1.89; envelope-from=; helo=mailbackend.panix.com; identity=mailfrom X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.72 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 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.org gmane.comp.tex.context:92038 Archived-At: This is a multi-part message in MIME format. --===============1295540253== Content-Type: multipart/alternative; boundary="------------040204060303090300080607" This is a multi-part message in MIME format. --------------040204060303090300080607 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 2015-07-22 05:20, Joas Yannick wrote: > On 7/20/2105 11:28 AM Joas Yannick wrote: > > > > > On 7/20/2105 0:50 AM Hans Hagen wrote: > > > So how would you like to use lua? Is the data stored in lua? > > > > Yes, I imagine that the data (for instance, the value of > > the keys "number", "name", "abbreviation", "title", etc.) > > is stored somewhere when the compilation process reads, say, > > "\startbiblebook", and that they are available to define the > > the formatting done by "\startbiblebook". > > > > Thank you. > > I have found this wiki: > > http://wiki.contextgarden.net/Commands_with_KeyVal_arguments > > But since I do not know Lua, I would appreciate that someone gets me > started with my example. > Joas, Perhaps there some confusion here about how ConTeXt is used to create a document, and what role Lua plays in it. ConTeXt is a macro-based language that provides a level of abstraction over TeX, which is also a macro language. Documents can be completely specified with the use of ConTeXt. Lua is a traditional programming language that is used by some versions of ConTeXt to optimize and extend some of the internal capabilities of ConTeXt and TeX. There are very few situations, if any, in which a document writer /must/ resort to using Lua; ConTeXt almost always suffices. Only the first example you found in the ConTeXt wiki uses Lua, and that example is not really useful for your problem. The other examples on that page are coded in the ConTeXt macro language. You might also look at http://wiki.contextgarden.net/System_Macros/Handling_Arguments and http://wiki.contextgarden.net/Commands_with_optional_arguments for more examples, and on the mailing list. I would also recommend looking in the mailing list for discussions of the \getrawparameters and \getbufferdata and related commands (in particular http://www.mail-archive.com/ntg-context%40ntg.nl/msg78808.html). Here is some code I use to format verse. It provides default values for the language, margin inset and continuation line indents that can be overridden when needed: \starttexdefinition unexpanded startPoem \begingroup \dosingleempty\dostartPoem \stoptexdefinition \starttexdefinition dostartPoem [#SETUPS] \getrawparameters[Poem][inset=2em,indent=0em,before=,font=, language=en,#SETUPS] \grabbufferdata[Poem][startPoem][stopPoem] \stoptexdefinition \starttexdefinition stopPoem \obeylines \language[\Poemlanguage] \Poembefore \Poemfont \setupnarrower[left={\dimexpr\Poemindent+\Poeminset\relax}, right=\Poeminset, before=] \startnarrower[left,right] \startparagraph \setupindenting[-\Poemindent,yes] \inlinebuffer[Poem] \stopparagraph \stopnarrower \endgroup \blank[halfline] \stoptexdefinition This type of code can easily be used to deal with the names, numbers, and abbreviations you describe in your requirements. -- Rik Kabel --------------040204060303090300080607 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On 2015-07-22 05:20, Joas Yannick wrote:
On 7/20/2105 11:28 AM Joas Yannick wrote:
>
> > On 7/20/2105 0:50 AM Hans Hagen wrote:
> > So how would you like to use lua? Is the data stored in lua?
>
> Yes, I imagine that the data (for instance, the value of
> the keys "number", "name", "abbreviation", "title", etc.)
> is stored somewhere when the compilation process reads, say,
> "\startbiblebook", and that they are available to define the
> the formatting done by "\startbiblebook".
>
> Thank you.

I have found this wiki:

http://wiki.contextgarden.net/Commands_with_KeyV=
al_arguments

But since I do not know Lua, I would appreciate that someone=
 gets me
started with my example.

Joas,

Perhaps there some confusion here about how ConTeXt is used to create a document, and what role Lua plays in it. ConTeXt is a macro-based language that provides a level of abstraction over TeX, which is also a macro language. Documents can be completely specified with the use of ConTeXt. Lua is a traditional programming language that is used by some versions of ConTeXt to optimize and extend some of the internal capabilities of ConTeXt and TeX. There are very few situations, if any, in which a document writer must resort to using Lua; ConTeXt almost always suffices.

Only the first example you found in the ConTeXt wiki uses Lua, and that example is not really useful for your problem. The other examples on that page are coded in the ConTeXt macro language.

You might also look at=C2=A0http://wiki.contextgarden.net/Syst= em_Macros/Handling_Arguments and http://wiki.contextgarden.net/Comm= ands_with_optional_arguments for more examples, and on the mailing list. I would also recommend looking in the mailing list for discussions of the \getrawparamet= ers and \getbufferdata and related commands (in particular=C2=A0= <= a class=3D"moz-txt-link-freetext" href=3D"http://www.mail-archive.com/ntg= -context%40ntg.nl/msg78808.html">http://www.mail-archive.com/ntg-context%= 40ntg.nl/msg78808.html).

Here is some code I use to format verse. It provides default values for the language, margin inset and continuation line indents that can be overridden when needed:
\starttexdefinition unexpanded startPoem
=C2=A0 \begingroup
=C2=A0 \dosingleempty\dostartPoem
\stoptexdefinition

\starttexdefinition dostartPoem [#SETUPS]
=C2=A0 \getrawparameters[Poem][inset=3D2em,indent=3D0em,before=3D,font=3D= ,
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 language=3Den,#SETUPS]
=C2=A0 \grabbufferdata[Poem][startPoem][stopPoem]=
\stoptexdefinition

\starttexdefinition stopPoem
=C2=A0=C2=A0=C2=A0 \obeylines
=C2=A0=C2=A0=C2=A0 \language[\Poemlanguage]
=C2=A0=C2=A0=C2=A0 \Poembefore
=C2=A0=C2=A0=C2=A0 \Poemfont
=C2=A0=C2=A0=C2=A0 \setupnarrower[left=3D{\dimexpr\Poemindent+\Poeminset\relax},
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 right=3D\Poeminset,=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 before=3D]
=C2=A0=C2=A0=C2=A0 \startnarrower[left,right]
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \startparagraph =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \setupindenting[-\Poeminden= t,yes]
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \inlinebuffer[Poem]
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \stopparagraph
=C2=A0=C2=A0=C2=A0 \stopnarrower
=C2=A0 \endgroup
=C2=A0 \blank[halfline]
\stoptexdefinition
This type of code can easily be used to deal with the names, numbers, and abbreviations you describe in your requirements.

--
Rik Kabel
--------------040204060303090300080607-- --===============1295540253== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly90ZXguYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHA6Ly9mb3VuZHJ5LnN1cGVsZWMu ZnIvcHJvamVjdHMvY29udGV4dHJldi8Kd2lraSAgICAgOiBodHRwOi8vY29udGV4dGdhcmRlbi5u ZXQKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX18= --===============1295540253==--