From: Aditya Mahajan <adityam@umich.edu>
To: Steffen Wolfrum <context@st.estfiles.de>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: hyphenated url
Date: Sun, 31 Oct 2010 16:25:47 -0400 (EDT) [thread overview]
Message-ID: <alpine.LNX.2.01.1010311618530.13832@ybpnyubfg.ybpnyqbznva> (raw)
In-Reply-To: <FC31827A-E920-47C4-9287-8BEE605CE94D@st.estfiles.de>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 976 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/x-tex; name=test.tex, Size: 2618 bytes --]
\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
[-- Attachment #3: Type: text/plain, Size: 486 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
___________________________________________________________________________________
prev parent reply other threads:[~2010-10-31 20:25 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-25 8:25 Steffen Wolfrum
2010-10-25 9:16 ` Philipp Gesang
2010-10-25 9:39 ` Steffen Wolfrum
2010-10-25 9:50 ` Philipp Gesang
2010-10-25 10:05 ` Steffen Wolfrum
2010-10-25 10:26 ` Philipp Gesang
2010-10-25 10:45 ` Steffen Wolfrum
2010-10-25 13:12 ` Philipp Gesang
2010-10-25 15:52 ` Steffen Wolfrum
2010-10-27 21:30 ` Peter Münster
2010-10-27 20:28 ` Steffen Wolfrum
2010-10-27 22:05 ` Philipp Gesang
2010-10-28 6:46 ` Steffen Wolfrum
2010-10-28 7:38 ` Peter Münster
2010-10-28 8:03 ` Philipp Gesang
2010-10-25 10:06 ` Steffen Wolfrum
2010-10-25 17:30 ` Aditya Mahajan
2010-10-25 20:25 ` Steffen Wolfrum
2010-10-25 21:00 ` Aditya Mahajan
2010-10-25 21:47 ` Wolfgang Schuster
2010-10-25 22:49 ` Philipp Gesang
2010-10-26 8:57 ` Steffen Wolfrum
2010-10-27 10:35 ` Steffen Wolfrum
2010-10-27 12:43 ` Wolfgang Schuster
2010-10-27 14:56 ` Peter Münster
2010-10-27 15:11 ` Steffen Wolfrum
2010-10-27 15:59 ` Wolfgang Schuster
2010-10-27 16:20 ` Thomas A. Schmitz
2010-10-27 17:08 ` Peter Münster
2010-10-27 17:22 ` Peter Münster
2010-10-27 18:31 ` Aditya Mahajan
2010-10-27 18:49 ` Peter Münster
2010-10-28 9:03 ` Hans Hagen
2010-10-28 9:53 ` Peter Münster
2010-10-28 11:02 ` Khaled Hosny
2010-10-28 11:52 ` Peter Münster
2010-10-28 12:59 ` Wolfgang Schuster
2010-10-28 6:53 ` Taco Hoekwater
2010-10-28 12:06 ` hyphenated url (SOLVED) Steffen Wolfrum
2010-10-28 12:50 ` hyphenated url Wolfgang Schuster
2010-10-31 6:06 ` Aditya Mahajan
2010-10-31 9:50 ` Steffen Wolfrum
[not found] ` <FC31827A-E920-47C4-9287-8BEE605CE94D@st.estfiles.de>
2010-10-31 20:25 ` Aditya Mahajan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.01.1010311618530.13832@ybpnyubfg.ybpnyqbznva \
--to=adityam@umich.edu \
--cc=context@st.estfiles.de \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).