ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* context.labeltext(...)
@ 2011-07-04 15:02 Willi Egger
  2011-07-04 15:41 ` context.labeltext(...) Wolfgang Schuster
  2011-07-04 15:54 ` context.labeltext(...) luigi scarso
  0 siblings, 2 replies; 11+ messages in thread
From: Willi Egger @ 2011-07-04 15:02 UTC (permalink / raw)
  To: NTG-Context ConTeXt users

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"?

KR

Willi

___________________________________________________________________________________
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] 11+ messages in thread

* Re: context.labeltext(...)
  2011-07-04 15:02 context.labeltext(...) Willi Egger
@ 2011-07-04 15:41 ` Wolfgang Schuster
  2011-07-04 16:00   ` context.labeltext(...) Willi Egger
  2011-07-04 15:54 ` context.labeltext(...) luigi scarso
  1 sibling, 1 reply; 11+ messages in thread
From: Wolfgang Schuster @ 2011-07-04 15:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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
___________________________________________________________________________________


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

* Re: context.labeltext(...)
  2011-07-04 15:02 context.labeltext(...) Willi Egger
  2011-07-04 15:41 ` context.labeltext(...) Wolfgang Schuster
@ 2011-07-04 15:54 ` luigi scarso
  2011-07-04 16:05   ` context.labeltext(...) Willi Egger
  1 sibling, 1 reply; 11+ messages in thread
From: luigi scarso @ 2011-07-04 15:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, Jul 4, 2011 at 5:02 PM, Willi Egger <w.egger@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
___________________________________________________________________________________

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

* Re: context.labeltext(...)
  2011-07-04 15:41 ` context.labeltext(...) Wolfgang Schuster
@ 2011-07-04 16:00   ` Willi Egger
  2011-07-04 16:12     ` context.labeltext(...) Wolfgang Schuster
  0 siblings, 1 reply; 11+ messages in thread
From: Willi Egger @ 2011-07-04 16:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


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

* Re: context.labeltext(...)
  2011-07-04 15:54 ` context.labeltext(...) luigi scarso
@ 2011-07-04 16:05   ` Willi Egger
  2011-07-04 16:14     ` context.labeltext(...) Wolfgang Schuster
  2011-07-04 16:20     ` context.labeltext(...) luigi scarso
  0 siblings, 2 replies; 11+ messages in thread
From: Willi Egger @ 2011-07-04 16:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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.egger@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
___________________________________________________________________________________


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

* Re: context.labeltext(...)
  2011-07-04 16:00   ` context.labeltext(...) Willi Egger
@ 2011-07-04 16:12     ` Wolfgang Schuster
  0 siblings, 0 replies; 11+ messages in thread
From: Wolfgang Schuster @ 2011-07-04 16:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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
___________________________________________________________________________________


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

* Re: context.labeltext(...)
  2011-07-04 16:05   ` context.labeltext(...) Willi Egger
@ 2011-07-04 16:14     ` Wolfgang Schuster
  2011-07-04 16:20     ` context.labeltext(...) luigi scarso
  1 sibling, 0 replies; 11+ messages in thread
From: Wolfgang Schuster @ 2011-07-04 16:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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
___________________________________________________________________________________


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

* Re: context.labeltext(...)
  2011-07-04 16:05   ` context.labeltext(...) Willi Egger
  2011-07-04 16:14     ` context.labeltext(...) Wolfgang Schuster
@ 2011-07-04 16:20     ` luigi scarso
  2011-07-04 16:53       ` context.labeltext(...) Khaled Hosny
  1 sibling, 1 reply; 11+ messages in thread
From: luigi scarso @ 2011-07-04 16:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, Jul 4, 2011 at 6:05 PM, Willi Egger <w.egger@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
___________________________________________________________________________________


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

* Re: context.labeltext(...)
  2011-07-04 16:20     ` context.labeltext(...) luigi scarso
@ 2011-07-04 16:53       ` Khaled Hosny
  2011-07-04 17:02         ` context.labeltext(...) Wolfgang Schuster
  2011-07-05  7:22         ` context.labeltext(...) Hans Hagen
  0 siblings, 2 replies; 11+ messages in thread
From: Khaled Hosny @ 2011-07-04 16:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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.egger@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
___________________________________________________________________________________


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

* Re: context.labeltext(...)
  2011-07-04 16:53       ` context.labeltext(...) Khaled Hosny
@ 2011-07-04 17:02         ` Wolfgang Schuster
  2011-07-05  7:22         ` context.labeltext(...) Hans Hagen
  1 sibling, 0 replies; 11+ messages in thread
From: Wolfgang Schuster @ 2011-07-04 17:02 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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.egger@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
___________________________________________________________________________________


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

* Re: context.labeltext(...)
  2011-07-04 16:53       ` context.labeltext(...) Khaled Hosny
  2011-07-04 17:02         ` context.labeltext(...) Wolfgang Schuster
@ 2011-07-05  7:22         ` Hans Hagen
  1 sibling, 0 replies; 11+ messages in thread
From: Hans Hagen @ 2011-07-05  7:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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 Egger<w.egger@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
___________________________________________________________________________________


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

end of thread, other threads:[~2011-07-05  7:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-04 15:02 context.labeltext(...) Willi Egger
2011-07-04 15:41 ` context.labeltext(...) Wolfgang Schuster
2011-07-04 16:00   ` context.labeltext(...) Willi Egger
2011-07-04 16:12     ` context.labeltext(...) Wolfgang Schuster
2011-07-04 15:54 ` context.labeltext(...) luigi scarso
2011-07-04 16:05   ` context.labeltext(...) Willi Egger
2011-07-04 16:14     ` context.labeltext(...) Wolfgang Schuster
2011-07-04 16:20     ` context.labeltext(...) luigi scarso
2011-07-04 16:53       ` context.labeltext(...) Khaled Hosny
2011-07-04 17:02         ` context.labeltext(...) Wolfgang Schuster
2011-07-05  7:22         ` context.labeltext(...) 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).