2 # Copyright (C) 2016 and later: Unicode, Inc. and others.
3 # License & terms of use: http://www.unicode.org/copyright.html
4 # Copyright (c) 2016, International Business Machines Corporation and others. All Rights Reserved.
6 # file: line_loose_cj.txt
8 # Reference Line Break rules for intltest rbbi/RBBIMonkeyTest.
9 # Rules derived from Unicode Standard Annex #14 Revision 40 for Unicode 11.0
11 # Note: Rule syntax and the monkey test itself are still a work in progress.
12 # They are expected to change with review and the addition of support for rule tailoring.
15 # Implement default line breaking as defined by
16 # Unicode Standard Annex #14 Revision 34 for Unicode 8.0
17 # http://www.unicode.org/reports/tr14/
18 # tailored as noted in 2nd paragraph below..
20 # This tailors the line break behavior to correspond to CSS
21 # line-break=loose (BCP47 -u-lb-loose) as defined for Chinese & Japanese.
22 # It sets characters of class CJ to behave like ID.
23 # In addition, it allows breaks:
24 # * before hyphens 2010 & 2013 (both BA) and 301C, 30A0 (both NS)
25 # * before iteration marks 3005, 303B, 309D, 309E, 30FD, 30FE (all NS)
26 # * between characters of LineBreak class IN such as 2026
27 # * before some centered punct 203C, 2047, 2048, 2049, 30FB, FF1A, FF1B,
28 # FF65 (all NS) and FF01, FF1F (both EX).
29 # * before suffix characters with LineBreak class PO and EastAsianWidth A,F,W;
30 # this includes: 00B0 2030 2032 2033 2035 2103 2109 FE6A FF05 FFE0
31 # * after prefix characters with LineBreak class PR and EastAsianWidth A,F,W;
32 # this includes: 00A4 00B1 20AC 2116 FE69 FF04 FFE1 FFE5 FFE6
33 # It allows breaking before 201C and after 201D, for zh_Hans, zh_Hant, and ja.
40 AI = [:LineBreak = Ambiguous:];
41 AL = [:LineBreak = Alphabetic:];
42 BAX = [\u2010 \u2013];
43 BA = [[:LineBreak = Break_After:] - BAX];
44 HH = [\u2010]; # \u2010 is HYPHEN, default line break is BA.
45 BB = [:LineBreak = Break_Before:];
46 BK = [:LineBreak = Mandatory_Break:];
47 B2 = [:LineBreak = Break_Both:];
48 CB = [:LineBreak = Contingent_Break:];
49 CJ = [:LineBreak = Conditional_Japanese_Starter:];
50 CL = [[:LineBreak = Close_Punctuation:] \u201d];
51 CMS = [:LineBreak = Combining_Mark:];
52 CP = [:LineBreak = Close_Parenthesis:];
53 CR = [:LineBreak = Carriage_Return:];
54 EB = [[:LineBreak = EB:] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C];
55 EM = [:LineBreak = EM:];
56 EXX = [\uFF01 \uFF1F];
57 EX = [[:LineBreak = Exclamation:] - EXX];
58 GL = [:LineBreak = Glue:];
59 HL = [:LineBreak = Hebrew_Letter:];
60 HY = [:LineBreak = Hyphen:];
61 H2 = [:LineBreak = H2:];
62 H3 = [:LineBreak = H3:];
63 ID = [[:LineBreak = Ideographic:] CJ]; # CSS Loose tailoring: CJ resolves to ID
64 IN = [:LineBreak = Inseperable:];
65 IS = [:LineBreak = Infix_Numeric:];
66 JL = [:LineBreak = JL:];
67 JV = [:LineBreak = JV:];
68 JT = [:LineBreak = JT:];
69 LF = [:LineBreak = Line_Feed:];
70 NL = [:LineBreak = Next_Line:];
71 NSX = [\u301C \u30A0 \u3005 \u303B \u309D \u309E \u30FD \u30FE \u203C \u2047 \u2048 \u2049 \u30FB \uFF1A \uFF1B \uFF65];
72 NS = [[:LineBreak = Nonstarter:] - NSX];
73 NU = [:LineBreak = Numeric:];
74 OP = [[:LineBreak = Open_Punctuation:] \u201c];
75 POX = [\u00B0 \u2030 \u2032 \u2033 \u2035 \u2103 \u2109 \uFE6A \uFF05 \uFFE0];
76 PO = [[:LineBreak = Postfix_Numeric:] - POX];
77 PRX = [\u00A4 \u00B1 \u20AC \u2116 \uFE69 \uFF04 \uFFE1 \uFFE5 \uFFE6];
78 PR = [[:LineBreak = Prefix_Numeric:] - PRX];
79 QU = [[:LineBreak = Quotation:] - [\u201c\u201d]];
80 RI = [:LineBreak = Regional_Indicator:];
81 SA = [:LineBreak = Complex_Context:];
82 SG = [:LineBreak = Surrogate:];
83 SP = [:LineBreak = Space:];
84 SY = [:LineBreak = Break_Symbols:];
85 WJ = [:LineBreak = Word_Joiner:];
86 XX = [:LineBreak = Unknown:];
87 ZW = [:LineBreak = ZWSpace:];
88 ZWJ = [:LineBreak = ZWJ:];
90 # LB1 - Resolve AI, CB, CJ, SA, SG, and XX into other line breaking classes
94 # By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly
95 # list it in the numerous rules that use CM.
104 LB6: . (BK | CR | LF | NL);
105 LB6.1: [^BK CR LF NL SP ZW] CM* (BK | CR | LF | NL);
107 # LB8 break after ZW SP*.
108 # Precedes LB7 because both rules will match the sequences like ZW SP,
109 # and LB8 must take precedence.
111 LB8: ZW SP* ÷ [^ZW SP BK CR LF NL];
113 # Numbers. Equivalent to Tailoring example 8 from UAX 14.
114 # Moved up, before LB14, because it can match longer sequences which must take precedence.
115 # Loose_cj tailoring: do not include $PRX at the beginning or $POX at the end.
116 LB25: ((PR | PO | POX)CM*)? ((OP | HY)CM*)? (IS CM*)? NU (CM*(NU | SY | IS))* (CM*(CL | CP))? (CM*(PR | PRX | PO))?;
119 # Moved up, before LB7, because they can match a longer sequence that would also match LB7.
120 # For example, the sequence "OP CM SP AL" matches LB14
121 # while the prefix of it, "OP CM SP" matches LB7.1
124 # LB 14a Break before an IS that begins a number and follows a space.
125 LB14a: SP ÷ IS CM* NU;
128 LB14b.1: [^SP] CM* IS;
132 LB16: (CL | CP)CM* SP* NS;
136 # LB7 Do not break before spaces or zero width space.
138 LB7.1: [^ZW SP] CM* [SP ZW];
139 LB7.2: [ZW SP] [SP ZW];
143 # Don't match a CM on the right - let other rules pick up CM sequences, where
144 # the ZWJ behaves as just another generic CM.
149 # LB10: Unattached CM -> AL
154 LB11.1: [^SP] CM* WJ;
156 LB11.3: WJ CM* [^CM];
160 LB12a: [^SP BA BAX HY] CM* GL;
162 # LB 13 Do not break before ‘]’ or ‘!’ or ‘/’, even after spaces.
163 LB13.1: [^SP] CM* [CL CP EX SY];
164 LB13.2: SP [CL CP EX SY];
167 # LB 14-17 are moved above LB 7.
172 LB19.1: QU CM* [^CM];
174 # LB 20 Break before and after CB.
175 # Interaction with LB8a: ZWJ x . is tricky because CM includes ZWJ.
176 # ZWJ acts like a CM to the left, combining with CB.
177 # ZWJ acts independently to the right, no break after by LB8a.
178 LB20.1: . CM* ZWJ CB;
181 LB20.3: CB CM* ZWJ [^CM];
184 # LB 20.09 Don't break between Hyphens and Letters when there is a break preceding the hyphen.
185 LB20.09: ^(HY | HH) CM* AL;
187 # Note: Rule 21a must come before 21 to prevent 21.1 from matching HL BA, then
188 # not picking up the continuing match after the BA from 21a.
189 # LB 21a Don't break after Hebrew + Hyphen
192 LB21a: HL CM* (HY | BA | BAX) CM* [^CM CB]?;
194 LB21.1: . CM* [BA HY NS];
195 LB21.2: BB CM* [^CM CB];
199 LB22.1: (AL | HL | CM) CM* IN; # The CM is from LB10, treat an unattached CM as AL.
201 LB22.3: (ID | EB | EM) CM* IN;
202 # LB22.4: IN CM* IN; # delete this rule for CSS loose.
205 LB23.1: (AL | HL | CM) CM* NU;
206 LB23.2: NU CM* (AL | HL);
208 LB23a.1: PR CM* (ID | EB | EM);
209 LB23a.2: (ID | EB | EM) CM* PO;
211 LB24.2: (PR | PO | POX) CM* (AL | HL);
212 LB24.3: (AL | HL | CM) CM* (PR | PO | POX);
215 LB26.1: JL CM* (JL | JV | H2 | H3);
216 LB26.2: (JV | H2) CM* (JV | JT);
217 LB26.3: (JT | H3) CM* JT;
219 LB27.1: (JL | JV | JT | H2 | H3) CM* IN;
220 LB27.2: (JL | JV | JT | H2 | H3) CM* PO;
221 LB27.3: PR CM* (JL | JV | JT | H2 | H3);
223 # LB28 Do not break between Alphabetics.
224 # Unattached (leading) CM treated as AL.
225 LB28: (AL | HL | CM)CM* (AL | HL);
227 LB29: IS CM* (AL | HL);
229 # LB30 is adjusted for unattached leading CM being treated as AL.
230 LB30.1: (AL | CM | HL | NU) CM* OP;
231 LB30.2: CP CM* (AL | HL | NU);
233 # LB30a keep pairs of RI together.
234 LB30a.1: RI CM* RI ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS CM];
235 LB30a.2: RI CM* RI CM* CMS ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS CM];
236 LB30a.3: RI CM* RI CM* [BK CR LF NL SP ZW WJ GL CL CP EX IS SY QU BA HY NS ZWJ]?;
238 # LB30b Do not break between Emoji Base and Emoji Modifier
241 # LB31 Break Everywhere Else.
242 # Include combining marks
243 LB31.1: . CM* ZWJ [^CM];