* labeltext via lua
@ 2017-02-16 10:36 Andreas Schneider
2017-02-16 10:50 ` Hans Hagen
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schneider @ 2017-02-16 10:36 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hello,
if I define a labeltext via \setuplabeltext[en][test=Something], how can
I access that value via lua?
(context.labeltext obviously prints the content, but doesn't allow me to
use it in lua).
As a related side-request: how can I fix expansion in cases like this:
\startsectionlevel[title=\labeltext{test}] ... this causes the bookmark
to read "test" instead of "Something". \expandafter\startsectionlevel...
didn't cut it.
Best regards
Andreas
___________________________________________________________________________________
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] 7+ messages in thread
* Re: labeltext via lua
2017-02-16 10:36 labeltext via lua Andreas Schneider
@ 2017-02-16 10:50 ` Hans Hagen
2017-02-16 13:12 ` Andreas Schneider
0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2017-02-16 10:50 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 2/16/2017 11:36 AM, Andreas Schneider wrote:
> Hello,
>
> if I define a labeltext via \setuplabeltext[en][test=Something], how can
> I access that value via lua?
> (context.labeltext obviously prints the content, but doesn't allow me to
> use it in lua).
languages.data.labels.texts.appendix.labels.en
look into lang-txt.lua
> As a related side-request: how can I fix expansion in cases like this:
> \startsectionlevel[title=\labeltext{test}] ... this causes the bookmark
> to read "test" instead of "Something". \expandafter\startsectionlevel...
> didn't cut it.
>
> Best regards
> Andreas
> ___________________________________________________________________________________
>
> 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
> ___________________________________________________________________________________
--
-----------------------------------------------------------------
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] 7+ messages in thread
* Re: labeltext via lua
2017-02-16 10:50 ` Hans Hagen
@ 2017-02-16 13:12 ` Andreas Schneider
2017-02-16 13:43 ` Hans Hagen
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schneider @ 2017-02-16 13:12 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 2017-02-16 11:50, schrieb Hans Hagen:
> languages.data.labels.texts.appendix.labels.en
>
> look into lang-txt.lua
Hello Hans,
I already looked into this and even printed the whole languages.data
table at runtime, but didn't find my keys in there.
Here is an example which apparently doesn't work (or I'm still
overlooking something):
```
\mainlanguage[de]
\setuplabeltext[de][Page=Seite]
\setuplabeltext[en][Page=Page]
\starttext
\startluacode
local language = languages.numbers[tex.getcount("mainlanguagenumber")]
local lbl = languages.data.labels.texts["Page"]
local text
if lbl == nil then
text = "[NOT FOUND]"
else
text = lbl.labels[language]
end
context("For language "..language.." we get "..text)
\stopluacode
\stoptext
```
Thank you very much!
Best regards
Andreas
___________________________________________________________________________________
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] 7+ messages in thread
* Re: labeltext via lua
2017-02-16 13:12 ` Andreas Schneider
@ 2017-02-16 13:43 ` Hans Hagen
2017-02-16 14:06 ` Andreas Schneider
0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2017-02-16 13:43 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 2/16/2017 2:12 PM, Andreas Schneider wrote:
> Am 2017-02-16 11:50, schrieb Hans Hagen:
>> languages.data.labels.texts.appendix.labels.en
>>
>> look into lang-txt.lua
>
> Hello Hans,
>
> I already looked into this and even printed the whole languages.data
> table at runtime, but didn't find my keys in there.
>
> Here is an example which apparently doesn't work (or I'm still
> overlooking something):
>
> ```
> \mainlanguage[de]
>
> \setuplabeltext[de][Page=Seite]
> \setuplabeltext[en][Page=Page]
>
> \starttext
>
> \startluacode
> local language = languages.numbers[tex.getcount("mainlanguagenumber")]
> local lbl = languages.data.labels.texts["Page"]
> local text
> if lbl == nil then
> text = "[NOT FOUND]"
> else
> text = lbl.labels[language]
> end
> context("For language "..language.." we get "..text)
> \stopluacode
>
> \stoptext
because additional ones live at the tex end
why not use context.labeltext etc?
Hans
-----------------------------------------------------------------
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] 7+ messages in thread
* Re: labeltext via lua
2017-02-16 13:43 ` Hans Hagen
@ 2017-02-16 14:06 ` Andreas Schneider
2017-02-16 16:13 ` Hans Hagen
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schneider @ 2017-02-16 14:06 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 2017-02-16 14:43, schrieb Hans Hagen:
>
> because additional ones live at the tex end
>
> why not use context.labeltext etc?
>
> Hans
`context.labeltext` would immediately print the label, so I cannot use
the value within lua. My workaround would be a crossover between lua and
tex, but that results in the bookmark having the wrong label:
\setuplabeltext[en][test=Something]
\startluacode
context.startsectionlevel{title="\\labeltext[test]"}
-- ...
context.stopsectionlevel()
\stopluacode
The title correctly reads "Something", but the bookmark in the PDF
viewer shows "test".
Best regards,
Andreas
___________________________________________________________________________________
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] 7+ messages in thread
* Re: labeltext via lua
2017-02-16 14:06 ` Andreas Schneider
@ 2017-02-16 16:13 ` Hans Hagen
2017-02-17 15:44 ` Andreas Schneider
0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2017-02-16 16:13 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 2/16/2017 3:06 PM, Andreas Schneider wrote:
> Am 2017-02-16 14:43, schrieb Hans Hagen:
>>
>> because additional ones live at the tex end
>>
>> why not use context.labeltext etc?
>>
>> Hans
>
> `context.labeltext` would immediately print the label, so I cannot use
> the value within lua. My workaround would be a crossover between lua and
> tex, but that results in the bookmark having the wrong label:
>
> \setuplabeltext[en][test=Something]
> \startluacode
> context.startsectionlevel{title="\\labeltext[test]"}
> -- ...
> context.stopsectionlevel()
> \stopluacode
>
> The title correctly reads "Something", but the bookmark in the PDF
> viewer shows "test".
also with this?
\enabledirectives[references.bookmarks.preroll]
-----------------------------------------------------------------
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] 7+ messages in thread
* Re: labeltext via lua
2017-02-16 16:13 ` Hans Hagen
@ 2017-02-17 15:44 ` Andreas Schneider
0 siblings, 0 replies; 7+ messages in thread
From: Andreas Schneider @ 2017-02-17 15:44 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 2017-02-16 17:13, schrieb Hans Hagen:
> On 2/16/2017 3:06 PM, Andreas Schneider wrote:
>> `context.labeltext` would immediately print the label, so I cannot use
>> the value within lua. My workaround would be a crossover between lua
>> and
>> tex, but that results in the bookmark having the wrong label:
>>
>> \setuplabeltext[en][test=Something]
>> \startluacode
>> context.startsectionlevel{title="\\labeltext[test]"}
>> -- ...
>> context.stopsectionlevel()
>> \stopluacode
>>
>> The title correctly reads "Something", but the bookmark in the PDF
>> viewer shows "test".
>
> also with this?
>
> \enabledirectives[references.bookmarks.preroll]
Nope, that works :-)
I certainly can live with that solution. Is there reason to not have
this enabled by default? (I know, there is a slight performance penalty,
but it seems strange that the bookmark defaults to the title, while the
title gets expanded but the bookmark doesn't. In any case, I will try to
figure out where in the wiki this information best belongs to.)
Thank you very much!
Andreas
___________________________________________________________________________________
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] 7+ messages in thread
end of thread, other threads:[~2017-02-17 15:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16 10:36 labeltext via lua Andreas Schneider
2017-02-16 10:50 ` Hans Hagen
2017-02-16 13:12 ` Andreas Schneider
2017-02-16 13:43 ` Hans Hagen
2017-02-16 14:06 ` Andreas Schneider
2017-02-16 16:13 ` Hans Hagen
2017-02-17 15:44 ` Andreas Schneider
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).