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