]>
Commit | Line | Data |
---|---|---|
1 | # Copyright (c) 2002-2015 International Business Machines Corporation and | |
2 | # others. All Rights Reserved. | |
3 | # | |
4 | # file: line_normal.txt | |
5 | # | |
6 | # Line Breaking Rules | |
7 | # Implement default line breaking as defined by | |
8 | # Unicode Standard Annex #14 Revision 29 for Unicode 6.2 | |
9 | # http://www.unicode.org/reports/tr14/ | |
10 | # tailored as noted in 2nd paragraph below.. | |
11 | # | |
12 | # TODO: Rule LB 8 remains as it was in Unicode 5.2 | |
13 | # This is only because of a limitation of ICU break engine implementation, | |
14 | # not because the older behavior is desirable. | |
15 | # | |
16 | # This tailors the line break behavior to correspond to CSS | |
17 | # line-break=normal (BCP47 -u-lb-normal) as defined for languages other than | |
18 | # Chinese & Japanese. | |
19 | # It sets characters of class CJ to behave like ID. | |
20 | ||
21 | # | |
22 | # Character Classes defined by TR 14. | |
23 | # | |
24 | ||
25 | !!chain; | |
26 | !!LBCMNoChain; | |
27 | ||
28 | ||
29 | !!lookAheadHardBreak; | |
30 | # | |
31 | # !!lookAheadHardBreak Described here because it is (as yet) undocumented elsewhere | |
32 | # and only used for the line break rules. | |
33 | # | |
34 | # It is used in the implementation of rule LB 10 | |
35 | # which says to treat any combining mark that is not attached to a base | |
36 | # character as if it were of class AL (alphabetic). | |
37 | # | |
38 | # The problem occurs in the reverse rules. | |
39 | # | |
40 | # Consider a sequence like, with correct breaks as shown | |
41 | # LF ID CM AL AL | |
42 | # ^ ^ ^ | |
43 | # Then consider the sequence without the initial ID (ideographic) | |
44 | # LF CM AL AL | |
45 | # ^ ^ | |
46 | # Our CM, which in the first example was attached to the ideograph, | |
47 | # is now unattached, becomes an alpha, and joins in with the other | |
48 | # alphas. | |
49 | # | |
50 | # When iterating forwards, these sequences do not present any problems | |
51 | # When iterating backwards, we need to look ahead when encountering | |
52 | # a CM to see whether it attaches to something further on or not. | |
53 | # (Look-ahead in a reverse rule is looking towards the start) | |
54 | # | |
55 | # If the CM is unattached, we need to force a break. | |
56 | # | |
57 | # !!lookAheadHardBreak forces the run time state machine to | |
58 | # stop immediately when a look ahead rule ( '/' operator) matches, | |
59 | # and set the match position to that of the look-ahead operator, | |
60 | # no matter what other rules may be in play at the time. | |
61 | # | |
62 | # See rule LB 19 for an example. | |
63 | # | |
64 | ||
65 | $AI = [:LineBreak = Ambiguous:]; | |
66 | $AL = [:LineBreak = Alphabetic:]; | |
67 | $BA = [:LineBreak = Break_After:]; | |
68 | $BB = [:LineBreak = Break_Before:]; | |
69 | $BK = [:LineBreak = Mandatory_Break:]; | |
70 | $B2 = [:LineBreak = Break_Both:]; | |
71 | $CB = [:LineBreak = Contingent_Break:]; | |
72 | $CJ = [:LineBreak = Conditional_Japanese_Starter:]; | |
73 | $CL = [:LineBreak = Close_Punctuation:]; | |
74 | $CM = [:LineBreak = Combining_Mark:]; | |
75 | $CP = [:LineBreak = Close_Parenthesis:]; | |
76 | $CR = [:LineBreak = Carriage_Return:]; | |
77 | $EX = [:LineBreak = Exclamation:]; | |
78 | $GL = [:LineBreak = Glue:]; | |
79 | $HL = [:LineBreak = Hebrew_Letter:]; | |
80 | $HY = [:LineBreak = Hyphen:]; | |
81 | $H2 = [:LineBreak = H2:]; | |
82 | $H3 = [:LineBreak = H3:]; | |
83 | $ID = [[:LineBreak = Ideographic:] $CJ]; | |
84 | $IN = [:LineBreak = Inseperable:]; | |
85 | $IS = [:LineBreak = Infix_Numeric:]; | |
86 | $JL = [:LineBreak = JL:]; | |
87 | $JV = [:LineBreak = JV:]; | |
88 | $JT = [:LineBreak = JT:]; | |
89 | $LF = [:LineBreak = Line_Feed:]; | |
90 | $NL = [:LineBreak = Next_Line:]; | |
91 | $NS = [:LineBreak = Nonstarter:]; | |
92 | $NU = [:LineBreak = Numeric:]; | |
93 | $OP = [:LineBreak = Open_Punctuation:]; | |
94 | $PO = [:LineBreak = Postfix_Numeric:]; | |
95 | $PR = [:LineBreak = Prefix_Numeric:]; | |
96 | $QU = [:LineBreak = Quotation:]; | |
97 | $RI = [:LineBreak = Regional_Indicator:]; | |
98 | $SA = [:LineBreak = Complex_Context:]; | |
99 | $SG = [:LineBreak = Surrogate:]; | |
100 | $SP = [:LineBreak = Space:]; | |
101 | $SY = [:LineBreak = Break_Symbols:]; | |
102 | $WJ = [:LineBreak = Word_Joiner:]; | |
103 | $XX = [:LineBreak = Unknown:]; | |
104 | $ZW = [:LineBreak = ZWSpace:]; | |
105 | ||
106 | # Special character classes for people & body part emoji: | |
107 | # Subsets of $CM: | |
108 | $ZWJ = \u200D; | |
109 | $EmojiVar = \uFE0F; | |
110 | # The following are subsets of $ID | |
111 | $EmojiForSeqs = [\u2764 \U0001F441 \U0001F466-\U0001F469 \U0001F48B \U0001F5E8]; | |
112 | $EmojiForMods = [\u261D \u26F9 \u270A-\u270D \U0001F385 \U0001F3C3-\U0001F3C4 \U0001F3C7 \U0001F3CA-\U0001F3CB \U0001F442-\U0001F443 \U0001F446-\U0001F450 \U0001F466-\U0001F469 \U0001F46E-\U0001F478 \U0001F47C \U0001F481-\U0001F483 \U0001F485-\U0001F487 \U0001F4AA \U0001F590 \U0001F595 \U0001F596 \U0001F645-\U0001F647 \U0001F64B-\U0001F64F \U0001F6A3 \U0001F6B4-\U0001F6B6 \U0001F6C0 \U0001F918]; | |
113 | $EmojiMods = [\U0001F3FB-\U0001F3FF]; | |
114 | ||
115 | # Dictionary character set, for triggering language-based break engines. Currently | |
116 | # limited to LineBreak=Complex_Context. Note that this set only works in Unicode | |
117 | # 5.0 or later as the definition of Complex_Context was corrected to include all | |
118 | # characters requiring dictionary break. | |
119 | ||
120 | $dictionary = [:LineBreak = Complex_Context:]; | |
121 | ||
122 | # | |
123 | # Rule LB1. By default, treat AI (characters with ambiguous east Asian width), | |
124 | # SA (South East Asian: Thai, Lao, Khmer) | |
125 | # SG (Unpaired Surrogates) | |
126 | # XX (Unknown, unassigned) | |
127 | # as $AL (Alphabetic) | |
128 | # | |
129 | $ALPlus = [$AL $AI $SA $SG $XX]; | |
130 | ||
131 | # | |
132 | # Combining Marks. X $CM* behaves as if it were X. Rule LB6. | |
133 | # | |
134 | $ALcm = $ALPlus $CM*; | |
135 | $BAcm = $BA $CM*; | |
136 | $BBcm = $BB $CM*; | |
137 | $B2cm = $B2 $CM*; | |
138 | $CLcm = $CL $CM*; | |
139 | $CPcm = $CP $CM*; | |
140 | $EXcm = $EX $CM*; | |
141 | $GLcm = $GL $CM*; | |
142 | $HLcm = $HL $CM*; | |
143 | $HYcm = $HY $CM*; | |
144 | $H2cm = $H2 $CM*; | |
145 | $H3cm = $H3 $CM*; | |
146 | $IDcm = $ID $CM*; | |
147 | $INcm = $IN $CM*; | |
148 | $IScm = $IS $CM*; | |
149 | $JLcm = $JL $CM*; | |
150 | $JVcm = $JV $CM*; | |
151 | $JTcm = $JT $CM*; | |
152 | $NScm = $NS $CM*; | |
153 | $NUcm = $NU $CM*; | |
154 | $OPcm = $OP $CM*; | |
155 | $POcm = $PO $CM*; | |
156 | $PRcm = $PR $CM*; | |
157 | $QUcm = $QU $CM*; | |
158 | $RIcm = $RI $CM*; | |
159 | $SYcm = $SY $CM*; | |
160 | $WJcm = $WJ $CM*; | |
161 | ||
162 | ## ------------------------------------------------- | |
163 | ||
164 | !!forward; | |
165 | ||
166 | # | |
167 | # Each class of character can stand by itself as an unbroken token, with trailing combining stuff | |
168 | # | |
169 | $ALPlus $CM+; | |
170 | $BA $CM+; | |
171 | $BB $CM+; | |
172 | $B2 $CM+; | |
173 | $CL $CM+; | |
174 | $CP $CM+; | |
175 | $EX $CM+; | |
176 | $GL $CM+; | |
177 | $HL $CM+; | |
178 | $HY $CM+; | |
179 | $H2 $CM+; | |
180 | $H3 $CM+; | |
181 | $ID $CM+; | |
182 | $IN $CM+; | |
183 | $IS $CM+; | |
184 | $JL $CM+; | |
185 | $JV $CM+; | |
186 | $JT $CM+; | |
187 | $NS $CM+; | |
188 | $NU $CM+; | |
189 | $OP $CM+; | |
190 | $PO $CM+; | |
191 | $PR $CM+; | |
192 | $QU $CM+; | |
193 | $RI $CM+; | |
194 | $SY $CM+; | |
195 | $WJ $CM+; | |
196 | ||
197 | # | |
198 | # CAN_CM is the set of characters that may combine with CM combining chars. | |
199 | # Note that Linebreak UAX 14's concept of a combining char and the rules | |
200 | # for what they can combine with are _very_ different from the rest of Unicode. | |
201 | # | |
202 | # Note that $CM itself is left out of this set. If CM is needed as a base | |
203 | # it must be listed separately in the rule. | |
204 | # | |
205 | $CAN_CM = [^$SP $BK $CR $LF $NL $ZW $CM]; # Bases that can take CMs | |
206 | $CANT_CM = [ $SP $BK $CR $LF $NL $ZW $CM]; # Bases that can't take CMs | |
207 | ||
208 | # | |
209 | # AL_FOLLOW set of chars that can unconditionally follow an AL | |
210 | # Needed in rules where stand-alone $CM s are treated as AL. | |
211 | # Chaining is disabled with CM because it causes other failures, | |
212 | # so for this one case we need to manually list out longer sequences. | |
213 | # | |
214 | $AL_FOLLOW_NOCM = [$BK $CR $LF $NL $ZW $SP]; | |
215 | $AL_FOLLOW_CM = [$CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $HY $NS $IN $NU $ALPlus]; | |
216 | $AL_FOLLOW = [$AL_FOLLOW_NOCM $AL_FOLLOW_CM]; | |
217 | ||
218 | ||
219 | # | |
220 | # Rule LB 4, 5 Mandatory (Hard) breaks. | |
221 | # | |
222 | $LB4Breaks = [$BK $CR $LF $NL]; | |
223 | $LB4NonBreaks = [^$BK $CR $LF $NL]; | |
224 | $CR $LF {100}; | |
225 | ||
226 | # | |
227 | # LB 6 Do not break before hard line breaks. | |
228 | # | |
229 | $LB4NonBreaks? $LB4Breaks {100}; # LB 5 do not break before hard breaks. | |
230 | $CAN_CM $CM* $LB4Breaks {100}; | |
231 | $CM+ $LB4Breaks {100}; | |
232 | ||
233 | # LB 7 x SP | |
234 | # x ZW | |
235 | $LB4NonBreaks [$SP $ZW]; | |
236 | $CAN_CM $CM* [$SP $ZW]; | |
237 | $CM+ [$SP $ZW]; | |
238 | ||
239 | # | |
240 | # LB 8 Break after zero width space | |
241 | # TODO: ZW SP* <break> | |
242 | # An engine change is required to write the reverse rule for this. | |
243 | # For now, leave the Unicode 5.2 rule, ZW <break> | |
244 | # | |
245 | $LB8Breaks = [$LB4Breaks $ZW]; | |
246 | $LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]]; | |
247 | ||
248 | ||
249 | # Special forward rule for people & body part emoji: | |
250 | # don't break $ZWJ from subsequent $EmojiForSeqs | |
251 | $EmojiForSeqs $EmojiVar? $EmojiMods? $ZWJ $EmojiForSeqs; | |
252 | ||
253 | # LB 9 Combining marks. X $CM needs to behave like X, where X is not $SP, $BK $CR $LF $NL | |
254 | # $CM not covered by the above needs to behave like $AL | |
255 | # See definition of $CAN_CM. | |
256 | ||
257 | $CAN_CM $CM+; # Stick together any combining sequences that don't match other rules. | |
258 | $CM+; | |
259 | ||
260 | # | |
261 | # LB 11 Do not break before or after WORD JOINER & related characters. | |
262 | # | |
263 | $CAN_CM $CM* $WJcm; | |
264 | $LB8NonBreaks $WJcm; | |
265 | $CM+ $WJcm; | |
266 | ||
267 | $WJcm $CANT_CM; | |
268 | $WJcm $CAN_CM $CM*; | |
269 | ||
270 | # | |
271 | # LB 12 Do not break after NBSP and related characters. | |
272 | # GL x | |
273 | # | |
274 | $GLcm $CAN_CM $CM*; | |
275 | $GLcm $CANT_CM; | |
276 | ||
277 | # | |
278 | # LB 12a Do not break before NBSP and related characters ... | |
279 | # [^SP BA HY] x GL | |
280 | # | |
281 | [[$LB8NonBreaks] - [$SP $BA $HY]] $CM* $GLcm; | |
282 | $CM+ GLcm; | |
283 | ||
284 | ||
285 | ||
286 | # | |
287 | # LB 13 Don't break before ']' or '!' or ';' or '/', even after spaces. | |
288 | # | |
289 | $LB8NonBreaks $CL; | |
290 | $CAN_CM $CM* $CL; | |
291 | $CM+ $CL; # by rule 10, stand-alone CM behaves as AL | |
292 | ||
293 | $LB8NonBreaks $CP; | |
294 | $CAN_CM $CM* $CP; | |
295 | $CM+ $CP; # by rule 10, stand-alone CM behaves as AL | |
296 | ||
297 | $LB8NonBreaks $EX; | |
298 | $CAN_CM $CM* $EX; | |
299 | $CM+ $EX; # by rule 10, stand-alone CM behaves as AL | |
300 | ||
301 | $LB8NonBreaks $IS; | |
302 | $CAN_CM $CM* $IS; | |
303 | $CM+ $IS; # by rule 10, stand-alone CM behaves as AL | |
304 | ||
305 | $LB8NonBreaks $SY; | |
306 | $CAN_CM $CM* $SY; | |
307 | $CM+ $SY; # by rule 10, stand-alone CM behaves as AL | |
308 | ||
309 | ||
310 | # | |
311 | # LB 14 Do not break after OP, even after spaces | |
312 | # | |
313 | $OPcm $SP* $CAN_CM $CM*; | |
314 | $OPcm $SP* $CANT_CM; | |
315 | ||
316 | $OPcm $SP+ $CM+ $AL_FOLLOW?; # by rule 10, stand-alone CM behaves as AL | |
317 | ||
318 | # LB 15 | |
319 | $QUcm $SP* $OPcm; | |
320 | ||
321 | # LB 16 | |
322 | ($CLcm | $CPcm) $SP* $NScm; | |
323 | ||
324 | # LB 17 | |
325 | $B2cm $SP* $B2cm; | |
326 | ||
327 | # | |
328 | # LB 18 Break after spaces. | |
329 | # | |
330 | $LB18NonBreaks = [$LB8NonBreaks - [$SP]]; | |
331 | $LB18Breaks = [$LB8Breaks $SP]; | |
332 | ||
333 | ||
334 | # LB 19 | |
335 | # x QU | |
336 | $LB18NonBreaks $CM* $QUcm; | |
337 | $CM+ $QUcm; | |
338 | ||
339 | # QU x | |
340 | $QUcm .?; | |
341 | $QUcm $LB18NonBreaks $CM*; # Don't let a combining mark go onto $CR, $BK, etc. | |
342 | # TODO: I don't think this rule is needed. | |
343 | ||
344 | ||
345 | # LB 20 | |
346 | # <break> $CB | |
347 | # $CB <break> | |
348 | ||
349 | $LB20NonBreaks = [$LB18NonBreaks - $CB]; | |
350 | ||
351 | # LB 21 x (BA | HY | NS) | |
352 | # BB x | |
353 | # | |
354 | $LB20NonBreaks $CM* ($BAcm | $HYcm | $NScm); | |
355 | ||
356 | $BBcm [^$CB]; # $BB x | |
357 | $BBcm $LB20NonBreaks $CM*; | |
358 | ||
359 | # LB 21a Don't break after Hebrew + Hyphen | |
360 | # HL (HY | BA) x | |
361 | # | |
362 | $HLcm ($HYcm | $BAcm) [^$CB]?; | |
363 | ||
364 | # LB 21b (forward) Don't break between SY and HL | |
365 | # (break between HL and SY already disallowed by LB 13 above) | |
366 | $SYcm $HLcm; | |
367 | ||
368 | # LB 22 | |
369 | ($ALcm | $HLcm) $INcm; | |
370 | $CM+ $INcm; # by rule 10, any otherwise unattached CM behaves as AL | |
371 | $IDcm $INcm; | |
372 | $INcm $INcm; | |
373 | $NUcm $INcm; | |
374 | ||
375 | ||
376 | # $LB 23 | |
377 | $IDcm $POcm; | |
378 | $ALcm $NUcm; # includes $LB19 | |
379 | $HLcm $NUcm; | |
380 | $CM+ $NUcm; # Rule 10, any otherwise unattached CM behaves as AL | |
381 | $NUcm $ALcm; | |
382 | $NUcm $HLcm; | |
383 | ||
384 | # | |
385 | # LB 24 | |
386 | # | |
387 | $PRcm $IDcm; | |
388 | $PRcm ($ALcm | $HLcm); | |
389 | $POcm ($ALcm | $HLcm); | |
390 | ||
391 | # | |
392 | # LB 25 Numbers. | |
393 | # | |
394 | ($PRcm | $POcm)? ($OPcm | $HYcm)? $NUcm ($NUcm | $SYcm | $IScm)* ($CLcm | $CPcm)? ($PRcm | $POcm)?; | |
395 | ||
396 | # LB 26 Do not break a Korean syllable | |
397 | # | |
398 | $JLcm ($JLcm | $JVcm | $H2cm | $H3cm); | |
399 | ($JVcm | $H2cm) ($JVcm | $JTcm); | |
400 | ($JTcm | $H3cm) $JTcm; | |
401 | ||
402 | # LB 27 Treat korean Syllable Block the same as ID (don't break it) | |
403 | ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $INcm; | |
404 | ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $POcm; | |
405 | $PRcm ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm); | |
406 | ||
407 | ||
408 | # LB 28 Do not break between alphabetics | |
409 | # | |
410 | ($ALcm | $HLcm) ($ALcm | $HLcm); | |
411 | $CM+ ($ALcm | $HLcm); # The $CM+ is from rule 10, an unattached CM is treated as AL | |
412 | ||
413 | # LB 29 | |
414 | $IScm ($ALcm | $HLcm); | |
415 | ||
416 | # LB 30 | |
417 | ($ALcm | $HLcm | $NUcm) $OPcm; | |
418 | $CM+ $OPcm; # The $CM+ is from rule 10, an unattached CM is treated as AL. | |
419 | $CPcm ($ALcm | $HLcm | $NUcm); | |
420 | ||
421 | # LB 30a Do not break between regional indicators. | |
422 | $RIcm $RIcm; | |
423 | ||
424 | # Special forward rule for people & body part emoji: | |
425 | # don't break between relevant emoji and $EmojiMods | |
426 | $EmojiForMods $EmojiVar? $EmojiMods; | |
427 | ||
428 | # | |
429 | # Reverse Rules. | |
430 | # | |
431 | ## ------------------------------------------------- | |
432 | ||
433 | !!reverse; | |
434 | ||
435 | $CM+ $ALPlus; | |
436 | $CM+ $BA; | |
437 | $CM+ $BB; | |
438 | $CM+ $B2; | |
439 | $CM+ $CL; | |
440 | $CM+ $CP; | |
441 | $CM+ $EX; | |
442 | $CM+ $GL; | |
443 | $CM+ $HL; | |
444 | $CM+ $HY; | |
445 | $CM+ $H2; | |
446 | $CM+ $H3; | |
447 | $CM+ $ID; | |
448 | $CM+ $IN; | |
449 | $CM+ $IS; | |
450 | $CM+ $JL; | |
451 | $CM+ $JV; | |
452 | $CM+ $JT; | |
453 | $CM+ $NS; | |
454 | $CM+ $NU; | |
455 | $CM+ $OP; | |
456 | $CM+ $PO; | |
457 | $CM+ $PR; | |
458 | $CM+ $QU; | |
459 | $CM+ $RI; | |
460 | $CM+ $SY; | |
461 | $CM+ $WJ; | |
462 | $CM+; | |
463 | ||
464 | ||
465 | # | |
466 | # Sequences of the form (shown forwards) | |
467 | # [CANT_CM] <break> [CM] [whatever] | |
468 | # The CM needs to behave as an AL | |
469 | # | |
470 | $AL_FOLLOW $CM+ / ( | |
471 | [$BK $CR $LF $NL $ZW {eof}] | | |
472 | $SP+ $CM+ $SP | | |
473 | $SP+ $CM* ([^$OP $CM $SP] | [$AL {eof}])); # if LB 14 will match, need to surpress this break. | |
474 | # LB14 says OP SP* x . | |
475 | # becomes OP SP* x AL | |
476 | # becomes OP SP* x CM+ AL_FOLLOW | |
477 | # | |
478 | # Further note: the $AL in [$AL {eof}] is only to work around | |
479 | # a rule compiler bug which complains about | |
480 | # empty sets otherwise. | |
481 | ||
482 | # | |
483 | # Sequences of the form (shown forwards) | |
484 | # [CANT_CM] <break> [CM] <break> [PR] | |
485 | # The CM needs to behave as an AL | |
486 | # This rule is concerned about getting the second of the two <breaks> in place. | |
487 | # | |
488 | ||
489 | [$PR ] / $CM+ [$BK $CR $LF $NL $ZW $SP {eof}]; | |
490 | ||
491 | ||
492 | ||
493 | # LB 4, 5, 5 | |
494 | ||
495 | $LB4Breaks [$LB4NonBreaks-$CM]; | |
496 | $LB4Breaks $CM+ $CAN_CM; | |
497 | $LF $CR; | |
498 | ||
499 | ||
500 | # LB 7 x SP | |
501 | # x ZW | |
502 | [$SP $ZW] [$LB4NonBreaks-$CM]; | |
503 | [$SP $ZW] $CM+ $CAN_CM; | |
504 | ||
505 | # LB 8 ZW SP* <break> | |
506 | # TODO: to implement this, we need more than one look-ahead hard break in play at a time. | |
507 | # Requires an engine enhancement. | |
508 | # / $SP* $ZW | |
509 | ||
510 | # Special reverse rule for people & body part emoji: | |
511 | # don't break $ZWJ from subsequent $EmojiForSeqs | |
512 | $EmojiForSeqs $ZWJ $EmojiMods? $EmojiVar? $EmojiForSeqs; | |
513 | ||
514 | # LB 9,10 Combining marks. | |
515 | # X $CM needs to behave like X, where X is not $SP or controls. | |
516 | # $CM not covered by the above needs to behave like $AL | |
517 | # Stick together any combining sequences that don't match other rules. | |
518 | $CM+ $CAN_CM; | |
519 | ||
520 | ||
521 | # LB 11 | |
522 | $CM* $WJ $CM* $CAN_CM; | |
523 | $CM* $WJ [$LB8NonBreaks-$CM]; | |
524 | ||
525 | $CANT_CM $CM* $WJ; | |
526 | $CM* $CAN_CM $CM* $WJ; | |
527 | ||
528 | # LB 12a | |
529 | # [^SP BA HY] x GL | |
530 | # | |
531 | $CM* $GL $CM* [$LB8NonBreaks-[$CM $SP $BA $HY]]; | |
532 | ||
533 | # LB 12 | |
534 | # GL x | |
535 | # | |
536 | $CANT_CM $CM* $GL; | |
537 | $CM* $CAN_CM $CM* $GL; | |
538 | ||
539 | ||
540 | # LB 13 | |
541 | $CL $CM+ $CAN_CM; | |
542 | $CP $CM+ $CAN_CM; | |
543 | $EX $CM+ $CAN_CM; | |
544 | $IS $CM+ $CAN_CM; | |
545 | $SY $CM+ $CAN_CM; | |
546 | ||
547 | $CL [$LB8NonBreaks-$CM]; | |
548 | $CP [$LB8NonBreaks-$CM]; | |
549 | $EX [$LB8NonBreaks-$CM]; | |
550 | $IS [$LB8NonBreaks-$CM]; | |
551 | $SY [$LB8NonBreaks-$CM]; | |
552 | ||
553 | # Rule 13 & 14 taken together for an edge case. | |
554 | # Match this, shown forward | |
555 | # OP SP+ ($CM+ behaving as $AL) (CL | CP | EX | IS | IY) | |
556 | # This really wants to chain at the $CM+ (which is acting as an $AL) | |
557 | # except for $CM chaining being disabled. | |
558 | [$CL $CP $EX $IS $SY] $CM+ $SP+ $CM* $OP; | |
559 | ||
560 | # LB 14 OP SP* x | |
561 | # | |
562 | $CM* $CAN_CM $SP* $CM* $OP; | |
563 | $CANT_CM $SP* $CM* $OP; | |
564 | $AL_FOLLOW? $CM+ $SP $SP* $CM* $OP; # by LB 10, behaves like $AL_FOLLOW? $AL $SP* $CM* $OP | |
565 | ||
566 | $AL_FOLLOW_NOCM $CM+ $SP+ $CM* $OP; | |
567 | $CM* $AL_FOLLOW_CM $CM+ $SP+ $CM* $OP; | |
568 | $SY $CM $SP+ $OP; # TODO: Experiment. Remove. | |
569 | ||
570 | ||
571 | ||
572 | # LB 15 | |
573 | $CM* $OP $SP* $CM* $QU; | |
574 | ||
575 | # LB 16 | |
576 | $CM* $NS $SP* $CM* ($CL | $CP); | |
577 | ||
578 | # LB 17 | |
579 | $CM* $B2 $SP* $CM* $B2; | |
580 | ||
581 | # LB 18 break after spaces | |
582 | # Nothing explicit needed here. | |
583 | ||
584 | ||
585 | # | |
586 | # LB 19 | |
587 | # | |
588 | $CM* $QU $CM* $CAN_CM; # . x QU | |
589 | $CM* $QU $LB18NonBreaks; | |
590 | ||
591 | ||
592 | $CM* $CAN_CM $CM* $QU; # QU x . | |
593 | $CANT_CM $CM* $QU; | |
594 | ||
595 | # | |
596 | # LB 20 Break before and after CB. | |
597 | # nothing needed here. | |
598 | # | |
599 | ||
600 | # LB 21 | |
601 | $CM* ($BA | $HY | $NS) $CM* [$LB20NonBreaks-$CM]; # . x (BA | HY | NS) | |
602 | ||
603 | $CM* [$LB20NonBreaks-$CM] $CM* $BB; # BB x . | |
604 | [^$CB] $CM* $BB; # | |
605 | ||
606 | # LB21a | |
607 | [^$CB] $CM* ($HY | $BA) $CM* $HL; | |
608 | ||
609 | # LB21b (reverse) | |
610 | $CM* $HL $CM* $SY; | |
611 | ||
612 | # LB 22 | |
613 | $CM* $IN $CM* ($ALPlus | $HL); | |
614 | $CM* $IN $CM* $ID; | |
615 | $CM* $IN $CM* $IN; | |
616 | $CM* $IN $CM* $NU; | |
617 | ||
618 | # LB 23 | |
619 | $CM* $PO $CM* $ID; | |
620 | $CM* $NU $CM* ($ALPlus | $HL); | |
621 | $CM* ($ALPlus | $HL) $CM* $NU; | |
622 | ||
623 | # LB 24 | |
624 | $CM* $ID $CM* $PR; | |
625 | $CM* ($ALPlus | $HL) $CM* $PR; | |
626 | $CM* ($ALPlus | $HL) $CM* $PO; | |
627 | ||
628 | ||
629 | # LB 25 | |
630 | ($CM* ($PR | $PO))? ($CM* ($CL | $CP))? ($CM* ($NU | $IS | $SY))* $CM* $NU ($CM* ($OP | $HY))? ($CM* ($PR | $PO))?; | |
631 | ||
632 | # LB 26 | |
633 | $CM* ($H3 | $H2 | $JV | $JL) $CM* $JL; | |
634 | $CM* ($JT | $JV) $CM* ($H2 | $JV); | |
635 | $CM* $JT $CM* ($H3 | $JT); | |
636 | ||
637 | # LB 27 | |
638 | $CM* $IN $CM* ($H3 | $H2 | $JT | $JV | $JL); | |
639 | $CM* $PO $CM* ($H3 | $H2 | $JT | $JV | $JL); | |
640 | $CM* ($H3 | $H2 | $JT | $JV | $JL) $CM* $PR; | |
641 | ||
642 | # LB 28 | |
643 | $CM* ($ALPlus | $HL) $CM* ($ALPlus | $HL); | |
644 | ||
645 | ||
646 | # LB 29 | |
647 | $CM* ($ALPlus | $HL) $CM* $IS; | |
648 | ||
649 | # LB 30 | |
650 | $CM* $OP $CM* ($ALPlus | $HL | $NU); | |
651 | $CM* ($ALPlus | $HL | $NU) $CM* $CP; | |
652 | ||
653 | # LB 30a | |
654 | $CM* $RI $CM* $RI; | |
655 | ||
656 | # Special reverse rule for people & body part emoji: | |
657 | # don't break between relevant emoji and $EmojiMods | |
658 | $EmojiMods $EmojiVar? $EmojiForMods; | |
659 | ||
660 | ## ------------------------------------------------- | |
661 | ||
662 | !!safe_reverse; | |
663 | ||
664 | # LB 9 | |
665 | $CM+ [^$CM $BK $CR $LF $NL $ZW $SP]; | |
666 | $CM+ $SP / .; | |
667 | ||
668 | # LB 14 | |
669 | $SP+ $CM* $OP; | |
670 | ||
671 | # LB 15 | |
672 | $SP+ $CM* $QU; | |
673 | ||
674 | # LB 16 | |
675 | $SP+ $CM* ($CL | $CP); | |
676 | ||
677 | # LB 17 | |
678 | $SP+ $CM* $B2; | |
679 | ||
680 | # LB 21 | |
681 | $CM* ($HY | $BA) $CM* $HL; | |
682 | ||
683 | # LB 25 | |
684 | ($CM* ($IS | $SY))+ $CM* $NU; | |
685 | ($CL | $CP) $CM* ($NU | $IS | $SY); | |
686 | ||
687 | # For dictionary-based break | |
688 | $dictionary $dictionary; | |
689 | ||
690 | ## ------------------------------------------------- | |
691 | ||
692 | !!safe_forward; | |
693 | ||
694 | # Skip forward over all character classes that are involved in | |
695 | # rules containing patterns with possibly more than one char | |
696 | # of context. | |
697 | # | |
698 | # It might be slightly more efficient to have specific rules | |
699 | # instead of one generic one, but only if we could | |
700 | # turn off rule chaining. We don't want to move more | |
701 | # than necessary. | |
702 | # | |
703 | [$CM $OP $QU $CL $CP $B2 $PR $HY $BA $SP $dictionary]+ [^$CM $OP $QU $CL $CP $B2 $PR $HY $BA $dictionary]; | |
704 | $dictionary $dictionary; | |
705 |