hyphenate urls in a non hyphenated text
Hello, I'm making a flushleft document with no hyphenation. However, URLs are then not hyphenated either and end up in the margin. \hyphenateurl{} works only when setupalign[] is set to hyphenated. Is there a way to hyphenate only URLs? Thanks, Stéphanie -- ---- Stéphanie Vilayphiou <stdin> http://stdin.fr/ +32 (0)4 89 00 88 59
On 10/8/2013 4:34 PM, Stéphanie Vilayphiou wrote:
Hello, I'm making a flushleft document with no hyphenation. However, URLs are then not hyphenated either and end up in the margin.
\hyphenateurl{} works only when setupalign[] is set to hyphenated.
Is there a way to hyphenate only URLs?
You need to provide a few more options to \setupalign: \starttext \appendtoks\tttf\to\everyhyphenatedurl % maybe we need a proper setup \setupalign[nothyphenated,stretch,tolerant] I wonder how stable these youtube links are but nevertheless youtube is a nice way to find new artists. Some only perform (mostly) at this medium, like \hyphenatedurl {http://www.youtube.com/watch?v=FI0fyOaD94Y} also to be seen in \hyphenatedurl {http://www.youtube.com/watch?v=HIJPxxoF7dw} and \hyphenatedurl {http://www.youtube.com/watch?v=r2i7TkGwOCw} (beware, you can spend days watching this once you see what's going on). Videos like \hyphenatedurl {http://www.youtube.com/watch?v=6CombsS6vFc} trigger you to visit concerts. Or this one \hyphenatedurl {http://www.youtube.com/watch?v=HJ0ImaGUYZo} (you have to him live!) also to be seen in \hyphenatedurl {http://www.youtube.com/watch?v=NgzQ_e2huJQ} (a series). Also, once you start looking up some specific artists it can trigger you in buying all dvd's and many cd's on where they perform, like \hyphenatedurl {http://www.youtube.com/watch?v=Y6YooxOTsus}, \hyphenatedurl {http://www.youtube.com/watch?v=9hdxYW2YODE}, and \hyphenatedurl {http://www.youtube.com/watch?v=su8ztwNbIsU}. beware, watching the interviews with him and and watching his instructional videos changes the way you listen to some music. And then there are those videos (but of course I use the dvds eventually) that are great while pondering and writing new code, take \hyphenatedurl {http://www.youtube.com/watch?v=umyB1QDP5PM}. Then there are those channels, like \hyphenatedurl {http://www.youtube.com/user/JoeBonamassaTV?feature=watch}, that make you buy even more disks, this time I bought blu-rays (forcing me to buy a player too). I could on for ages but I now have enough links for testing. \stoptext Well, it renders okay, but one can debate of it looks pretty. Let's hope that you might use ragged right rendering. Urls will always be kind of ugly anyway. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 2013–10–08 Hans Hagen wrote:
\hyphenateurl{} works only when setupalign[] is set to hyphenated.
Is there a way to hyphenate only URLs?
You need to provide a few more options to \setupalign:
Why?
\appendtoks\tttf\to\everyhyphenatedurl % maybe we need a proper setup
Isn't that what \url is for? It has a setup command and uses \hyphenatedurl.
\setupalign[nothyphenated,stretch,tolerant]
This does not only change how URLs are typeset, but it also affects the main text, which might not be desirable.
[…]
I don't see a single hyphenated URL in your result. The OP failing to provide a minimal example, let me provide my interpretation of the problem: \useurl [somelink] [http://bits.blogs.nytimes.com/2010/03/05/a-former-book-designer-says-good-riddance-to-print/?hpw&_r=0] \setupalign [nothyphenated] \starttext \url [somelink] \input knuth \stoptext I don't know how to start and stop hyphenation within a paragraph. Allowing hyphenation for the entire paragraph is easy. Marco
On 10/8/2013 7:35 PM, Marco Patzer wrote:
On 2013–10–08 Hans Hagen wrote:
\hyphenateurl{} works only when setupalign[] is set to hyphenated.
Is there a way to hyphenate only URLs?
You need to provide a few more options to \setupalign:
Why?
\appendtoks\tttf\to\everyhyphenatedurl % maybe we need a proper setup
Isn't that what \url is for? It has a setup command and uses \hyphenatedurl.
sure, but it forces one to use \url which is not always an option (if there are thousands embedded in the text)
\setupalign[nothyphenated,stretch,tolerant]
This does not only change how URLs are typeset, but it also affects the main text, which might not be desirable.
I got the impression that it concerned a whole document (we sometimes have that demand, but normally those have no urls anyway)
[…]
I don't see a single hyphenated URL in your result. The OP failing to provide a minimal example, let me provide my interpretation of the problem:
This is more visible \appendtoks\tttf\to\everyhyphenatedurl \lefthyphenmin=100 \righthyphenmin=100 maybe this is s better definition of nohyphens: \unexpanded\def\nohyphens {\ifx\dohyphens\relax \unexpanded\edef\dohyphens {\lefthyphenmin\the\lefthyphenmin \righthyphenmin\the\righthyphenmin \relax}% \fi \lefthyphenmin\maxdimen \righthyphenmin\maxdimen}
\useurl [somelink] [http://bits.blogs.nytimes.com/2010/03/05/a-former-book-designer-says-good-riddance-to-print/?hpw&_r=0]
\setupalign [nothyphenated]
\starttext \url [somelink] \input knuth \stoptext
I don't know how to start and stop hyphenation within a paragraph. Allowing hyphenation for the entire paragraph is easy.
needs a bit it tinkering, maybe this is nicer: \unprotect \unexpanded\def\nohyphens {\ifx\dohyphens\relax \unexpanded\edef\dohyphens {\hyphenminoffset\the\hyphenminoffset\relax \lang_basics_synchronize_min_max}% \fi \hyphenminoffset\plusthousand \lang_basics_synchronize_min_max} \protect as it syncs nicely with languages too (characters carry left and right values so inline changes are possible) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 2013–10–08 Hans Hagen wrote:
On 10/8/2013 7:35 PM, Marco Patzer wrote:
On 2013–10–08 Hans Hagen wrote:
\hyphenateurl{} works only when setupalign[] is set to hyphenated.
Is there a way to hyphenate only URLs?
You need to provide a few more options to \setupalign:
Why?
\appendtoks\tttf\to\everyhyphenatedurl % maybe we need a proper setup
Isn't that what \url is for? It has a setup command and uses \hyphenatedurl.
sure, but it forces one to use \url which is not always an option (if there are thousands embedded in the text)
Valid point.
I don't see a single hyphenated URL in your result. The OP failing to provide a minimal example, let me provide my interpretation of the problem:
This is more visible
\appendtoks\tttf\to\everyhyphenatedurl \lefthyphenmin=100 \righthyphenmin=100
You URLs still don't hyphenate. Maybe we're misunderstanding each other here.
maybe this is s better definition of nohyphens:
\unexpanded\def\nohyphens {\ifx\dohyphens\relax \unexpanded\edef\dohyphens {\lefthyphenmin\the\lefthyphenmin \righthyphenmin\the\righthyphenmin \relax}% \fi \lefthyphenmin\maxdimen \righthyphenmin\maxdimen}
[…]
needs a bit it tinkering, maybe this is nicer:
\unprotect
\unexpanded\def\nohyphens {\ifx\dohyphens\relax \unexpanded\edef\dohyphens {\hyphenminoffset\the\hyphenminoffset\relax \lang_basics_synchronize_min_max}% \fi \hyphenminoffset\plusthousand \lang_basics_synchronize_min_max}
\protect
as it syncs nicely with languages too (characters carry left and right values so inline changes are possible)
That looks good. The OP should test it on his document. However, it has the implication that URLs are always hyphenated, as far as I can tell. But it is in fact a practical solution which is certainly what the user wants in almost all of the cases. I never had a document where URLs protruding into the margin was desired. Marco
Hello, thank you for your answers. As Marco stated, the first minimal example you gave didn't hyphenate URLs. I'd like to try a minimal example of your second email, Hans, but I can't figure out how to use those functions? Can you make another minimal example so that I can understand better how this works? Thank you, Stéphanie Le mar. 08 oct. 2013 21:27:22 CEST, Marco Patzer a écrit :
On 2013–10–08 Hans Hagen wrote:
On 10/8/2013 7:35 PM, Marco Patzer wrote:
On 2013–10–08 Hans Hagen wrote:
\hyphenateurl{} works only when setupalign[] is set to hyphenated.
Is there a way to hyphenate only URLs?
You need to provide a few more options to \setupalign:
Why?
\appendtoks\tttf\to\everyhyphenatedurl % maybe we need a proper setup
Isn't that what \url is for? It has a setup command and uses \hyphenatedurl.
sure, but it forces one to use \url which is not always an option (if there are thousands embedded in the text)
Valid point.
I don't see a single hyphenated URL in your result. The OP failing to provide a minimal example, let me provide my interpretation of the problem:
This is more visible
\appendtoks\tttf\to\everyhyphenatedurl \lefthyphenmin=100 \righthyphenmin=100
You URLs still don't hyphenate. Maybe we're misunderstanding each other here.
maybe this is s better definition of nohyphens:
\unexpanded\def\nohyphens {\ifx\dohyphens\relax \unexpanded\edef\dohyphens {\lefthyphenmin\the\lefthyphenmin \righthyphenmin\the\righthyphenmin \relax}% \fi \lefthyphenmin\maxdimen \righthyphenmin\maxdimen}
[…]
needs a bit it tinkering, maybe this is nicer:
\unprotect
\unexpanded\def\nohyphens {\ifx\dohyphens\relax \unexpanded\edef\dohyphens {\hyphenminoffset\the\hyphenminoffset\relax \lang_basics_synchronize_min_max}% \fi \hyphenminoffset\plusthousand \lang_basics_synchronize_min_max}
\protect
as it syncs nicely with languages too (characters carry left and right values so inline changes are possible)
That looks good. The OP should test it on his document.
However, it has the implication that URLs are always hyphenated, as far as I can tell. But it is in fact a practical solution which is certainly what the user wants in almost all of the cases. I never had a document where URLs protruding into the margin was desired.
Marco
___________________________________________________________________________________ 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 ___________________________________________________________________________________ -- École Supérieure d'Art et Design, www.esad-gv.fr — 25 rue Lesdiguières, 38 000 •Grenoble ; Tél. +33 (0)4 76 86 61 30, Fax +33 (0)4 76 85 28 18, Mél. grenoble@ esad-gv.fr — Place des Beaux-Arts, CS 40 074, 26 903 •Valence cedex 9 ; Tél. +33 (0)4 75 79 24 00, Fax +33 (0)4 75 79 24 40, Mél. valence@ esad-gv.fr •Inge Linder-Gaillard, responsable des études et de la recherche, T^él. +33 (0)4 76 86 61 34, M^ob. +33 (0)6 98 08 43 86, M^él. inge.linder-gaillard@esad-gv.fr
On 2013–10–08 Stéphanie Vilayphiou wrote:
I'd like to try a minimal example of your second email, Hans, but I can't figure out how to use those functions? Can you make another minimal example so that I can understand better how this works?
It's sufficient to copy-paste the code into your document. Note that the redefined code has do precede \setupalign. \unprotect \unexpanded\def\nohyphens {\ifx\dohyphens\relax \unexpanded\edef\dohyphens {\hyphenminoffset\the\hyphenminoffset\relax \lang_basics_synchronize_min_max}% \fi \hyphenminoffset\plusthousand \lang_basics_synchronize_min_max} \protect \setupalign [nothyphenated] \starttext \hyphenatedurl{http://bits.blogs.nytimes.com/2010/03/05/a-former-book-designer-says-good-riddance-to-print/?hpw&_r=0} \input knuth \stoptext Marco
Ah ok, I tried it in Context live first and it didn't output a PDF, but it works like a charm on my server. See an example here, page 24: http://esadgv.stdin.fr/media/pdf/esad-gv_catalogue_2012-2013.pdf Thanks a lot for your help! Stéphanie Le mar. 08 oct. 2013 22:37:27 CEST, Marco Patzer a écrit :
On 2013–10–08 Stéphanie Vilayphiou wrote:
I'd like to try a minimal example of your second email, Hans, but I can't figure out how to use those functions? Can you make another minimal example so that I can understand better how this works?
It's sufficient to copy-paste the code into your document. Note that the redefined code has do precede \setupalign.
\unprotect \unexpanded\def\nohyphens {\ifx\dohyphens\relax \unexpanded\edef\dohyphens {\hyphenminoffset\the\hyphenminoffset\relax \lang_basics_synchronize_min_max}% \fi \hyphenminoffset\plusthousand \lang_basics_synchronize_min_max} \protect
\setupalign [nothyphenated]
\starttext \hyphenatedurl{http://bits.blogs.nytimes.com/2010/03/05/a-former-book-designer-says-good-riddance-to-print/?hpw&_r=0} \input knuth \stoptext
Marco
___________________________________________________________________________________ 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 ___________________________________________________________________________________
-- École Supérieure d'Art et Design, www.esad-gv.fr — 25 rue Lesdiguières, 38 000 •Grenoble ; Tél. +33 (0)4 76 86 61 30, Fax +33 (0)4 76 85 28 18, Mél. grenoble@ esad-gv.fr — Place des Beaux-Arts, CS 40 074, 26 903 •Valence cedex 9 ; Tél. +33 (0)4 75 79 24 00, Fax +33 (0)4 75 79 24 40, Mél. valence@ esad-gv.fr •Inge Linder-Gaillard, responsable des études et de la recherche, T^él. +33 (0)4 76 86 61 34, M^ob. +33 (0)6 98 08 43 86, M^él. inge.linder-gaillard@esad-gv.fr
On 2013–10–09 Stéphanie Vilayphiou wrote:
Ah ok, I tried it in Context live first and it didn't output a PDF,
ConTeXt live runs 2012.05.30 11:26. However, the hyphenation macros were redone in beta 2013.03.04 18:28 and macros such as \sethyphenationvariables were replaced by \lang_basics_synchronize_min_max Hans' first suggestion should work on older versions as well: \unexpanded\def\nohyphens {\ifx\dohyphens\relax \unexpanded\edef\dohyphens {\lefthyphenmin\the\lefthyphenmin \righthyphenmin\the\righthyphenmin \relax}% \fi \lefthyphenmin\maxdimen \righthyphenmin\maxdimen} Marco
On Wed, 9 Oct 2013, Stéphanie Vilayphiou wrote:
Ah ok, I tried it in Context live first and it didn't output a PDF, but it works like a charm on my server. See an example here, page 24: http://esadgv.stdin.fr/media/pdf/esad-gv_catalogue_2012-2013.pdf
Why does context break urls **before** slash, hyphen, and dot. Isn't it better to break urls **after** these symbols? Aditya
On 10/9/2013 1:09 AM, Aditya Mahajan wrote:
On Wed, 9 Oct 2013, Stéphanie Vilayphiou wrote:
Ah ok, I tried it in Context live first and it didn't output a PDF, but it works like a charm on my server. See an example here, page 24: http://esadgv.stdin.fr/media/pdf/esad-gv_catalogue_2012-2013.pdf
Why does context break urls **before** slash, hyphen, and dot. Isn't it better to break urls **after** these symbols?
because when they end up in front of a line, it's more likely that they belong to the previous while for instance a period at the end of a line could also be ending a line. ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (5)
-
Aditya Mahajan
-
Hans Hagen
-
Marco Patzer
-
Stéphanie Vilayphiou
-
Stéphanie Vilayphiou