ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* User-Defined Commands With Key-Value Options
@ 2015-07-25  7:47 Joas Yannick
  0 siblings, 0 replies; 6+ messages in thread
From: Joas Yannick @ 2015-07-25  7:47 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 46 bytes --]

Dear Rik,

Thank you very much.

All the best

[-- Attachment #1.2: Type: text/html, Size: 109 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: User-Defined Commands With Key-Value Options
  2015-07-22  9:20 Joas Yannick
@ 2015-07-23 20:32 ` Rik
  0 siblings, 0 replies; 6+ messages in thread
From: Rik @ 2015-07-23 20:32 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 3104 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 5279 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* User-Defined Commands With Key-Value Options
@ 2015-07-22  9:20 Joas Yannick
  2015-07-23 20:32 ` Rik
  0 siblings, 1 reply; 6+ messages in thread
From: Joas Yannick @ 2015-07-22  9:20 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 671 bytes --]

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.

Many thanks,
Yours sincerely.

[-- Attachment #1.2: Type: text/html, Size: 955 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* User-Defined Commands With Key-Value Options
@ 2015-07-20  9:28 Joas Yannick
  0 siblings, 0 replies; 6+ messages in thread
From: Joas Yannick @ 2015-07-20  9:28 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 397 bytes --]

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.

[-- Attachment #1.2: Type: text/html, Size: 592 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: User-Defined Commands With Key-Value Options
  2015-07-19 11:24 Joas Yannick
@ 2015-07-19 22:50 ` Hans Hagen
  0 siblings, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2015-07-19 22:50 UTC (permalink / raw)
  To: ntg-context

On 7/19/2015 1:24 PM, Joas Yannick wrote:
> Dear everyone,
>
> I am currently typesetting the old (published in 1707) French Bible of
> David Martin using
> ConTeXt MkIV. The source code looks like this:
>
> \startproduct martin1707
>      \startproject bibles % Page layout, fonts, language, etc.
>      \startbiblebook[number={1}, name={Genéſe}, abbreviation={Gen.},
> title={Le premier livre de Moyſe dit la Genéſe}]
>          \startbiblechapter[number={1}]
>              \startbibleverse[number={1}]
>                  Au commencement Dieu créa les cieux & la terre.
>              \stopbibleverse
>          \stopbiblechapter
>      \stopbiblebook
>      \startbiblebook[number={45}, name={Romains}, abbreviation={Rom.},
> title={Epiſtre de ſaint Paul apoſtre aux romains}]
>          \startbiblechapter[number={12}]
>              \startbibleverse[number={1}]
>                  Je vous exhorte donc, \bibleaddition{mes} fréres, par les
>                  compaſſions de Dieu, que vous préſentiez vos corps en
> ſacrifice
>                  vivant, ſaint, agréable à Dieu, \bibleaddition{qui eſt}
> vôtre
>                  raiſonnable ſervice.
>              \stopbibleverse
>              \startbibleverse[number={2}]
>                  Et ne vous conformez point à ce préſent ſiecle, mais ſoyez
>                  transformez par le renouvellement de vôtre entendement,
> afin que
>                  vous éprouviez quelle eſt la volonté de Dieu, bonne, &
> agréable,
>                  & parfaite.
>              \stopbibleverse
>          \stopbiblechapter
>      \stopbiblebook
> \stopproduct
>
> As you may know, all the Bibles are divided into books, and each book
> into chapters, and
> each chapter into verses. The purpose of \startbiblebook,
> \startbiblechapter, and \startbibleverse
> is to control the formatting thereof respectively (as \startsection,
> \startsubsection, etc., control
> the formatting of sections, subsections, etc.)
>
> Now, as you see. these commands are user-defined commands with key-value
> options. My
> goal is to define the way they do the formatting with Lua. But I do not
> know how to do. I
> know a bit about programming, so learning Lua is not a problem.

So how would you like to use lua? Is the data stored in lua?

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* User-Defined Commands With Key-Value Options
@ 2015-07-19 11:24 Joas Yannick
  2015-07-19 22:50 ` Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Joas Yannick @ 2015-07-19 11:24 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 2189 bytes --]

Dear everyone,

I am currently typesetting the old (published in 1707) French Bible of
David Martin using
ConTeXt MkIV. The source code looks like this:

\startproduct martin1707
    \startproject bibles % Page layout, fonts, language, etc.
    \startbiblebook[number={1}, name={Genéſe}, abbreviation={Gen.},
title={Le premier livre de Moyſe dit la Genéſe}]
        \startbiblechapter[number={1}]
            \startbibleverse[number={1}]
                Au commencement Dieu créa les cieux & la terre.
            \stopbibleverse
        \stopbiblechapter
    \stopbiblebook
    \startbiblebook[number={45}, name={Romains}, abbreviation={Rom.},
title={Epiſtre de ſaint Paul apoſtre aux romains}]
        \startbiblechapter[number={12}]
            \startbibleverse[number={1}]
                Je vous exhorte donc, \bibleaddition{mes} fréres, par les
                compaſſions de Dieu, que vous préſentiez vos corps en
ſacrifice
                vivant, ſaint, agréable à Dieu, \bibleaddition{qui eſt}
vôtre
                raiſonnable ſervice.
            \stopbibleverse
            \startbibleverse[number={2}]
                Et ne vous conformez point à ce préſent ſiecle, mais ſoyez
                transformez par le renouvellement de vôtre entendement,
afin que
                vous éprouviez quelle eſt la volonté de Dieu, bonne, &
agréable,
                & parfaite.
            \stopbibleverse
        \stopbiblechapter
    \stopbiblebook
\stopproduct

As you may know, all the Bibles are divided into books, and each book into
chapters, and
each chapter into verses. The purpose of \startbiblebook,
\startbiblechapter, and \startbibleverse
is to control the formatting thereof respectively (as \startsection,
\startsubsection, etc., control
the formatting of sections, subsections, etc.)

Now, as you see. these commands are user-defined commands with key-value
options. My
goal is to define the way they do the formatting with Lua. But I do not
know how to do. I
know a bit about programming, so learning Lua is not a problem.

Thanking you in advance,
All the best,
Yours faithfully.

[-- Attachment #1.2: Type: text/html, Size: 2698 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-07-25  7:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-25  7:47 User-Defined Commands With Key-Value Options Joas Yannick
  -- strict thread matches above, loose matches on Subject: below --
2015-07-22  9:20 Joas Yannick
2015-07-23 20:32 ` Rik
2015-07-20  9:28 Joas Yannick
2015-07-19 11:24 Joas Yannick
2015-07-19 22:50 ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).