Re: [NTG-context] labeltext via lua

2017-02-17 Thread Andreas Schneider

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
___

Re: [NTG-context] labeltext via lua

2017-02-16 Thread Hans Hagen

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
___

Re: [NTG-context] labeltext via lua

2017-02-16 Thread Andreas Schneider

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
___

Re: [NTG-context] labeltext via lua

2017-02-16 Thread Hans Hagen

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
___

Re: [NTG-context] labeltext via lua

2017-02-16 Thread Andreas Schneider

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
___

Re: [NTG-context] labeltext via lua

2017-02-16 Thread Hans Hagen

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
___

[NTG-context] labeltext via lua

2017-02-16 Thread Andreas Schneider

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
___