* deeptextcommand and firstcharacter
@ 2013-09-21 5:50 Thangalin
2013-09-21 9:56 ` Hans Hagen
0 siblings, 1 reply; 9+ messages in thread
From: Thangalin @ 2013-09-21 5:50 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 302 bytes --]
Hi,
The attached file does not compile in ConTeXt.
However, if the \placeindex is substituted for \completeindex, then the
document compiles.
Any idea how to use a deeptextcommand and firstcharacter as shown in the
attachment while also using the firstcharacter macro?
Thank you.
Kindest regards.
[-- Attachment #1.2: Type: text/html, Size: 426 bytes --]
[-- Attachment #2: ex.tex --]
[-- Type: application/x-tex, Size: 784 bytes --]
[-- Attachment #3: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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] 9+ messages in thread
* Re: deeptextcommand and firstcharacter
2013-09-21 5:50 deeptextcommand and firstcharacter Thangalin
@ 2013-09-21 9:56 ` Hans Hagen
2013-09-21 17:11 ` Thangalin
0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2013-09-21 9:56 UTC (permalink / raw)
To: ntg-context
On 9/21/2013 7:50 AM, Thangalin wrote:
> Hi,
>
> The attached file does not compile in ConTeXt.
>
> However, if the \placeindex is substituted for \completeindex, then the
> document compiles.
>
> Any idea how to use a deeptextcommand and firstcharacter as shown in the
> attachment while also using the firstcharacter macro?
this way of applying something to a first character won't work (as it
assume real simple arguments)
so, the next beta has: \applytofirstcharacter
\defineframed[ChapterFramed][location=low,background=color,backgroundcolor=red,frame=off]
\setuphead[chapter][deeptextcommand=\applytofirstcharacter\ChapterFramed]
probaly a better interface is possible but it's seldom used so ... upto
you to wikify this!
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] 9+ messages in thread
* Re: deeptextcommand and firstcharacter
2013-09-21 9:56 ` Hans Hagen
@ 2013-09-21 17:11 ` Thangalin
2013-09-21 17:13 ` Thangalin
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Thangalin @ 2013-09-21 17:11 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 421 bytes --]
Hi,
Most programming languages allow extraction of a character or substring
from a string. For example, if I wanted to stylize the word Index:
*I...* Index *...X*
It would be handy to do something like:
\bold{\getcharacter[1]{#!}}... #1
...\bold{\getcharacter[\stringlength{#!}]}
That is a much more flexible solution than only providing a mechanism to
get the first character.
Is this possible?
Kind regards.
[-- Attachment #1.2: Type: text/html, Size: 616 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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] 9+ messages in thread
* Re: deeptextcommand and firstcharacter
2013-09-21 17:11 ` Thangalin
@ 2013-09-21 17:13 ` Thangalin
2013-09-21 17:43 ` Wolfgang Schuster
2013-09-21 20:04 ` Hans Hagen
2 siblings, 0 replies; 9+ messages in thread
From: Thangalin @ 2013-09-21 17:13 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 126 bytes --]
Sorry, I missed a {#1}:
\bold{\getcharacter[1]{#1}}... #1 ...\bold{\getcharacter[\
stringlength{#1}{#1}]}
Best regards.
[-- Attachment #1.2: Type: text/html, Size: 177 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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] 9+ messages in thread
* Re: deeptextcommand and firstcharacter
2013-09-21 17:11 ` Thangalin
2013-09-21 17:13 ` Thangalin
@ 2013-09-21 17:43 ` Wolfgang Schuster
2013-09-21 18:46 ` Thangalin
2013-09-21 20:04 ` Hans Hagen
2 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2013-09-21 17:43 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 728 bytes --]
Am 21.09.2013 um 19:11 schrieb Thangalin <thangalin@gmail.com>:
> Hi,
>
> Most programming languages allow extraction of a character or substring from a string. For example, if I wanted to stylize the word Index:
>
> I... Index ...X
>
> It would be handy to do something like:
>
> \bold{\getcharacter[1]{#!}}... #1 ...\bold{\getcharacter[\stringlength{#!}]}
>
> That is a much more flexible solution than only providing a mechanism to get the first character.
>
> Is this possible?
You can use Lua!
\starttext
\cldcontext{string.sub("A short example text!",0,1)}
\cldcontext{string.sub("A short example text!",3,7)}
\cldcontext{string.sub("A short example text!",-5)}
\stoptext
Wolfgang
[-- Attachment #1.2: Type: text/html, Size: 1344 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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] 9+ messages in thread
* Re: deeptextcommand and firstcharacter
2013-09-21 17:43 ` Wolfgang Schuster
@ 2013-09-21 18:46 ` Thangalin
2013-09-21 18:48 ` Thangalin
2013-09-21 18:55 ` Wolfgang Schuster
0 siblings, 2 replies; 9+ messages in thread
From: Thangalin @ 2013-09-21 18:46 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 742 bytes --]
Hi, Wolfgang.
I tried dropping in the Lua code, but it does not extract the text:
\define[1]\StyleChapter{%
\StyleChapterFramed{%
\framed[align=right, frame=off]{%
\startoverlay
\color[ColourSecondaryLightest]{%
\cldcontext{string.sub(#1,0,1)}
}
\vskip-1.9em\hskip1.2em#1
\stopoverlay
}
}
}
! LuaTeX error [string "\directlua "]:1: bad argument #1 to 'sub' (string
expected, got nil)
I've tried a few variations:
\directlua{string.sub(tex.sprint("\luatexluaescapestring{#1}") }
\directlua{string.sub("\luatexluaescapestring{#1}",0,1)}
\directlua{string.sub(tex.sprint("#1"),0,1)}
\cldcontext{string.sub(tex.sprint("#1"),0,1)}
Any ideas?
[-- Attachment #1.2: Type: text/html, Size: 975 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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] 9+ messages in thread
* Re: deeptextcommand and firstcharacter
2013-09-21 18:46 ` Thangalin
@ 2013-09-21 18:48 ` Thangalin
2013-09-21 18:55 ` Wolfgang Schuster
1 sibling, 0 replies; 9+ messages in thread
From: Thangalin @ 2013-09-21 18:48 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 112 bytes --]
Ah, I think this does it:
\cldcontext{string.sub("#1",0,1)}%
Automatically expands the macro. Nice.
[-- Attachment #1.2: Type: text/html, Size: 182 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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] 9+ messages in thread
* Re: deeptextcommand and firstcharacter
2013-09-21 18:46 ` Thangalin
2013-09-21 18:48 ` Thangalin
@ 2013-09-21 18:55 ` Wolfgang Schuster
1 sibling, 0 replies; 9+ messages in thread
From: Wolfgang Schuster @ 2013-09-21 18:55 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 21.09.2013 um 20:46 schrieb Thangalin <thangalin@gmail.com>:
> Hi, Wolfgang.
>
> I tried dropping in the Lua code, but it does not extract the text:
>
> \define[1]\StyleChapter{%
> \StyleChapterFramed{%
> \framed[align=right, frame=off]{%
> \startoverlay
> \color[ColourSecondaryLightest]{%
> \cldcontext{string.sub(#1,0,1)}
\cldcontext{string.sub("#1",0,1)}%
> }
> \vskip-1.9em\hskip1.2em#1
> \stopoverlay
> }
> }
> }
When this doesn’t help you have to provide a complete minimal example.
> ! LuaTeX error [string "\directlua "]:1: bad argument #1 to 'sub' (string expected, got nil)
>
> I've tried a few variations:
>
> \directlua{string.sub(tex.sprint("\luatexluaescapestring{#1}") }
> \directlua{string.sub("\luatexluaescapestring{#1}",0,1)}
> \directlua{string.sub(tex.sprint("#1"),0,1)}
> \cldcontext{string.sub(tex.sprint("#1"),0,1)}
1. You have to use string.sub in the parameters of tex.sprint.
2. ConTeXt uses \luaescapestring.
3. We use in ConTeXt \ctxlua instead of \directlua.
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] 9+ messages in thread
* Re: deeptextcommand and firstcharacter
2013-09-21 17:11 ` Thangalin
2013-09-21 17:13 ` Thangalin
2013-09-21 17:43 ` Wolfgang Schuster
@ 2013-09-21 20:04 ` Hans Hagen
2 siblings, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2013-09-21 20:04 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 9/21/2013 7:11 PM, Thangalin wrote:
> Hi,
>
> Most programming languages allow extraction of a character or substring
> from a string. For example, if I wanted to stylize the word Index:
>
> *I...* Index *...X*
>
> It would be handy to do something like:
>
> \bold{\getcharacter[1]{#!}}... #1
> ...\bold{\getcharacter[\stringlength{#!}]}
tex is macro language so that would not work .. of course I can provide
something more clever than the previous hack but not this week (it's not
too complex but i need to fool the font system and of course one might
wonder if such features make any typographical sense at all esp in
automated document processing)
> That is a much more flexible solution than only providing a mechanism to
> get the first character.
in this case #1 == \headtext{#1} so you cannot easily do such things
without know what you deal with
-----------------------------------------------------------------
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] 9+ messages in thread
end of thread, other threads:[~2013-09-21 20:04 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-21 5:50 deeptextcommand and firstcharacter Thangalin
2013-09-21 9:56 ` Hans Hagen
2013-09-21 17:11 ` Thangalin
2013-09-21 17:13 ` Thangalin
2013-09-21 17:43 ` Wolfgang Schuster
2013-09-21 18:46 ` Thangalin
2013-09-21 18:48 ` Thangalin
2013-09-21 18:55 ` Wolfgang Schuster
2013-09-21 20:04 ` 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).