summaryrefslogtreecommitdiff
path: root/tex/context/base/lang-url.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/lang-url.mkiv')
-rw-r--r--tex/context/base/lang-url.mkiv130
1 files changed, 84 insertions, 46 deletions
diff --git a/tex/context/base/lang-url.mkiv b/tex/context/base/lang-url.mkiv
index 1bbe16838..e7d62ba01 100644
--- a/tex/context/base/lang-url.mkiv
+++ b/tex/context/base/lang-url.mkiv
@@ -44,18 +44,21 @@
\newtoks\everyhyphenatedurl
\appendtoks
- \let\&\letterampersand
- \let\#\letterhash
- \let\~\lettertilde
- \let\\\letterbackslash
- \let\$\letterdollar
- \let\^\letterhat
- \let\_\letterunderscore
- \let\{\letterleftbrace
- \let\}\letterrightbrace
- \let\|\letterbar
- \let~=\lettertilde
- \let|=\letterbar
+ \resetfontfeature
+ \resetcharacterspacing
+ %
+ \let\&\letterampersand
+ \let\#\letterhash
+ \let\~\lettertilde
+ \let\\\letterbackslash
+ \let\$\letterdollar
+ \let\^\letterhat
+ \let\_\letterunderscore
+ \let\{\letterleftbrace
+ \let\}\letterrightbrace
+ \let\|\letterbar
+ \let~=\lettertilde
+ \let|=\letterbar
\to \everyhyphenatedurl
\let\hyphenatedurlseparator \empty % \periodcentered
@@ -64,47 +67,54 @@
\setnewconstant\hyphenatedurllefthyphenmin \plusthree
\setnewconstant\hyphenatedurlrighthyphenmin\plusthree
-\def\lang_url_space {\nobreak\hskip\zeropoint plus\onepoint\nobreak}
-\def\lang_url_after #1{\char#1\discretionary{}{\hyphenatedurlseparator}{}}
-\def\lang_url_before #1{\discretionary{\hyphenatedurlseparator}{}{}\char#1\relax}
-\def\lang_url_normal #1{\char#1\relax}
-\def\lang_url_disc #1{\discretionary{}{}{}}
-
-\def\lang_url_space_trace {\nobreak\begingroup\darkyellow\ruledhskip\zeropoint plus\onepoint\endgroup\nobreak}
-\def\lang_url_after_trace #1{\char#1\hsmash{\darkblue\vl}\discretionary{}{\hyphenatedurlseparator}{}}
-\def\lang_url_before_trace#1{\discretionary{\hyphenatedurlseparator}{}{}\hsmash{\darkred\vl}\char#1\relax}
-\def\lang_url_normal_trace#1{\char#1\relax}
-\def\lang_url_disc_trace #1{\discretionary{\hsmash{\darkgreen\vl}}{\hsmash{\darkgreen\vl}}{\hsmash{\darkgreen\vl}}}
-
-\def\showhyphenatedurlbreaks
- {\let\lang_url_space \lang_url_space_trace
- \let\lang_url_after \lang_url_after_trace
- \let\lang_url_before\lang_url_before_trace
- \let\lang_url_normal\lang_url_normal_trace
- \let\lang_url_disc \lang_url_disc_trace}
-
-\def\sethyphenatedurlnormal#1{\ctxcommand{hyphenatedurl.setcharacters(\!!bs#1\!!es,0)}} % Lua names will change
-\def\sethyphenatedurlbefore#1{\ctxcommand{hyphenatedurl.setcharacters(\!!bs#1\!!es,1)}} % Lua names will change
-\def\sethyphenatedurlafter #1{\ctxcommand{hyphenatedurl.setcharacters(\!!bs#1\!!es,2)}} % Lua names will change
+\def\lang_url_more{\penalty\plustenthousand\hskip\scratchskipone\penalty\plustenthousand}
+\def\lang_url_less{\penalty\plustenthousand\hskip\scratchskiptwo\penalty\plustenthousand}
+\def\lang_url_trac{\penalty\plustenthousand\hsmash{\darkred\vl}\penalty\plustenthousand}
+
+\def\lang_url_a#1{\lang_url_more\char#1\lang_url_show\discretionary{}{\hyphenatedurlseparator}{}}
+\def\lang_url_b#1{\lang_url_more\discretionary{\hyphenatedurlseparator}{}{}\lang_url_show\char#1\relax}
+\def\lang_url_d#1{\lang_url_more\discretionary{\lang_url_show}{\lang_url_show}{\lang_url_show}}
+\def\lang_url_l#1{\lang_url_less\char#1\relax}
+\def\lang_url_c#1{\lang_url_more\char#1\relax}
+\def\lang_url_L#1{\lang_url_less\char#1\relax}
+\def\lang_url_C#1{\lang_url_more\char#1\relax}
+
+\unexpanded\def\showhyphenatedurlbreaks % for old times sake
+ {\let\lang_url_show\lang_url_trac}
+
+\installtextracker
+ {languages.url}
+ {\let\lang_url_show\lang_url_trac}
+ {\let\lang_url_show\relax}
+
+\let\lang_url_show\relax
+
+\unexpanded\def\sethyphenatedurlnormal#1{\clf_sethyphenatedurlcharacters{#1}{\v!normal}}
+\unexpanded\def\sethyphenatedurlbefore#1{\clf_sethyphenatedurlcharacters{#1}{\v!before}}
+\unexpanded\def\sethyphenatedurlafter #1{\clf_sethyphenatedurlcharacters{#1}{\v!after }}
% \sethyphenatedurlafter{ABCDEF}
-\unexpanded \def\hyphenatedurl#1%
+\unexpanded\def\hyphenatedurl#1%
{\dontleavehmode
\begingroup
\the\everyhyphenatedurl
\normallanguage\zerocount
- \let\s\lang_url_space
- \let\a\lang_url_after
- \let\b\lang_url_before
- \let\n\lang_url_normal
- \let\d\lang_url_disc
- \normalexpanded{\noexpand\ctxcommand{hyphenatedurl(
- \!!bs\noexpand\detokenize{#1}\!!es,
- \number\hyphenatedurllefthyphenmin,
- \number\hyphenatedurlrighthyphenmin,
- "\hyphenatedurldiscretionary"
- )}}%
+ \let\a\lang_url_a % after
+ \let\b\lang_url_b % before
+ \let\d\lang_url_d % disc
+ \let\l\lang_url_l % letter
+ \let\c\lang_url_c % character
+ \let\L\lang_url_L % letter_nobreak
+ \let\C\lang_url_C % character_nobreak
+ \scratchskipone\zeropoint\s!plus\dimexpr\emwidth/12\s!minus\dimexpr\emwidth/24\relax % 1.00pt @ 12pt
+ \scratchskiptwo\zeropoint\s!plus\dimexpr\emwidth/48\s!minus\dimexpr\emwidth/96\relax % 0.25pt @ 12pt
+ \normalexpanded{\noexpand\clf_hyphenatedurl
+ {\noexpand\detokenize{#1}}%
+ \hyphenatedurllefthyphenmin
+ \hyphenatedurlrighthyphenmin
+ {\hyphenatedurldiscretionary}%
+ }%
\endgroup}
%D \macros
@@ -131,3 +141,31 @@
% \dorecurse{100}{\test{a} \test{ab} \test{abc} \test{abcd} \test{abcde} \test{abcdef}}
\protect \endinput
+
+% \setuppapersize[A7]
+%
+% \unexpanded\def\WhateverA#1%
+% {\dontleavehmode
+% \begingroup
+% \prehyphenchar"B7\relax
+% \setbox\scratchbox\hbox{\tttf#1}%
+% \prehyphenchar`-\relax
+% \unhbox\scratchbox
+% \endgroup}
+%
+% \unexpanded\def\WhateverB#1%
+% {\dontleavehmode
+% \begingroup
+% \tttf
+% \prehyphenchar\minusone
+% % \localrightbox{\llap{_}}%
+% \localrightbox{\llap{\smash{\lower1.5ex\hbox{\char"2192}}}}%
+% \setbox\scratchbox\hbox{#1}%
+% \prehyphenchar`-\relax
+% \unhbox\scratchbox
+% \endgroup}
+%
+% \begingroup \hsize1cm
+% \WhateverA{thisisaboringandverylongcommand}\par
+% \WhateverB{thisisaboringandverylongcommand}\par
+% \endgroup