[NTG-context] hyphenated url

Steffen Wolfrum context at st.estfiles.de
Sun Oct 31 10:50:23 CET 2010


Am 31.10.2010 um 07:06 schrieb Aditya Mahajan:

> On Mon, 25 Oct 2010, Steffen Wolfrum wrote:
> 
>> Hi,
>> 
>> the "%" is a frequently used character in URL.
>> But \hyphenatedurl{} can deal with it ...
>> 
>> Does someone has a fix?
>> 
>> 
>> \starttext
>> text\footnote{test \hyphenatedurl{www.test%it.com} test.} text.
>> \stoptext
> 
> This is more a proof of concept so I did not take care of the optional argument of \footnote.
> 
> \newcatcodetable \mytxtcatcodes
> \startcatcodetable \mytxtcatcodes
>   \catcode`\^^I = 10
>   \catcode`\^^M =  5
>   \catcode`\^^L =  5
>   \catcode`\    = 10
>   \catcode`\^^Z =  9
>   \catcode`\\   =  0
>   \catcode`\{   =  1
>   \catcode`\}   =  2
> \stopcatcodetable
> 
> \def\dosingleasciigroup#1%
> {\pushcatcodetable
>  \setcatcodetable \mytxtcatcodes
>  \def\next##1{#1{##1}\popcatcodetable}%
>  \next}
> 
> \def\setasciicommand#1%
> {\savenormalmeaning{#1}%
>  \def#1{\dosingleasciigroup{\csname normal\strippedcsname#1\endcsname}}}
> 
> \setasciicommand\footnote
> \setasciicommand\hyphenatedurl
> 
> \starttext
> \hyphenatedurl{http://www.google.com/some%20thing}
> test \footnote{A footnote with a \bold{url} \hyphenatedurl{http://www.google.com/some%20thing}}
> 
> \stoptext


A very nice and clean solution!

Is it also possible to adapt it to useURL?

\setasciicommand\useURL

test \useURL[one][http://www.google.com/some%20thing][][http://www.google.com/some%20thing] text


Thanks a lot,
Steffen


More information about the ntg-context mailing list