Re: [NTG-context] modifying URL wrapping rules
On 11/21/2008 2:22 AM, Hans Hagen wrote:
i leave it to others to react on the rest of your mail (some users have been tuning the mechanism too)
Hans
On 11/21/2008 9:45 AM, Steffen Wolfrum wrote:
Am 21.11.2008 um 16:35 schrieb Lars Huttar:
Hello,
Did either of you, Aditya or Steffen, have success modifying how URLs are wrapped? Did you do it by using \sethyphenatedurlbefore/etc.?
I'm trying to finish a production project and am stuck on this problem.
Thanks, Lars
Hi Lars,
... no, I am still hoping for a fix for that.
As far as I have seen also Mojca asked for "How to influence hyphenation points in URLs?" And even her got no answer! That's a bad sign ;o)
Steffen
On 11/21/2008 9:52 AM, Aditya Mahajan wrote:
No, I had a deadline and in the end, I did URL breaking by hand, using \break at appropriate places. But it was a short article (4/5 pages).
Aditya
So as far as we know, nobody has successfully used \sethyphenatedurlbefore/after/etc. to tune the url-breaking mechanism. Has anybody else on the list done this? If not, maybe the mkii implementation has never worked for that purpose... it's possible, since urls are breaking after hyphens when lang-url.mkii says to break before hyphens. If this is the case (\sethyphenatedbefore/after in mkii is broken), then rather than awaiting a fix for the soon-obsolete mkii implementation, maybe I can do a workaround. I need help with the tex details though, please, as I am still very much a tex newbie... We are generating our tex document, so verbosity is not a problem, but irregularity would be. Rather than inserting \break in various places manually, which would have to be redone often, I could automatically insert \discretionary or \allowbreak before/after the appropriate characters in the tex document. Would that work? How would I suppress hyphenation at other points -- \dontleavehmode or something like that? Thanks again, Lars
On 11/21/2008 12:01 PM, Lars Huttar wrote:
So as far as we know, nobody has successfully used \sethyphenatedurlbefore/after/etc. to tune the url-breaking mechanism. Has anybody else on the list done this?
If not, maybe the mkii implementation has never worked for that purpose... it's possible, since urls are breaking after hyphens when lang-url.mkii says to break before hyphens.
If this is the case (\sethyphenatedbefore/after in mkii is broken), then rather than awaiting a fix for the soon-obsolete mkii implementation, maybe I can do a workaround. I need help with the tex details though, please, as I am still very much a tex newbie...
We are generating our tex document, so verbosity is not a problem, but irregularity would be. Rather than inserting \break in various places manually, which would have to be redone often, I could automatically insert \discretionary or \allowbreak before/after the appropriate characters in the tex document. Would that work? How would I suppress hyphenation at other points -- \dontleavehmode or something like that?
OK... I have a working workaround... close your eyes, because it's ugly. I just put \hbox{} around the sections that we don't want broken, and \discretionary{}{}{} in the places we will allow a break: \hbox{http://}\discretionary{}{}{}\hbox{www}\discretionary{}{}{}\hbox{.sil}\discretionary{}{}{}\hbox{.org/}\discretionary{}{}{}\hbox{silesr/}... One of our URLs goes from 89 to 391 characters! :-p Maybe posting this awful kluge to the list will motivate someone who knows TeX better to post a more elegant solution. :-) Ugly as it is, it does allow me to control exactly where I want to allow a break and where I don't. So I'll go with that for now, in order to meet our deadline. I'm sure someone could write a TeX macro to do the above algorithmically instead of brute-force specifying every possible break point explicitly. But that's what \hyphenatedurl is supposed to be, and it doesn't seem to be working for me. Regards, Lars
On Fri, Nov 21, 2008 at 8:31 PM, Lars Huttar wrote:
On 11/21/2008 12:01 PM, Lars Huttar wrote:
So as far as we know, nobody has successfully used \sethyphenatedurlbefore/after/etc. to tune the url-breaking mechanism. Has anybody else on the list done this?
OK... I have a working workaround... close your eyes, because it's ugly.
I just put \hbox{} around the sections that we don't want broken, and \discretionary{}{}{} in the places we will allow a break: \hbox{http://}\discretionary{}{}{}\hbox{www}\discretionary{}{}{}\hbox{.sil}\discretionary{}{}{}\hbox{.org/}\discretionary{}{}{}\hbox{silesr/}...
One of our URLs goes from 89 to 391 characters! :-p
Maybe posting this awful kluge to the list will motivate someone who knows TeX better to post a more elegant solution. :-)
I don't know many details about TeX, but simple tests like the one below seem to work: \bgroup \catcode`\:=11 \catcode`\/=11 \catcode`\~=11 \catcode`\,=11 \catcode`\-=11 \catcode`\_=11 \catcode`\?=11 \lccode`\:=`\: \lccode`\/=`\/ \lccode`\~=`\~ \lccode`\,=`\, \lccode`\-=`\- \lccode`\_=`\_ \lccode`\?=`\? % not sure how to handle the dot, but this seems to work \catcode`\.=11 \catcode`\^=11 \lccode`\^=`\. \patterns{ 8:3 % break after : (never before) 3^8 % break before . (never after) 8/3 % break after / (never before) 3~8 % break before ~ (never after) 3,8 3-8 3_8 3?8 } \egroup And then an ugly document (after selecting the proper language): \bgroup \catcode`\:=11 \catcode`\.=11 \catcode`\/=11 \catcode`\~=11 \catcode`\,=11 \catcode`\-=11 \catcode`\_=11 \catcode`\?=11 \lccode`\:=`\: \lccode`\.=`\. \lccode`\/=`\/ \lccode`\~=`\~ \lccode`\,=`\, \lccode`\-=`\- \lccode`\_=`\_ \lccode`\?=`\? \showhyphens{http://www.sil.org/silesr/} hello \egroup This returns http://-www-.sil-.org/-silesr/ But one would need to complete the rules above (should be almost trivial), and of course one would need to write all the needed macros to use the "url language" automatically when typesetting URLs. Mojca
Mojca Miklavec wrote:
hack hack hack hack ....
I tried solutions with special patterns sveral times but the problem is in mixed languages, i.e. english text mixed with url-language; there are some limitations (in pdftex for instance the same codes are used fo rthe whole par (i.e. mixed languages are possible but with the same lccodes etc). Also, one needs to get rid of the - Anyhow, there is another trick, one that Aditya might love ... \bgroup \gdef\lettercolon{:} \catcode`\:=\active \catcode`\^=\active \catcode`\/=\active \catcode`\~=\active \gdef\ForMojcaWhoLikesHacks#1% {\dontleavehmode \begingroup \mathcode`\:="8000 \mathcode`\^="8000 \mathcode`\/="8000 \mathcode`\~="8000 \def:{\nobreak \hbox{\lettercolon}\allowbreak}% \def^{\allowbreak\hbox{\letterhat }\nobreak}% \def/{\nobreak \hbox{\letterslash}\allowbreak}% \def~{\allowbreak\hbox{\lettertilde}\nobreak}% \everymath\emptytoks \mathsurround\zeropoint$\tttf#1$% \endgroup} \egroup \hsize 1mm \ForMojcaWhoLikesHacks{http://www.sil.org/silesr/} ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Fri, Nov 21, 2008 at 11:53 PM, Hans Hagen
Mojca Miklavec wrote:
hack hack hack hack ....
I tried solutions with special patterns sveral times but the problem is in mixed languages, i.e. english text mixed with url-language; there are some limitations (in pdftex for instance the same codes are used fo rthe whole par (i.e. mixed languages are possible but with the same lccodes etc). Also, one needs to get rid of the -
Whooops! I didn't know about those limitations (same catcodes in paragraph, no language mixing). It seemed like a clean solution to me, but apparently it's not. (Sorry for the brainwash.) Mojca
Hi all, would it be able to write a line after a table or figure (e.g.: "Data source: ...") that will be handled as a part of the float object? With many thanks for any hint, Albrecht On Sat, 22 Nov 2008, Mojca Miklavec wrote:
On Fri, Nov 21, 2008 at 11:53 PM, Hans Hagen
wrote: Mojca Miklavec wrote:
hack hack hack hack ....
I tried solutions with special patterns sveral times but the problem is in mixed languages, i.e. english text mixed with url-language; there are some limitations (in pdftex for instance the same codes are used fo rthe whole par (i.e. mixed languages are possible but with the same lccodes etc). Also, one needs to get rid of the -
Whooops! I didn't know about those limitations (same catcodes in paragraph, no language mixing). It seemed like a clean solution to me, but apparently it's not. (Sorry for the brainwash.)
Mojca ___________________________________________________________________________________ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
Albrecht Kauffmann wrote:
Hi all,
would it be able to write a line after a table or figure (e.g.: "Data source: ...") that will be handled as a part of the float object?
Just do \placefigure[]{}{\externalfigure[cow.pdf]\crlf Data source: .. } Best wishes, Taco
On Mon, Nov 24, 2008 at 9:20 AM, Taco Hoekwater
Albrecht Kauffmann wrote:
Hi all,
would it be able to write a line after a table or figure (e.g.: "Data source: ...") that will be handled as a part of the float object?
Just do \placefigure[]{}{\externalfigure[cow.pdf]\crlf Data source: .. }
\placefigure[]{}{\placelegend{\externalfigure[cow.pdf]}{Data source: ...}} Regards, Wolfgang
Dear ConTeXtuals, a few days ago I asked this question but got not any answer. I think it is an important issue to couple a comment with a float (e.g. a table or figure) that has to be moved together with the float, similarly to local footnotes. Has someone solved this problem already somehow or other? With many thanks for hints, Albrecht On Sat, 22 Nov 2008, Albrecht Kauffmann wrote:
Hi all,
would it be able to write a line after a table or figure (e.g.: "Data source: ...") that will be handled as a part of the float object?
With many thanks for any hint, Albrecht
On Sat, 22 Nov 2008, Mojca Miklavec wrote:
On Fri, Nov 21, 2008 at 11:53 PM, Hans Hagen
wrote: Mojca Miklavec wrote:
hack hack hack hack ....
I tried solutions with special patterns sveral times but the problem is in mixed languages, i.e. english text mixed with url-language; there are some limitations (in pdftex for instance the same codes are used fo rthe whole par (i.e. mixed languages are possible but with the same lccodes etc). Also, one needs to get rid of the -
Whooops! I didn't know about those limitations (same catcodes in paragraph, no language mixing). It seemed like a clean solution to me, but apparently it's not. (Sorry for the brainwash.)
Mojca ___________________________________________________________________________________ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On 11/21/2008 4:53 PM, Hans Hagen wrote:
Mojca Miklavec wrote:
hack hack hack hack ....
I tried solutions with special patterns sveral times but the problem is in mixed languages, i.e. english text mixed with url-language; there are some limitations (in pdftex for instance the same codes are used fo rthe whole par (i.e. mixed languages are possible but with the same lccodes etc). Also, one needs to get rid of the -
Anyhow, there is another trick, one that Aditya might love ...
\bgroup
\gdef\lettercolon{:}
\catcode`\:=\active \catcode`\^=\active \catcode`\/=\active \catcode`\~=\active
\gdef\ForMojcaWhoLikesHacks#1% {\dontleavehmode \begingroup \mathcode`\:="8000 \mathcode`\^="8000 \mathcode`\/="8000 \mathcode`\~="8000 \def:{\nobreak \hbox{\lettercolon}\allowbreak}% \def^{\allowbreak\hbox{\letterhat }\nobreak}% \def/{\nobreak \hbox{\letterslash}\allowbreak}% \def~{\allowbreak\hbox{\lettertilde}\nobreak}% \everymath\emptytoks \mathsurround\zeropoint$\tttf#1$% \endgroup}
\egroup
\hsize 1mm \ForMojcaWhoLikesHacks{http://www.sil.org/silesr/}
Thanks, this is great. Looks like, as in improvement over \hyphenatedurl, it allows you to specify that you can break before a character, after, or both. I think I can even see how to use it in a document... though, would I have to undo the initial \catcode commands after the \egroup? Also, I don't see a way to prevent breaking between two slashes... unless you treat them as part of a separate hbox: \hbox{http://}\ForMojcaWhoLikesHacks{www.sil.org/silesr/} which is not a big problem. Thanks, Lars
Lars Huttar wrote:
Also, I don't see a way to prevent breaking between two slashes... unless you treat them as part of a separate hbox: \hbox{http://}\ForMojcaWhoLikesHacks{www.sil.org/silesr/} which is not a big problem.
it's no problem to catch the // but in general this method is not that generic since font changes in math are somewhat limited and kerning is gone too Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 11/24/2008 8:45 AM, Hans Hagen wrote:
Lars Huttar wrote:
Also, I don't see a way to prevent breaking between two slashes... unless you treat them as part of a separate hbox: \hbox{http://}\ForMojcaWhoLikesHacks{www.sil.org/silesr/} which is not a big problem.
it's no problem to catch the // but in general this method is not that generic since font changes in math are somewhat limited and kerning is gone too
Oh... so my ugly \hbox{...}\discretionary{}{}{} method eliminates kerning? Bummer...
Am 21.11.2008 um 23:53 schrieb Hans Hagen:
Mojca Miklavec wrote:
hack hack hack hack ....
I tried solutions with special patterns sveral times but the problem is in mixed languages, i.e. english text mixed with url-language; there are some limitations (in pdftex for instance the same codes are used fo rthe whole par (i.e. mixed languages are possible but with the same lccodes etc). Also, one needs to get rid of the -
Anyhow, there is another trick, one that Aditya might love ...
\bgroup
\gdef\lettercolon{:}
\catcode`\:=\active \catcode`\^=\active \catcode`\/=\active \catcode`\~=\active
\gdef\ForMojcaWhoLikesHacks#1% {\dontleavehmode \begingroup \mathcode`\:="8000 \mathcode`\^="8000 \mathcode`\/="8000 \mathcode`\~="8000 \def:{\nobreak \hbox{\lettercolon}\allowbreak}% \def^{\allowbreak\hbox{\letterhat }\nobreak}% \def/{\nobreak \hbox{\letterslash}\allowbreak}% \def~{\allowbreak\hbox{\lettertilde}\nobreak}% \everymath\emptytoks \mathsurround\zeropoint$\tttf#1$% \endgroup}
\egroup
\hsize 1mm \ForMojcaWhoLikesHacks{http://www.sil.org/silesr/}
Conclusion please: Is \ForMojcaWhoLikesHacks an improvement of \hyphenatedurls in terms of being closer to this "Chicago style" sort of standard? [And thus being part of next beta?] Or is it a personal hack, fitting Lars' needs? Steffen
Steffen Wolfrum wrote:
Conclusion please:
Is \ForMojcaWhoLikesHacks an improvement of \hyphenatedurls in terms of being closer to this "Chicago style" sort of standard?
no, a hack just for mojca, not finished, and since inmath mode hardly configurable with respect to fonts etc
[And thus being part of next beta?]
no, onluy as comment
Or is it a personal hack, fitting Lars' needs?
not even that but if it serves that purpose, fine Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (7)
-
Albrecht Kauffmann
-
Hans Hagen
-
Lars Huttar
-
Mojca Miklavec
-
Steffen Wolfrum
-
Taco Hoekwater
-
Wolfgang Schuster