On 2010-10-27 <22:28:56>, Steffen Wolfrum wrote:
> 
> Hi,
> 
> I tried an other approach: \useURL
> 
> But here the letterpercent trick doesn't work at all ... ie.
> there is no clickable link at all anymore!

Hi Steffen,

if you consider an environment-style version of ‘\useURL’
appropriate, you could hack your way through like this:

···8<····························································

\setupinteraction[state=start]

\unprotect
\newcatcodetable \urlcatcodes
\startcatcodetable \urlcatcodes
    \catcode`\^^I = 10
    \catcode`\^^M =  5
    \catcode`\^^L =  5
    \catcode`\    = 10
    \catcode`\^^Z =  9
    \catcode`\\   =  0
    \catcode`\{   =  1
    \catcode`\}   =  2
    \catcode`\$   = \@@other
    \catcode`\&   = \@@other
    \catcode`\#   = \@@other
    \catcode`\^   = \@@other
    \catcode`\_   = \@@other
    \catcode`\~   = \@@other
    \catcode`\|   = \@@other
    \catcode`\%   = \@@other
    \catcode`\*   = \@@other
\stopcatcodetable

\startluacode
function structures.references.urls.get(name,method,space)
    local u = structures.references.urls.data[name]
    if u then 
        local url, file = u[1], u[2] 
        if file and file ~= "" then 
            context("%s/%s",url,file)
        else 
            context.pushcatcodes("vrb")
            context(url)
            context.popcatcodes()
        end  
    end  
end

\stopluacode

\def\startuseURL{%
  \bgroup%
  \catcodetable \urlcatcodes
  \dodoubleempty\dostartuseURL%
}

\let\stopuseURL\relax

\def\dostartuseURL[#1][#2]#3\stopuseURL{
  \egroup
  
\ctxlua{structures.references.urls.define("#1",string.strip(\!!bs\detokenize{#3}\!!es),"",\!!bs\detokenize{#2}\!!es)}
}

% Usage example here:

\startuseURL[anotherurl][urldescription]
http://test%it.example.com
\stopuseURL

\starttext

\from[anotherurl]\par
\url[anotherurl]\par

Test.\footnote{\url[anotherurl]}

\stoptext

···8<····························································

This deviates from standard ‘\useURL’ in the order of parameters:

  \startuseURL[#1][#2]
  #3
  \stopuseURL

where #1 is the id, #2 is the display text and #3 the url itself.
This eliminates the need to resort to ‘\letterpercent’ as well
and works in footnotes.

Philipp


> 
> 
> \setupinteraction
>    [state=start]
> 
> \showframe
> 
> \starttext
> 
> \useURL[aurl]       
> [http://www.kommers.se/upload/Analysarkiv/In\letterpercent 
> English/Analyses/Woolcock\letterpercent paper\letterpercent on\letterpercent 
> impact\letterpercent of\letterpercent Lisbontreaty\letterpercent 
> on\letterpercent tradepolicy.pdf] [] 
> [http://www.kommers.se/upload/Analysarkiv/In\letterpercent 
> English/Analyses/Woolcock\letterpercent paper\letterpercent on\letterpercent 
> impact\letterpercent of\letterpercent Lisbontreaty\letterpercent 
> on\letterpercent tradepolicy.pdf] 
> 
> test \from[aurl] text
> \stoptext
> 
> 
> 
> 
> Steffen
> 
> 
> 
> 
> 
> 
> Am 25.10.2010 um 15:12 schrieb Philipp Gesang:
> 
> > On 2010-10-25 <12:45:17>, Steffen Wolfrum wrote:
> >> 
> >> Am 25.10.2010 um 12:26 schrieb Philipp Gesang:
> >>> \unexpanded\gdef\hyphenatedurl
> >>> 
> >>> Should work in footnotes. Regards, Philipp
> >> 
> >> 
> >> No, it doesn't (see below).
> >> Do you have an other idea?
> > 
> > Right; it works in footnotes but doesn’t accomplish what you
> > want. Sorry, I tried a lot but ‘\letterpercent’ is the only
> > way it works for me.
> > 
> > Concerning the urlencoding I referred to browsers automatically
> > converting raw urls, like for instance
> > 
> >  http://www.google.com/search?q=ähre
> > 
> > , which is encoded as
> > 
> >  http://www.google.com/search?q=%C3%A4hre
> > 
> > by my browser. As long as your urls mainly consist of unicode
> > strings you might not need the actual (ascii) percent sign.  In
> > this case you could be fine simply by converting strings like
> > ‘%C3%A4hre’ to ‘Ähre’, rendering urls percent-less, and rely on
> > the browsers to re-encode them on the fly. Might be a bit far
> > fetched, though.
> > 
> > Philipp
> > 
> > 
> >> 
> >> Thanks, Steffen
> >> (ConTeXt  ver: 2010.10.21)
> >> 
> >> 
> >> Runaway argument?
> >> {test \hyphenatedurl {www.test\par \stoptext \par 
> >> ! File ended while scanning use of \@@notemakedescription.
> >> 
> >> system          > error on line 0 in file : File ended while scanning use 
> >> of \@@notemakedescription ...
> >> 
> >> 
> >> \let\normalhyphenatedurl\hyphenatedurl
> >> 
> >> \bgroup
> >> 
> >> \catcode`\%=11
> >> 
> >> \unexpanded\gdef\hyphenatedurl
> >> {\bgroup
> >>  \catcode`\%=11
> >>  \expandafter\egroup
> >>  \normalhyphenatedurl}
> >> 
> >> \egroup
> >> 
> >> \setupinteraction
> >>   [state=start]
> >> 
> >> \starttext
> >> 
> >> text\footnote{test \hyphenatedurl{www.test%it.com} test.} text.
> >> 
> >> \stoptext
> >> 
> >> 
> >> 
> >> 
> >> ___________________________________________________________________________________
> >> 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
> > ___________________________________________________________________________________
> 
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

Attachment: pgpOVQOY80C9e.pgp
Description: PGP signature

___________________________________________________________________________________
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
___________________________________________________________________________________

Reply via email to