summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/lang-url.mkiv
blob: 7479fed6803a8b36264422466da211da10b6a501 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
%D \module
%D   [       file=lang-url,
%D        version=2008.01.22, % used to be lang-mis
%D          title=\CONTEXT\ Language Macros,
%D       subtitle=Language Options,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\registerctxluafile{lang-url}{1.001}

\unprotect

% \urlsplitmode is not (yet) supported (not that much needed)

\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
\to \everyhyphenatedurl

\def\hyphenatedurlseparator{} % \periodcentered

\def\dohyphenatedurlafter #1{\char#1\discretionary{}{\hyphenatedurlseparator}{}}%
\def\dohyphenatedurlbefore#1{\discretionary{\hyphenatedurlseparator}{}{}\char#1\relax}%
\def\dohyphenatedurlnormal#1{\char#1\relax}%

\def\sethyphenatedurlnormal#1{\ctxlua{commands.hyphenatedurl.characters[\!!bs#1\!!es]=0}}
\def\sethyphenatedurlbefore#1{\ctxlua{commands.hyphenatedurl.characters[\!!bs#1\!!es]=1}}
\def\sethyphenatedurlafter #1{\ctxlua{commands.hyphenatedurl.characters[\!!bs#1\!!es]=2}}

\chardef\hyphenatedurllefthyphenmin  = 3
\chardef\hyphenatedurlrighthyphenmin = 3

\unexpanded \def\hyphenatedurl#1%
  {\dontleavehmode
   \begingroup
   \the\everyhyphenatedurl
   \let\n\dohyphenatedurlnormal
   \let\b\dohyphenatedurlbefore
   \let\a\dohyphenatedurlafter
   \expanded{\ctxlua{commands.hyphenatedurl.action(
        \!!bs\noexpand\detokenize{#1}\!!es,
        \number\hyphenatedurllefthyphenmin,
        \number\hyphenatedurlrighthyphenmin
    )}}%
   \endgroup}

\protect \endinput