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 44 for Unicode 13.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
17 # http://www.unicode.org/reports/tr14/, tailored as noted below.
19 # This tailors the line break behavior to correspond to CSS
20 # line-break=loose (BCP47 -u-lb-loose) as defined for Chinese & Japanese.
21 # It sets characters of class CJ to behave like ID.
22 # In addition, it allows breaks:
23 # * before hyphens 2010 & 2013 (both BA) and 301C, 30A0 (both NS)
24 # * before iteration marks 3005, 303B, 309D, 309E, 30FD, 30FE (all NS)
25 # * between characters of LineBreak class IN such as 2026
26 # * before some centered punct 203C, 2047, 2048, 2049, 30FB, FF1A, FF1B,
27 # FF65 (all NS) and FF01, FF1F (both EX).
28 # * before suffix characters with LineBreak class PO and EastAsianWidth A,F,W;
29 # this includes: 00B0 2030 2032 2033 2035 2103 2109 FE6A FF05 FFE0
30 # * after prefix characters with LineBreak class PR and EastAsianWidth A,F,W;
31 # this includes: 00A4 00B1 20AC 2116 FE69 FF04 FFE1 FFE5 FFE6
32 # It allows breaking before 201C and after 201D, for zh_Hans, zh_Hant, and ja.
39 AI = [:LineBreak = Ambiguous:];
40 AL = [:LineBreak = Alphabetic:];
41 BAX = [\u2010 \u2013];
42 BA = [[:LineBreak = Break_After:] - BAX];
43 HH = [\u2010]; # \u2010 is HYPHEN, default line break is BA.
44 BB = [:LineBreak = Break_Before:];
45 BK = [:LineBreak = Mandatory_Break:];
46 B2 = [:LineBreak = Break_Both:];
47 CB = [:LineBreak = Contingent_Break:];
48 CJ = [:LineBreak = Conditional_Japanese_Starter:];
49 CL = [[:LineBreak = Close_Punctuation:] \u201d];
50 CMS = [:LineBreak = Combining_Mark:];
51 CP = [:LineBreak = Close_Parenthesis:];
52 CR = [:LineBreak = Carriage_Return:];
53 EB = [[:LineBreak = EB:] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C];
54 EM = [:LineBreak = EM:];
55 EXX = [\uFF01 \uFF1F];
56 EX = [[:LineBreak = Exclamation:] - EXX];
57 GL = [:LineBreak = Glue:];
58 HL = [:LineBreak = Hebrew_Letter:];
59 HY = [:LineBreak = Hyphen:];
60 H2 = [:LineBreak = H2:];
61 H3 = [:LineBreak = H3:];
62 ID = [[:LineBreak = Ideographic:] CJ]; # CSS Loose tailoring: CJ resolves to ID
63 IN = [:LineBreak = Inseperable:];
64 IS = [:LineBreak = Infix_Numeric:];
65 JL = [:LineBreak = JL:];
66 JV = [:LineBreak = JV:];
67 JT = [:LineBreak = JT:];
68 LF = [:LineBreak = Line_Feed:];
69 NL = [:LineBreak = Next_Line:];
70 NSX = [\u301C \u30A0 \u3005 \u303B \u309D \u309E \u30FD \u30FE \u203C \u2047 \u2048 \u2049 \u30FB \uFF1A \uFF1B \uFF65];
71 NS = [[:LineBreak = Nonstarter:] - NSX];
72 NU = [:LineBreak = Numeric:];
73 OP = [[:LineBreak = Open_Punctuation:] \u201c];
74 POX = [\u00B0 \u2030 \u2032 \u2033 \u2035 \u2103 \u2109 \uFE6A \uFF05 \uFFE0];
75 PO = [[:LineBreak = Postfix_Numeric:] - POX];
76 PRX = [\u00A4 \u00B1 \u20AC \u2116 \uFE69 \uFF04 \uFFE1 \uFFE5 \uFFE6];
77 PR = [[:LineBreak = Prefix_Numeric:] - PRX];
78 QU = [[:LineBreak = Quotation:] - [\u201c\u201d]];
79 RI = [:LineBreak = Regional_Indicator:];
80 SA = [:LineBreak = Complex_Context:];
81 SG = [:LineBreak = Surrogate:];
82 SP = [:LineBreak = Space:];
83 SY = [:LineBreak = Break_Symbols:];
84 WJ = [:LineBreak = Word_Joiner:];
85 XX = [:LineBreak = Unknown:];
86 ZW = [:LineBreak = ZWSpace:];
87 ZWJ = [:LineBreak = ZWJ:];
89 # OP30 and CP30 are variants of OP and CP that appear in rule LB30 from UAX 14.
90 # Limitations of this monkey test rule parser require that these definitions be pulled out
91 # rather than appearing in-line in LB 30.
93 OP30 = [OP - [\p{ea=F}\p{ea=W}\p{ea=H}]];
94 CP30 = [CP - [\p{ea=F}\p{ea=W}\p{ea=H}]];
96 # LB1 - Resolve AI, CB, CJ, SA, SG, and XX into other line breaking classes
100 # By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly
101 # list it in the numerous rules that use CM.
110 LB6: . (BK | CR | LF | NL);
111 LB6.1: [^BK CR LF NL SP ZW] CM* (BK | CR | LF | NL);
113 # LB8 break after ZW SP*.
114 # Precedes LB7 because both rules will match the sequences like ZW SP,
115 # and LB8 must take precedence.
117 LB8: ZW SP* ÷ [^ZW SP BK CR LF NL];
119 # Numbers. Equivalent to Tailoring example 8 from UAX 14.
120 # Moved up, before LB14, because it can match longer sequences which must take precedence.
121 # Loose_cj tailoring: do not include $PRX at the beginning or $POX at the end.
122 LB25: ((PR | PO | POX)CM*)? ((OP | HY)CM*)? (IS CM*)? NU (CM*(NU | SY | IS))* (CM*(CL | CP))? (CM*(PR | PRX | PO))?;
125 # Moved up, before LB7, because they can match a longer sequence that would also match LB7.
126 # For example, the sequence "OP CM SP AL" matches LB14
127 # while the prefix of it, "OP CM SP" matches LB7.1
130 # LB 14a Break before an IS that begins a number and follows a space.
131 LB14a: SP ÷ IS CM* NU;
134 LB14b.1: [^SP] CM* IS;
138 LB16: (CL | CP)CM* SP* NS;
142 # LB7 Do not break before spaces or zero width space.
144 LB7.1: [^ZW SP] CM* [SP ZW];
145 LB7.2: [ZW SP] [SP ZW];
149 # Don't match a CM on the right - let other rules pick up CM sequences, where
150 # the ZWJ behaves as just another generic CM.
155 # LB10: Unattached CM -> AL
160 LB11.1: [^SP] CM* WJ;
162 LB11.3: WJ CM* [^CM];
166 LB12a: [^SP BA BAX HY] CM* GL;
168 # LB 13 Do not break before ‘]’ or ‘!’ or ‘/’, even after spaces.
169 LB13.1: [^SP] CM* [CL CP EX SY];
170 LB13.2: SP [CL CP EX SY];
173 # LB 14-17 are moved above LB 7.
178 LB19.1: QU CM* [^CM];
180 # LB 20 Break before and after CB.
181 # Interaction with LB8a: ZWJ x . is tricky because CM includes ZWJ.
182 # ZWJ acts like a CM to the left, combining with CB.
183 # ZWJ acts independently to the right, no break after by LB8a.
184 LB20.1: . CM* ZWJ CB;
187 LB20.3: CB CM* ZWJ [^CM];
190 # LB 20.09 Don't break between Hyphens and Letters when there is a break preceding the hyphen.
191 LB20.09: ^(HY | HH) CM* AL;
193 # Note: Rule 21a must come before 21 to prevent 21.1 from matching HL BA, then
194 # not picking up the continuing match after the BA from 21a.
195 # LB 21a Don't break after Hebrew + Hyphen
198 LB21a: HL CM* (HY | BA | BAX) CM* [^CM CB]?;
200 LB21.1: . CM* [BA HY NS];
201 LB21.2: BB CM* [^CM CB];
206 LB22: [^IN] CM* IN; # For CSS Loose, allow breaks between adjacent ellipses characters.
208 LB23.1: (AL | HL | CM) CM* NU;
209 LB23.2: NU CM* (AL | HL);
211 LB23a.1: PR CM* (ID | EB | EM);
212 LB23a.2: (ID | EB | EM) CM* PO;
214 LB24.2: (PR | PO | POX) CM* (AL | HL);
215 LB24.3: (AL | HL | CM) CM* (PR | PO | POX);
218 LB26.1: JL CM* (JL | JV | H2 | H3);
219 LB26.2: (JV | H2) CM* (JV | JT);
220 LB26.3: (JT | H3) CM* JT;
222 LB27.1: (JL | JV | JT | H2 | H3) CM* IN;
223 LB27.2: (JL | JV | JT | H2 | H3) CM* PO;
224 LB27.3: PR CM* (JL | JV | JT | H2 | H3);
226 # LB28 Do not break between Alphabetics.
227 # Unattached (leading) CM treated as AL.
228 LB28: (AL | HL | CM)CM* (AL | HL);
230 LB29: IS CM* (AL | HL);
232 # LB30 is adjusted for unattached leading CM being treated as AL.
233 LB30.1: (AL | CM | HL | NU) CM* OP30;
234 LB30.2: CP30 CM* (AL | HL | NU);
236 # LB30a keep pairs of RI together.
237 LB30a.1: RI CM* RI ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS IN CM];
238 LB30a.2: RI CM* RI CM* CMS ÷ [^BK CR LF NL SP ZW WJ CL CP EX IS SY GL QU BA HY NS IN CM];
239 LB30a.3: RI CM* RI CM* [BK CR LF NL SP ZW WJ GL CL CP EX IS SY QU BA HY NS IN ZWJ]?;
241 # LB30b Do not break between Emoji Base and Emoji Modifier
244 # LB31 Break Everywhere Else.
245 # Include combining marks
246 LB31.1: . CM* ZWJ [^CM];