summaryrefslogtreecommitdiff
path: root/tex/context/base/lang-hyp.mkiv
blob: 0cd5a72ca61ff317d42847899a10af624f008381 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
%D \module
%D   [       file=lang-ini,
%D        version=2014.08.10,
%D          title=\CONTEXT\ Language Macros,
%D       subtitle=Experimental Patterns,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D This is an experimental module. We often have to deal with titles
%D that have conflicting demands:
%D
%D \startitemize
%D \startitem They go into a dedicated space (often a graphic). \stopitem
%D \startitem The words cannot be hyphenated. \stopitem
%D \startitem But as an escape they can get hyphenated. \stopitem
%D \startitem In that case we want at least an extra word on the last line. \stopitem
%D \stopitemize
%D
%D These and maybe more cases can be dealt with using dedicated hyphenation
%D mechanisms. At he same time we want to experiment with more extensive patterns
%D as discussed in {\em TUGboat, Volume 27 (2006), No. 2—Proceedings of EuroTEX2006}.

% lua: 5.341 5.354
% tex: 5.174 5.262

\writestatus{loading}{ConTeXt Language Macros / Initialization}

\registerctxluafile{lang-hyp}{1.001}

%D This command can change! At some point we will keep the setting with the
%D paragraph and then the \type {\par} can go.

\unexpanded\def\atleastoneword#1%
  {\begingroup
   \enabledirectives[hyphenators.method=traditional]%
   \enabledirectives[hyphenators.rightwordsmin=1]%
   \lefthyphenmin \plusfour
   \righthyphenmin\plusfour
   #1\par
   \disabledirectives[hyphenators.rightwordsmin]%
   \enabledirectives[hyphenators.method]%
   \endgroup}

\endinput

% \starttext
%
% \enabledirectives[hyphenators.method=traditional]
%
% % \dorecurse{1000}{\input tufte \par}
%
% \setupalign[verytolerant,flushleft]
% \setuplayout[width=140pt] \showframe
%
% longword longword long word longword longwordword \blank
%
% \enabledirectives[hyphenators.rightwordsmin=1]
%
% longword longword long word longword longwordword\blank
%
% \disabledirectives[hyphenators.rightwordsmin]
%
% longword longword long word longword longwordword\blank
%
% \atleastoneword{longword longword long word longword longwordword}
%
% \enabledirectives[hyphenators.method=traditional]
%
% \stoptext

% \startluacode
%     -- e1ë/e=e             reëel      re-eel
%     -- a1atje./a=t,1,3     omaatje    oma-tje
%     -- schif1f/ff=f,5,2    Schiffahrt Schiff-fahrt
%
%     languages.hyphenators.traditional.registerpattern("en","a1b",      { start = 1, length = 2, before = "CD", after = "EF"  } )
%     languages.hyphenators.traditional.registerpattern("en","e1ë",      { start = 1, length = 2, before = "e",  after = "e"  } )
%     languages.hyphenators.traditional.registerpattern("en","oo1ë",     { start = 2, length = 2, before = "o",  after = "e"  } )
%     languages.hyphenators.traditional.registerpattern("en","qqxc9xkqq",{ start = 3, length = 4, before = "ab", after = "cd" } ) -- replacement start length
%
%     --  print("reëel",       injecthyphens(dictionaries.nl,"reëel",       2,2))
%     --  print("reeëel",      injecthyphens(dictionaries.nl,"reeëel",      2,2))
%     --  print("rooëel",      injecthyphens(dictionaries.nl,"rooëel",      2,2))
%     --  print(   "QXcXkQ",   injecthyphens(dictionaries.de,   "QXcXkQ",   2,2))
%     --  print(  "QQXcXkQQ",  injecthyphens(dictionaries.de,  "QQXcXkQQ",  2,2))
%     --  print( "QQQXcXkQQQ", injecthyphens(dictionaries.de, "QQQXcXkQQQ", 2,2))
%     --  print("QQQQXcXkQQQQ",injecthyphens(dictionaries.de,"QQQQXcXkQQQQ",2,2))
%     --
%     --  print(  "QQXcXkQQ QQXcXkQQ",  injecthyphens(dictionaries.de,  "QQXcXkQQ QQXcXkQQ",  2,2))
% \stopluacode
%
% \starttext
%
% \blank
%
% xreëel rooëel \par xxabxx xxxabxxx \par
%
% \hsize1mm \lefthyphenmin2 \righthyphenmin2
%
% \blank Capacity \blank capacity \blank xyabxy \blank xreëel \blank rooëel \blank
%
% xy\discretionary{CD}{EF}{ab}xy % xxacceedxxx
%
% \stoptext