ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Modes in Lua
@ 2017-05-31  7:06 Henning Hraban Ramm
  2017-05-31  9:03 ` MF
  0 siblings, 1 reply; 6+ messages in thread
From: Henning Hraban Ramm @ 2017-05-31  7:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi, this should be easy:

How can I access ConTeXt’s modes in Lua? Is it any different with language modes (*en)?

e.g.

\startluacode

if context.modes['specialmode'] then
    context('I’m special.')
end

\stopluacode


Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
GPG Key ID 1C9B22FD

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Modes in Lua
  2017-05-31  7:06 Modes in Lua Henning Hraban Ramm
@ 2017-05-31  9:03 ` MF
  2017-05-31 14:51   ` Pablo Rodriguez
  0 siblings, 1 reply; 6+ messages in thread
From: MF @ 2017-05-31  9:03 UTC (permalink / raw)
  To: ntg-context

if tex.modes['specialmode'] then
    context('I’m special.')
end
 
Best greetings,
Massi

> Hi, this should be easy:
> 
> How can I access ConTeXt’s modes in Lua? Is it any different with
> language modes (*en)?
> 
> e.g.
> 
> \startluacode
> 
> if context.modes['specialmode'] then
>     context('I’m special.')
> end
> 
> \stopluacode
> 

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Modes in Lua
  2017-05-31  9:03 ` MF
@ 2017-05-31 14:51   ` Pablo Rodriguez
  2017-05-31 16:53     ` Pablo Rodriguez
  2017-05-31 16:57     ` Hans Hagen
  0 siblings, 2 replies; 6+ messages in thread
From: Pablo Rodriguez @ 2017-05-31 14:51 UTC (permalink / raw)
  To: ntg-context

On 05/31/2017 11:03 AM, MF wrote:
> if tex.modes['specialmode'] then
>     context('I’m special.')
> end
>  
> Best greetings,
> Massi
> 
>> Hi, this should be easy:
>>
>> How can I access ConTeXt’s modes in Lua? Is it any different with
>> language modes (*en)?

This is the way to detect system modes, but I don’t know how to do it
for \mainlanguage (**en).

    \mainlanguage[es]
    \starttext
    \en\startlua
    if tex.systemmodes['en'] then
        context('Language is English.')
    else
        context('Language is not English.')
    end
    context('\\par')
    if tex.modes['es'] then
        context('Main language is Spanish.')
    else
        context('Main language is not Spanish.')
    end
    \stoplua
    \stoptext

Just in case it help,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Modes in Lua
  2017-05-31 14:51   ` Pablo Rodriguez
@ 2017-05-31 16:53     ` Pablo Rodriguez
  2017-05-31 16:57     ` Hans Hagen
  1 sibling, 0 replies; 6+ messages in thread
From: Pablo Rodriguez @ 2017-05-31 16:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 05/31/2017 04:51 PM, Pablo Rodriguez wrote:
> [...]
> This is the way to detect system modes, but I don’t know how to do it
> for \mainlanguage (**en).

It was simple (not even using tex.systemmodes):

    \mainlanguage[es]
    \starttext
    \en\startlua
    if tex.modes['*en'] then
        context('Language is English.')
    else
        context('Language is not English.')
    end
    context('\\par')
    if tex.modes['**es'] then
        context('Main language is Spanish.')
    else
        context('Main language is not Spanish.')
    end
    \stoplua
    \stoptext

Just in case it helps,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Modes in Lua
  2017-05-31 14:51   ` Pablo Rodriguez
  2017-05-31 16:53     ` Pablo Rodriguez
@ 2017-05-31 16:57     ` Hans Hagen
  2017-06-01  6:03       ` Henning Hraban Ramm
  1 sibling, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2017-05-31 16:57 UTC (permalink / raw)
  To: ntg-context

On 5/31/2017 4:51 PM, Pablo Rodriguez wrote:
> On 05/31/2017 11:03 AM, MF wrote:
>> if tex.modes['specialmode'] then
>>      context('I’m special.')
>> end
>>   
>> Best greetings,
>> Massi
>>
>>> Hi, this should be easy:
>>>
>>> How can I access ConTeXt’s modes in Lua? Is it any different with
>>> language modes (*en)?
> 
> This is the way to detect system modes, but I don’t know how to do it
> for \mainlanguage (**en).
> 
>      \mainlanguage[es]
>      \starttext
>      \en\startlua
>      if tex.systemmodes['en'] then
>          context('Language is English.')
>      else
>          context('Language is not English.')
>      end
>      context('\\par')
>      if tex.modes['es'] then
>          context('Main language is Spanish.')
>      else
>          context('Main language is not Spanish.')
>      end
>      \stoplua
>      \stoptext
> 
> Just in case it help,
tex.modes['*en']
tex.modes['**en']

tex.systemmodes['en']
tex.systemmodes['*en']

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Modes in Lua
  2017-05-31 16:57     ` Hans Hagen
@ 2017-06-01  6:03       ` Henning Hraban Ramm
  0 siblings, 0 replies; 6+ messages in thread
From: Henning Hraban Ramm @ 2017-06-01  6:03 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Thank you all!

Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
GPG Key ID 1C9B22FD

Am 2017-05-31 um 18:57 schrieb Hans Hagen <pragma@wxs.nl>:

> On 5/31/2017 4:51 PM, Pablo Rodriguez wrote:
>> This is the way to detect system modes, but I don’t know how to do it
>> for \mainlanguage (**en).
>>     \mainlanguage[es]
>>     \starttext
>>     \en\startlua
>>     if tex.systemmodes['en'] then
>>         context('Language is English.')
>>     else
>>         context('Language is not English.')
>>     end
>>     context('\\par')
>>     if tex.modes['es'] then
>>         context('Main language is Spanish.')
>>     else
>>         context('Main language is not Spanish.')
>>     end
>>     \stoplua
>>     \stoptext
>> Just in case it help,
> tex.modes['*en']
> tex.modes['**en']
> 
> tex.systemmodes['en']
> tex.systemmodes['*en']
> 

___________________________________________________________________________________
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
___________________________________________________________________________________

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

end of thread, other threads:[~2017-06-01  6:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-31  7:06 Modes in Lua Henning Hraban Ramm
2017-05-31  9:03 ` MF
2017-05-31 14:51   ` Pablo Rodriguez
2017-05-31 16:53     ` Pablo Rodriguez
2017-05-31 16:57     ` Hans Hagen
2017-06-01  6:03       ` Henning Hraban Ramm

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).