]>
Commit | Line | Data |
---|---|---|
2ca993e8 | 1 | # |
f3c0d7a5 A |
2 | # Copyright (C) 2016 and later: Unicode, Inc. and others. |
3 | # License & terms of use: http://www.unicode.org/copyright.html | |
2ca993e8 A |
4 | # Copyright (c) 2016, International Business Machines Corporation and others. All Rights Reserved. |
5 | # | |
6 | # file: line_loose_cj.txt | |
7 | # | |
0f5d89e8 | 8 | # Reference Line Break rules for intltest rbbi/RBBIMonkeyTest. |
340931cb | 9 | # Rules derived from Unicode Standard Annex #14 Revision 44 for Unicode 13.0 |
2ca993e8 A |
10 | # |
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. | |
13 | # | |
14 | # Line Breaking Rules | |
f3c0d7a5 | 15 | # Implement default line breaking as defined by |
340931cb A |
16 | # Unicode Standard Annex #14 |
17 | # http://www.unicode.org/reports/tr14/, tailored as noted below. | |
2ca993e8 A |
18 | # |
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 | |
3d1f044b | 32 | # It allows breaking before 201C and after 201D, for zh_Hans, zh_Hant, and ja. |
2ca993e8 A |
33 | |
34 | ||
35 | type = line; | |
36 | locale = ja@lb=loose; | |
37 | ||
38 | ||
39 | AI = [:LineBreak = Ambiguous:]; | |
3d1f044b | 40 | AL = [:LineBreak = Alphabetic:]; |
2ca993e8 A |
41 | BAX = [\u2010 \u2013]; |
42 | BA = [[:LineBreak = Break_After:] - BAX]; | |
3d1f044b | 43 | HH = [\u2010]; # \u2010 is HYPHEN, default line break is BA. |
2ca993e8 A |
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:]; | |
3d1f044b A |
49 | CL = [[:LineBreak = Close_Punctuation:] \u201d]; |
50 | CMS = [:LineBreak = Combining_Mark:]; | |
2ca993e8 A |
51 | CP = [:LineBreak = Close_Parenthesis:]; |
52 | CR = [:LineBreak = Carriage_Return:]; | |
f3c0d7a5 A |
53 | EB = [[:LineBreak = EB:] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C]; |
54 | EM = [:LineBreak = EM:]; | |
2ca993e8 A |
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:]; | |
f3c0d7a5 | 62 | ID = [[:LineBreak = Ideographic:] CJ]; # CSS Loose tailoring: CJ resolves to ID |
2ca993e8 A |
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:]; | |
3d1f044b | 73 | OP = [[:LineBreak = Open_Punctuation:] \u201c]; |
2ca993e8 A |
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]; | |
3d1f044b | 78 | QU = [[:LineBreak = Quotation:] - [\u201c\u201d]]; |
2ca993e8 A |
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:]; | |
f3c0d7a5 | 87 | ZWJ = [:LineBreak = ZWJ:]; |
2ca993e8 | 88 | |
340931cb A |
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. | |
92 | ||
93 | OP30 = [OP - [\p{ea=F}\p{ea=W}\p{ea=H}]]; | |
94 | CP30 = [CP - [\p{ea=F}\p{ea=W}\p{ea=H}]]; | |
95 | ||
f3c0d7a5 A |
96 | # LB1 - Resolve AI, CB, CJ, SA, SG, and XX into other line breaking classes |
97 | AL = [AL AI SG XX ]; | |
98 | dictionary = SA; | |
2ca993e8 | 99 | |
f3c0d7a5 A |
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. | |
3d1f044b | 102 | CM = [CMS ZWJ]; |
2ca993e8 A |
103 | |
104 | LB4: BK ÷; | |
105 | LB5: CR LF; | |
106 | LB5.1: CR ÷; | |
107 | LB5.2: LF ÷; | |
108 | LB5.3: NL ÷; | |
109 | ||
110 | LB6: . (BK | CR | LF | NL); | |
111 | LB6.1: [^BK CR LF NL SP ZW] CM* (BK | CR | LF | NL); | |
112 | ||
3d1f044b A |
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. | |
116 | ||
117 | LB8: ZW SP* ÷ [^ZW SP BK CR LF NL]; | |
118 | ||
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))?; | |
123 | ||
2ca993e8 | 124 | # Rules LB14 - LB17. |
3d1f044b A |
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 | |
2ca993e8 | 128 | LB14: OP CM* SP* .; |
3d1f044b A |
129 | |
130 | # LB 14a Break before an IS that begins a number and follows a space. | |
131 | LB14a: SP ÷ IS CM* NU; | |
132 | ||
133 | # LB14b × IS | |
134 | LB14b.1: [^SP] CM* IS; | |
135 | LB14b.2: SP IS; | |
136 | ||
2ca993e8 A |
137 | LB15: QU CM* SP* OP; |
138 | LB16: (CL | CP)CM* SP* NS; | |
139 | LB17: B2 CM* SP* B2; | |
140 | ||
3d1f044b A |
141 | |
142 | # LB7 Do not break before spaces or zero width space. | |
143 | ||
2ca993e8 A |
144 | LB7.1: [^ZW SP] CM* [SP ZW]; |
145 | LB7.2: [ZW SP] [SP ZW]; | |
146 | ||
f3c0d7a5 | 147 | # LB8a |
0f5d89e8 A |
148 | # ZWJ x |
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. | |
151 | LB8a: ZWJ [^CM]; | |
2ca993e8 A |
152 | |
153 | ||
154 | # LB9: X CM -> X | |
155 | # LB10: Unattached CM -> AL | |
156 | ||
157 | #LB11: × WJ; | |
158 | # WJ × | |
159 | ||
0f5d89e8 | 160 | LB11.1: [^SP] CM* WJ; |
2ca993e8 A |
161 | LB11.2: SP WJ; |
162 | LB11.3: WJ CM* [^CM]; | |
163 | ||
164 | LB12: GL CM* [^CM]; | |
165 | ||
166 | LB12a: [^SP BA BAX HY] CM* GL; | |
167 | ||
3d1f044b A |
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]; | |
2ca993e8 A |
171 | |
172 | ||
173 | # LB 14-17 are moved above LB 7. | |
174 | ||
175 | LB18: SP ÷; | |
176 | ||
177 | LB19: . CM* QU; | |
178 | LB19.1: QU CM* [^CM]; | |
179 | ||
180 | # LB 20 Break before and after CB. | |
0f5d89e8 | 181 | # Interaction with LB8a: ZWJ x . is tricky because CM includes ZWJ. |
f3c0d7a5 | 182 | # ZWJ acts like a CM to the left, combining with CB. |
0f5d89e8 A |
183 | # ZWJ acts independently to the right, no break after by LB8a. |
184 | LB20.1: . CM* ZWJ CB; | |
185 | LB20.2: . CM* ÷ CB; | |
186 | ||
187 | LB20.3: CB CM* ZWJ [^CM]; | |
188 | LB20.4: CB CM* ÷; | |
2ca993e8 | 189 | |
3d1f044b A |
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; | |
192 | ||
2ca993e8 A |
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 | |
196 | # HL (HY | BA) x | |
197 | ||
198 | LB21a: HL CM* (HY | BA | BAX) CM* [^CM CB]?; | |
199 | ||
200 | LB21.1: . CM* [BA HY NS]; | |
201 | LB21.2: BB CM* [^CM CB]; | |
202 | ||
203 | LB21b: SY CM* HL; | |
204 | ||
340931cb A |
205 | |
206 | LB22: [^IN] CM* IN; # For CSS Loose, allow breaks between adjacent ellipses characters. | |
2ca993e8 | 207 | |
f3c0d7a5 A |
208 | LB23.1: (AL | HL | CM) CM* NU; |
209 | LB23.2: NU CM* (AL | HL); | |
210 | ||
211 | LB23a.1: PR CM* (ID | EB | EM); | |
212 | LB23a.2: (ID | EB | EM) CM* PO; | |
2ca993e8 | 213 | |
f3c0d7a5 A |
214 | LB24.2: (PR | PO | POX) CM* (AL | HL); |
215 | LB24.3: (AL | HL | CM) CM* (PR | PO | POX); | |
2ca993e8 | 216 | |
2ca993e8 A |
217 | |
218 | LB26.1: JL CM* (JL | JV | H2 | H3); | |
219 | LB26.2: (JV | H2) CM* (JV | JT); | |
220 | LB26.3: (JT | H3) CM* JT; | |
221 | ||
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); | |
225 | ||
226 | # LB28 Do not break between Alphabetics. | |
227 | # Unattached (leading) CM treated as AL. | |
228 | LB28: (AL | HL | CM)CM* (AL | HL); | |
229 | ||
230 | LB29: IS CM* (AL | HL); | |
231 | ||
232 | # LB30 is adjusted for unattached leading CM being treated as AL. | |
340931cb A |
233 | LB30.1: (AL | CM | HL | NU) CM* OP30; |
234 | LB30.2: CP30 CM* (AL | HL | NU); | |
2ca993e8 | 235 | |
0f5d89e8 | 236 | # LB30a keep pairs of RI together. |
340931cb A |
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]?; | |
2ca993e8 A |
240 | |
241 | # LB30b Do not break between Emoji Base and Emoji Modifier | |
242 | LB30b: EB CM* EM; | |
243 | ||
244 | # LB31 Break Everywhere Else. | |
245 | # Include combining marks | |
0f5d89e8 | 246 | LB31.1: . CM* ZWJ [^CM]; |
2ca993e8 | 247 | LB31.2: . CM* ÷; |