From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/14621 Path: main.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: Hyphenation of URLs with and without interaction Date: Sun, 25 Jan 2004 14:30:11 +0100 Sender: ntg-context-admin@ntg.nl Message-ID: <6.0.1.1.2.20040125140153.01e28ec0@localhost> References: <20040123105933.GA15024@physik.fu-berlin.de> Reply-To: ntg-context@ntg.nl NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Trace: sea.gmane.org 1075054964 30662 80.91.224.253 (25 Jan 2004 18:22:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 25 Jan 2004 18:22:44 +0000 (UTC) Original-X-From: ntg-context-admin@ntg.nl Sun Jan 25 19:22:35 2004 Return-path: Original-Received: from ref.vet.uu.nl ([131.211.172.13] helo=ref.ntg.nl) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Akou3-00030w-00 for ; Sun, 25 Jan 2004 19:22:35 +0100 Original-Received: from ref.ntg.nl (localhost.localdomain [127.0.0.1]) by ref.ntg.nl (Postfix) with ESMTP id 92F3610B75; Sun, 25 Jan 2004 19:21:31 +0100 (MET) Original-Received: from mail.solcon.net (mail.solcon.net [212.45.33.5]) by ref.ntg.nl (Postfix) with ESMTP id 9B6DA10B2D for ; Sun, 25 Jan 2004 19:20:06 +0100 (MET) Original-Received: from server-1.pragma-net.nl (dsl-212-84-128-085.solcon.nl [212.84.128.85]) by mail.solcon.net (8.11.6/8.9.3) with ESMTP id i0PIL0631423 for ; Sun, 25 Jan 2004 19:21:00 +0100 Original-Received: by server-1.pragma-net.nl (Postfix, from userid 65534) id C19922EB42; Sun, 25 Jan 2004 19:21:07 +0100 (CET) Original-Received: from laptop-3.wxs.nl (unknown [10.100.1.1]) by server-1.pragma-net.nl (Postfix) with ESMTP id 4794E179E2 for ; Sun, 25 Jan 2004 18:20:58 +0000 (UTC) X-Sender: hagen-mail@localhost X-Mailer: QUALCOMM Windows Eudora Version 6.0.1.1 Original-To: ntg-context@ntg.nl In-Reply-To: <20040123105933.GA15024@physik.fu-berlin.de> Original-References: <20040123105933.GA15024@physik.fu-berlin.de> Errors-To: ntg-context-admin@ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.0.13 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.comp.tex.context:14621 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:14621 At 11:59 23/01/2004, you wrote: >Hello, > >If you run the test case below, once with and once without >\statupinteraction[state=start], you realize that this influences the >hyphenation. > >Using interaction, the URL is only hyphenated at '/', '.' etc. >Using no interaction, also the words are hyphenated. > >How can I get also hyphenated words with interaction enabled? > >----------------------------------------------------------- >\showframe >\setupinteraction[state=start] >\def\gotoURL#1{\useURL[foo][#1]\goto{\url[foo]}[url(foo)]} > >\starttext > >\hskip5cm\gotoURL{http://www.physik.fu-berlin.de/SomeVeryVeryVeryLongDirectory/And/AQuiteLongFileName.html} > >\stoptext >----------------------------------------------------------- in context, hyphenation of interactive references is a rather tricky thing; this has to do with the fact that i want comfortable clickable areas. (another reason is that it should work with several backends. Some day i may offer an alternative solution (backend dependent). In the case of url's it's even more tricky since one cannot for instance use hyphenation patterns for it, so we have to rely on parsing. And, with parsing, we run into those catcode handling situations. When i have time, i'll rewrite the parser for etex (time is near that we drop tex in favor of etex) which is cleaner (but not entirely upward compatible). Now to your problem. Hyphenation is not done here and does not make sense either (mixed case) \bgroup \catcode`\~=\active \catcode`\/=\active \unexpanded\gdef\hyphenatedurl#1% {}{} handles accents {\bgroup \ifnum\hyphenpenalty<10000 \else \def\discretionary##1##2##3{##1\allowbreak##2}% \fi \obeyhyphens \def\splitbefore##1% {\setbox\scratchbox=\hbox{##1{}{}}% \ifcase\urlsplitmode \box\scratchbox \or \postwordbreak\box\scratchbox\prewordbreak \or \prewordbreak\discretionary{\box\scratchbox}{}{\box\scratchbox}\prewordbreak \else \postwordbreak\box\scratchbox\prewordbreak \fi}% \def\splitafter##1% {\ifcase\urlsplitmode ##1{}{}% \or \prewordbreak\discretionary{##1{}{}}{}{##1{}{}}\prewordbreak \or \prewordbreak\discretionary{##1{}{}}{}{##1{}{}}\prewordbreak \else \prewordbreak\discretionary{}{##1{}{}}{##1{}{}}\prewordbreak \fi}% \def\flushurl% {\savedurl\let\savedurl\empty}% \def\\% {\spliturl\#}% \let\~=\lettertilde\let~=\~% \let\/=\letterslash\let/=\/% \let\savedurl\empty \scratchcounter\zerocount \handletokens#1\with\scanurl\savedurl \egroup} \egroup \def\scanurl#1% {\advance\scratchcounter\plusone \ifx#1\~% \flushurl\splitbefore\~% \else\ifx#1\#% \flushurl\splitbefore\#% \else\ifx#1\&% \flushurl\splitbefore\&% \else\ifx#1\%% \flushurl\splitbefore\%% \else\ifx#1\_% \flushurl\splitbefore\_% \else\if\noexpand#1\relax #1% \else\ifnum\catcode`#1=8 \flushurl\splitbefore\_% \else\ifnum\catcode`#1=6 \flushurl\splitbefore\#% \else\ifnum\catcode`#1=4 \flushurl\splitbefore\&% \else\if#1\lettertilde \flushurl\splitbefore\~% \else\if#1\letterpercent \flushurl\splitbefore\%% \else\if#1\letterunderscore \flushurl\splitbefore\_% \else\if#1\letterquestionmark \flushurl\splitafter\letterquestionmark \else\if#1\letterat \flushurl\splitafter\letterat \else\if#1\letterslash \edef\savedurl{\savedurl\letterslash}% \else\if#1+% \flushurl\splitafter+% \else\if#1:% \flushurl\splitafter:% \else\if#1.% \flushurl\splitafter.% \else\if#1(% \flushurl\splitbefore(% \else\if#1)% \flushurl\splitafter)% \else \ifx\savedurl\empty\else \splitbefore\savedurl \let\savedurl\empty \fi \ifcase\urlhyphenmethod #1% \else \ifnum\scratchcounter>\plusthree % so, \http: will not break \edef\savedurl{#1}% \else #1% \fi \fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} \chardef\urlhyphenmethod=0 \setupinteraction[state=start]\showframe \def\gotoURL#1{\useURL[foo][#1][#1]\goto{\url[foo]}[url(foo)]} \starttext \chardef\urlhyphenmethod=0 \hsize1pt\gotoURL{http://www.physik.fu-berlin.de/SomeVeryVeryVeryLongDirectory/And/AQuiteLongFileName.html} \chardef\urlhyphenmethod=1 \hsize1pt\gotoURL{http://www.physik.fu-berlin.de/SomeVeryVeryVeryLongDirectory/And/AQuiteLongFileName.html} \stoptext