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