On Sun, 31 Oct 2010, Steffen Wolfrum wrote:
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.
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
It starts getting more confusing...the control passes from tex to luatex
and then back to tex and at the last step ctxcatcodes are restored. I just bypassed the
whole last leg. See the attached file for a working example.
A proper fix is much more involved.
Aditya
\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\dosingleasciiargument#1%
{\pushcatcodetable
\setcatcodetable \mytxtcatcodes
\def\next[##1]{#1[##1]\popcatcodetable}%
\dosingleargument\next}
\def\doquadrupleasciiargument#1%
{\pushcatcodetable
\setcatcodetable \mytxtcatcodes
\def\next[##1][##2][##3][##4]{#1[##1][##2][##3][##4]\popcatcodetable}%
\doquadrupleargument\next}
\def\setasciicommand#1#2%arguments cs
{\savenormalmeaning{#2}%
\def#2{#1{\csname normal\strippedcsname#2\endcsname}}}
\setasciicommand\dosingleasciigroup\footnote
\setasciicommand\dosingleasciigroup\hyphenatedurl
% This does not work... possible because the context(...) function is using
% ctxcatcodes rather than current catcodes.
%\setasciicommand\dosingleasciigroup\dofromurldescription
\setasciicommand\doquadrupleasciiargument\useURL
% Not needed
%\setasciicommand\dosingleasciiargument\from
\startluacode
local references = structures.references
references.urls = references.urls or { }
references.urls.data = references.urls.data or { }
function references.from(name)
local u = references.urls.data[name]
if u then
local url, file, description = u[1], u[2], u[3]
if description ~= "" then
-- context.dofromurldescription(description)
-- AM: Changed this
tex.sprint(tex.mytxtcatcodes, description)
-- ok
elseif file and file ~= "" then
context.dofromurlliteral(url .. "/" .. file)
else
context.dofromurlliteral(url)
end
else
local f = files[name]
if f then
local description, file = f[1], f[2]
if description ~= "" then
context.dofromfiledescription(description)
else
context.dofromfileliteral(file)
end
end
end
end
\stopluacode
\starttext
\hyphenatedurl{http://www.google.com/some%20thing}
test \footnote{A footnote with a \bold{url} \hyphenatedurl{http://www.google.com/some%20thing}}
\useURL[one][http://www.google.com/some%20thing][][http://www.google.com/some%20thing]
\from[one]
\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
___________________________________________________________________________________