1 # Copyright (C) 2016 and later: Unicode, Inc. and others.
2 # License & terms of use: http://www.unicode.org/copyright.html
3 # Copyright (c) 2002-2016 International Business Machines Corporation and
4 # others. All Rights Reserved.
6 # file: line_loose_fi.txt
9 # Implement default line breaking as defined by
10 # Unicode Standard Annex #14 Revision 40 for Unicode 11.0
11 # http://www.unicode.org/reports/tr14/
12 # tailored as noted in 3rd paragraph below.
14 # TODO: Rule LB 8 remains as it was in Unicode 5.2
15 # This is only because of a limitation of ICU break engine implementation,
16 # not because the older behavior is desirable.
18 # This tailors the line break behavior both for Finnish and to correpond to CSS
19 # line-break=loose (BCP47 -u-lb-loose) as defined for languages other than
21 # It sets characters of class CJ to behave like ID.
22 # In addition, it allows breaks before 3005, 303B, 309D, 309E, 30FD, 30FE (all NS).
24 # Character Classes defined by TR 14.
28 !!quoted_literals_only;
30 $AI = [:LineBreak = Ambiguous:];
31 $AL = [:LineBreak = Alphabetic:];
32 $BA = [:LineBreak = Break_After:];
33 $HH = [\u2010]; # \u2010 is HYPHEN, default line break is BA.
34 $BB = [:LineBreak = Break_Before:];
35 $BK = [:LineBreak = Mandatory_Break:];
36 $B2 = [:LineBreak = Break_Both:];
37 $CB = [:LineBreak = Contingent_Break:];
38 $CJ = [:LineBreak = Conditional_Japanese_Starter:];
39 $CL = [:LineBreak = Close_Punctuation:];
40 # $CM = [:LineBreak = Combining_Mark:];
41 $CP = [:LineBreak = Close_Parenthesis:];
42 $CR = [:LineBreak = Carriage_Return:];
43 $EB = [[:LineBreak = EB:] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C];
44 $EM = [:LineBreak = EM:];
45 $EX = [:LineBreak = Exclamation:];
46 $GL = [:LineBreak = Glue:];
47 $HL = [:LineBreak = Hebrew_Letter:];
48 $HY = [:LineBreak = Hyphen:];
49 $H2 = [:LineBreak = H2:];
50 $H3 = [:LineBreak = H3:];
51 # CSS Loose tailoring: CJ resolves to ID
52 $ID = [[:LineBreak = Ideographic:] $CJ];
53 $IN = [:LineBreak = Inseperable:];
54 $IS = [:LineBreak = Infix_Numeric:];
55 $JL = [:LineBreak = JL:];
56 $JV = [:LineBreak = JV:];
57 $JT = [:LineBreak = JT:];
58 $LF = [:LineBreak = Line_Feed:];
59 $NL = [:LineBreak = Next_Line:];
60 $NSX = [\u3005 \u303B \u309D \u309E \u30FD \u30FE];
61 $NS = [[:LineBreak = Nonstarter:] - $NSX];
62 $NU = [:LineBreak = Numeric:];
63 $OP = [:LineBreak = Open_Punctuation:];
64 $PO = [:LineBreak = Postfix_Numeric:];
65 $PR = [:LineBreak = Prefix_Numeric:];
66 $QU = [:LineBreak = Quotation:];
67 $RI = [:LineBreak = Regional_Indicator:];
68 $SA = [:LineBreak = Complex_Context:];
69 $SG = [:LineBreak = Surrogate:];
70 $SP = [:LineBreak = Space:];
71 $SY = [:LineBreak = Break_Symbols:];
72 $WJ = [:LineBreak = Word_Joiner:];
73 $XX = [:LineBreak = Unknown:];
74 $ZW = [:LineBreak = ZWSpace:];
75 $ZWJ = [:LineBreak = ZWJ:];
77 # By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly
78 # list it in the numerous rules that use CM.
79 # By LB1, SA characters with general categor of Mn or Mc also resolve to CM.
81 $CM = [[:LineBreak = Combining_Mark:] $ZWJ [$SA & [[:Mn:][:Mc:]]]];
83 # Dictionary character set, for triggering language-based break engines. Currently
84 # limited to LineBreak=Complex_Context (SA).
89 # Rule LB1. By default, treat AI (characters with ambiguous east Asian width),
90 # SA (Dictionary chars, excluding Mn and Mc)
91 # SG (Unpaired Surrogates)
92 # XX (Unknown, unassigned)
95 $ALPlus = [$AL $AI $SG $XX [$SA-[[:Mn:][:Mc:]]]];
98 ## -------------------------------------------------
101 # CAN_CM is the set of characters that may combine with CM combining chars.
102 # Note that Linebreak UAX 14's concept of a combining char and the rules
103 # for what they can combine with are _very_ different from the rest of Unicode.
105 # Note that $CM itself is left out of this set. If CM is needed as a base
106 # it must be listed separately in the rule.
108 $CAN_CM = [^$SP $BK $CR $LF $NL $ZW $CM]; # Bases that can take CMs
109 $CANT_CM = [ $SP $BK $CR $LF $NL $ZW $CM]; # Bases that can't take CMs
112 # AL_FOLLOW set of chars that can unconditionally follow an AL
113 # Needed in rules where stand-alone $CM s are treated as AL.
115 $AL_FOLLOW = [$BK $CR $LF $NL $ZW $SP $CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $HH $HY $NS $IN $NU $PR $PO $ALPlus];
119 # Rule LB 4, 5 Mandatory (Hard) breaks.
121 $LB4Breaks = [$BK $CR $LF $NL];
122 $LB4NonBreaks = [^$BK $CR $LF $NL $CM];
126 # LB 6 Do not break before hard line breaks.
128 $LB4NonBreaks? $LB4Breaks {100}; # LB 5 do not break before hard breaks.
129 $CAN_CM $CM* $LB4Breaks {100};
130 ^$CM+ $LB4Breaks {100};
134 $LB4NonBreaks [$SP $ZW];
135 $CAN_CM $CM* [$SP $ZW];
139 # LB 8 Break after zero width space
140 # TODO: ZW SP* <break>
141 # An engine change is required to write the reverse rule for this.
142 # For now, leave the Unicode 5.2 rule, ZW <break>
144 $LB8Breaks = [$LB4Breaks $ZW];
145 $LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]];
147 # LB 8a ZWJ x Do not break Emoji ZWJ sequences.
151 # LB 9 Combining marks. X $CM needs to behave like X, where X is not $SP, $BK $CR $LF $NL
152 # $CM not covered by the above needs to behave like $AL
153 # See definition of $CAN_CM.
155 $CAN_CM $CM+; # Stick together any combining sequences that don't match other rules.
159 # LB 11 Do not break before or after WORD JOINER & related characters.
168 # LB 12 Do not break after NBSP and related characters.
174 # LB 12a Do not break before NBSP and related characters ...
177 [[$LB8NonBreaks] - [$SP $BA $HH $HY]] $CM* $GL;
183 # LB 13 Don't break before ']' or '!' or ';' or '/', even after spaces.
187 ^$CM+ $CL; # by rule 10, stand-alone CM behaves as AL
191 ^$CM+ $CP; # by rule 10, stand-alone CM behaves as AL
195 ^$CM+ $EX; # by rule 10, stand-alone CM behaves as AL
199 ^$CM+ $IS; # by rule 10, stand-alone CM behaves as AL
203 ^$CM+ $SY; # by rule 10, stand-alone CM behaves as AL
207 # LB 14 Do not break after OP, even after spaces
211 $OP $CM* $SP+ $CM+ $AL_FOLLOW?; # by rule 10, stand-alone CM behaves as AL
212 # by rule 8, CM following a SP is stand-alone.
218 # Do not break between closing punctuation and $NS, even with intervening spaces
219 # But DO allow a break between closing punctuation and $NSX, don't include it here
220 ($CL | $CP) $CM* $SP* $NS;
226 # LB 18 Break after spaces.
228 $LB18NonBreaks = [$LB8NonBreaks - [$SP]];
229 $LB18Breaks = [$LB8Breaks $SP];
234 $LB18NonBreaks $CM* $QU;
245 $LB20NonBreaks = [$LB18NonBreaks - $CB];
247 # LB 20.09 added rule for Finnish tailoring
248 # LB 21 x (BA | HY | NS)
251 # DO allow breaks here before NSX, so don't include it
252 $LB20NonBreaks $CM* ($BA | $HH | $HY | $NS) $CM* / $AL;
253 $LB20NonBreaks $CM* ($BA | $HH | $HY | $NS);
255 ^$CM+ ($BA | $HY | $HH | $NS);
257 $BB $CM* [^$CB]; # $BB x
258 $BB $CM* $LB20NonBreaks;
260 # LB 21a Don't break after Hebrew + Hyphen
263 $HL $CM* ($HY | $BA | $HH) $CM* [^$CB]?;
265 # LB 21b (forward) Don't break between SY and HL
266 # (break between HL and SY already disallowed by LB 13 above)
270 ($ALPlus | $HL) $CM* $IN;
271 ^$CM+ $IN; # by rule 10, any otherwise unattached CM behaves as AL
273 ($ID | $EB | $EM) $CM* $IN;
274 # $IN $CM* $IN; # delete this rule for CSS loose
280 ($ALPlus | $HL) $CM* $NU;
281 ^$CM+ $NU; # Rule 10, any otherwise unattached CM behaves as AL
282 $NU $CM* ($ALPlus | $HL);
286 $PR $CM* ($ID | $EB | $EM);
287 ($ID | $EB | $EM) $CM* $PO;
293 ($PR | $PO) $CM* ($ALPlus | $HL);
294 ($ALPlus | $HL) $CM* ($PR | $PO);
295 ^$CM+ ($PR | $PO); # Rule 10, any otherwise unattached CM behaves as AL
300 (($PR | $PO) $CM*)? (($OP | $HY) $CM*)? $NU ($CM* ($NU | $SY | $IS))*
301 ($CM* ($CL | $CP))? ($CM* ($PR | $PO))?;
303 # LB 26 Do not break a Korean syllable
305 $JL $CM* ($JL | $JV | $H2 | $H3);
306 ($JV | $H2) $CM* ($JV | $JT);
307 ($JT | $H3) $CM* $JT;
309 # LB 27 Treat korean Syllable Block the same as ID (don't break it)
310 ($JL | $JV | $JT | $H2 | $H3) $CM* $IN;
311 ($JL | $JV | $JT | $H2 | $H3) $CM* $PO;
312 $PR $CM* ($JL | $JV | $JT | $H2 | $H3);
315 # LB 28 Do not break between alphabetics
317 ($ALPlus | $HL) $CM* ($ALPlus | $HL);
318 ^$CM+ ($ALPlus | $HL); # The $CM+ is from rule 10, an unattached CM is treated as AL
321 $IS $CM* ($ALPlus | $HL);
324 ($ALPlus | $HL | $NU) $CM* $OP;
325 ^$CM+ $OP; # The $CM+ is from rule 10, an unattached CM is treated as AL.
326 $CP $CM* ($ALPlus | $HL | $NU);
328 # LB 30a Do not break between regional indicators. Break after pairs of them.
329 # Tricky interaction with LB8a: ZWJ x . together with ZWJ acting like a CM.
330 $RI $CM* $RI / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM]];
331 $RI $CM* $RI $CM* [$CM-$ZWJ] / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM]];
332 $RI $CM* $RI $CM* [$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $ZWJ {eof}];
333 # note: the preceding rule includes {eof} rather than having the last [set] term qualified with '?'
334 # because of the chain-out behavior difference. The rule must chain out only from the [set characters],
335 # not from the preceding $RI or $CM, which it would be able to do if the set were optional.
337 # LB 30b Do not break between an Emoji Base and an Emoji Modifier
340 # LB 31 Break everywhere else.
341 # Match a single code point if no other rule applies.