Re: [NTG-context] context.labeltext(...)
On 4-7-2011 6:53, Khaled Hosny wrote: On Mon, Jul 04, 2011 at 06:20:37PM +0200, luigi scarso wrote: On Mon, Jul 4, 2011 at 6:05 PM, Willi Eggerw.eg...@boede.nl wrote: Hi Luigi, hm, did not know this one. Still I can not see that this is going to fit in my situation. I refer to may other mail I sent a minute ago. - The thing is, that the document I am building should be multilingual and therefore I need at the lua-end the lowercase text which should be made first-letter-uppercase at the moment it is typeset. In the first email you talked about a generic label. Uppercase /lower case are unicode sensitive; as Wolfgang already wrote string.lower(..) and string.upper(..) can help , but they depend on unicode.utf8.lower()/upper() are a better choice for non-ASCII text. (I still believe the default string manipulation functions should be Unicode aware by default, and the 8-bit ones should be an alternative, not the other way around). you can just rename/remap them if needed; swapping stock lua and unicode functions would render regular lua manuals/tutorials useless and also make lua 8-bit dirty (local lower = utf.lower at the top of a file is enough to get what you want) 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 ___
Re: [NTG-context] context.labeltext(...)
Am 04.07.2011 um 17:02 schrieb Willi Egger: Hi all, experimenting with context.labeltext... My question is how can I tweak the context.labeltext(text) command at the lua-side to make ConTeXt to typeset the labeltext starting with an uppercase letter? e.g. if text contains january to display January? You can access constants and variables with “interfaces.constants” and “interfaces.variables”: \starttext \startluacode context.labeltext(%s,interfaces.variables.january) \stopluacode \stoptext Wolfgang ___ 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 ___
Re: [NTG-context] context.labeltext(...)
On Mon, Jul 4, 2011 at 5:02 PM, Willi Egger w.eg...@boede.nl wrote: Hi all, experimenting with context.labeltext... My question is how can I tweak the context.labeltext(text) command at the lua-side to make ConTeXt to typeset the labeltext starting with an uppercase letter? e.g. if text contains january to display January? And if text is foo you want Foo ? In char-ini.lua, among others, there is function characters.upper(str) local new, n = { }, 0 for u in utfvalues(str) do n = n + 1 new[n] = ucchars[u] end return concat(new) end The idea is to take the first character from characters.upper(str), and all but not first from str and then join them using concat. -- luigi ___ 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 ___
Re: [NTG-context] context.labeltext(...)
Hello Wolfgang, thanks for your reply. I see that I was not quite clear with my explanation. The situation is the following: in a function which runs over the months of the year at a certain moment I need to insert at the ConTeXt side the monthname. However the monthname returned by the following statement is all lowercase, which is ok for the translation of the labeltext. In the document however I need the labeltext in with a starting uppercase letter. The question is therefor how to achieve this uppercase first letter \startluacode function monthtable(month) local direct = true local nofdays = converters.nofdays(os.date(%Y),month,direct) direct = false local d = os.date(%B,os.time({year=os.date(%Y),month= month,day=1})) context.bTABLE({setups=table:month}) context.bTR({align=middle}) context.bTD() context.labeltext(d) -- context.labeltext(%s,interfaces.variables.january) context.eTD() context.eTR() for i = 1, 31 do context.bTR() context.bTD() if i nofdays +1 then context(i) else context() end context.eTD() context.eTR() end context.eTABLE() end \stopluacode \def\maandtabel#1{\ctxlua{monthtable(#1)}} \starttext \maandtabel{2) \stoptext Kind regards Willi On 4 Jul 2011, at 17:41, Wolfgang Schuster wrote: context.labeltext(%s,interfaces.variables.january) ___ 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 ___
Re: [NTG-context] context.labeltext(...)
Hi Luigi, hm, did not know this one. Still I can not see that this is going to fit in my situation. I refer to may other mail I sent a minute ago. - The thing is, that the document I am building should be multilingual and therefore I need at the lua-end the lowercase text which should be made first-letter-uppercase at the moment it is typeset. Thanks Willi On 4 Jul 2011, at 17:54, luigi scarso wrote: On Mon, Jul 4, 2011 at 5:02 PM, Willi Egger w.eg...@boede.nl wrote: Hi all, experimenting with context.labeltext... My question is how can I tweak the context.labeltext(text) command at the lua-side to make ConTeXt to typeset the labeltext starting with an uppercase letter? e.g. if text contains january to display January? And if text is foo you want Foo ? In char-ini.lua, among others, there is function characters.upper(str) local new, n = { }, 0 for u in utfvalues(str) do n = n + 1 new[n] = ucchars[u] end return concat(new) end The idea is to take the first character from characters.upper(str), and all but not first from str and then join them using concat. -- luigi ___ 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 ___ ___ 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 ___
Re: [NTG-context] context.labeltext(...)
Am 04.07.2011 um 18:00 schrieb Willi Egger: Hello Wolfgang, thanks for your reply. I see that I was not quite clear with my explanation. The situation is the following: in a function which runs over the months of the year at a certain moment I need to insert at the ConTeXt side the monthname. However the monthname returned by the following statement is all lowercase, which is ok for the translation of the labeltext. In the document however I need the labeltext in with a starting uppercase letter. The question is therefor how to achieve this uppercase first letter ??? The first letter in the month name you get from Lua is uppercase as you can see in the output from your example. To make the first letter uppercase at the TeX side you can use “context.Word(...)”. Wolfgang ___ 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 ___
Re: [NTG-context] context.labeltext(...)
Am 04.07.2011 um 18:05 schrieb Willi Egger: Hi Luigi, hm, did not know this one. Still I can not see that this is going to fit in my situation. I refer to may other mail I sent a minute ago. - The thing is, that the document I am building should be multilingual and therefore I need at the lua-end the lowercase text which should be made first-letter-uppercase at the moment it is typeset. context.labeltext(%s,interfaces.variables[string.lower(d)]) Wolfgang ___ 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 ___
Re: [NTG-context] context.labeltext(...)
On Mon, Jul 4, 2011 at 6:05 PM, Willi Egger w.eg...@boede.nl wrote: Hi Luigi, hm, did not know this one. Still I can not see that this is going to fit in my situation. I refer to may other mail I sent a minute ago. - The thing is, that the document I am building should be multilingual and therefore I need at the lua-end the lowercase text which should be made first-letter-uppercase at the moment it is typeset. In the first email you talked about a generic label. Uppercase /lower case are unicode sensitive; as Wolfgang already wrote string.lower(..) and string.upper(..) can help , but they depend on the current locale which can confuse things. So it's better to look at char-ini.lua . -- luigi ___ 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 ___
Re: [NTG-context] context.labeltext(...)
On Mon, Jul 04, 2011 at 06:20:37PM +0200, luigi scarso wrote: On Mon, Jul 4, 2011 at 6:05 PM, Willi Egger w.eg...@boede.nl wrote: Hi Luigi, hm, did not know this one. Still I can not see that this is going to fit in my situation. I refer to may other mail I sent a minute ago. - The thing is, that the document I am building should be multilingual and therefore I need at the lua-end the lowercase text which should be made first-letter-uppercase at the moment it is typeset. In the first email you talked about a generic label. Uppercase /lower case are unicode sensitive; as Wolfgang already wrote string.lower(..) and string.upper(..) can help , but they depend on unicode.utf8.lower()/upper() are a better choice for non-ASCII text. (I still believe the default string manipulation functions should be Unicode aware by default, and the 8-bit ones should be an alternative, not the other way around). Regards, Khaled -- Khaled Hosny Egyptian Arab ___ 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 ___
Re: [NTG-context] context.labeltext(...)
Am 04.07.2011 um 18:53 schrieb Khaled Hosny: On Mon, Jul 04, 2011 at 06:20:37PM +0200, luigi scarso wrote: On Mon, Jul 4, 2011 at 6:05 PM, Willi Egger w.eg...@boede.nl wrote: Hi Luigi, hm, did not know this one. Still I can not see that this is going to fit in my situation. I refer to may other mail I sent a minute ago. - The thing is, that the document I am building should be multilingual and therefore I need at the lua-end the lowercase text which should be made first-letter-uppercase at the moment it is typeset. In the first email you talked about a generic label. Uppercase /lower case are unicode sensitive; as Wolfgang already wrote string.lower(..) and string.upper(..) can help , but they depend on unicode.utf8.lower()/upper() are a better choice for non-ASCII text. (I still believe the default string manipulation functions should be Unicode aware by default, and the 8-bit ones should be an alternative, not the other way around). ConTeXt provides also characters.upper()/lower(). Wolfgang ___ 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 ___