Debian Codegraph @

intl/icu/source/data/brkitr/rules/line_loose_cj.txt

raw
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.
5 #
6 # file: line_loose_cj.txt
7 #
8 # Line Breaking Rules
9 # Implement default line breaking as defined by
10 # Unicode Standard Annex #14 (https://www.unicode.org/reports/tr14/)
11 # for Unicode 14.0, with the following modification:
12 #
13 # Boundaries between hyphens and following letters are suppressed when
14 # there is a boundary preceding the hyphen. See rule 20.9
15 #
16 # This tailors the line break behavior to correspond to CSS
17 # line-break=loose (BCP47 -u-lb-loose) as defined for Chinese & Japanese.
18 # It sets characters of class CJ to behave like ID.
19 # In addition, it allows breaks:
20 # * between ID and hyphens 2010 & 2013 (both BA)
21 # * before 301C, 30A0 (both NS)
22 # * before iteration marks 3005, 303B, 309D, 309E, 30FD, 30FE (all NS)
23 # * between characters of LineBreak class IN such as 2026
24 # * before some centered punct 203C, 2047, 2048, 2049, 30FB, FF1A, FF1B,
25 # FF65 (all NS) and FF01, FF1F (both EX).
26 # * before suffix characters with LineBreak class PO and EastAsianWidth A,F,W;
27 # this includes: 00B0 2030 2032 2033 2035 2103 2109 FE6A FF05 FFE0
28 # * after prefix characters with LineBreak class PR and EastAsianWidth A,F,W;
29 # this includes: 00A4 00B1 20AC 2116 FE69 FF04 FFE1 FFE5 FFE6
30 # It allows breaking before 201C and after 201D, for zh_Hans, zh_Hant, and ja.
31
32
33 #
34 # Character Classes defined by TR 14.
35 #
36
37 !!chain;
38 !!quoted_literals_only;
39
40 $AI = [:LineBreak = Ambiguous:];
41 $AK = [:LineBreak = Aksara:];
42 $AL = [:LineBreak = Alphabetic:];
43 $AP = [:LineBreak = Aksara_Prebase:];
44 $AS = [:LineBreak = Aksara_Start:];
45 $BAX = [\u2010 \u2013];
46 $BA = [[:LineBreak = Break_After:] - $BAX];
47 $HH = [\u2010]; # \u2010 is HYPHEN, default line break is BA.
48 $BB = [:LineBreak = Break_Before:];
49 $BK = [:LineBreak = Mandatory_Break:];
50 $B2 = [:LineBreak = Break_Both:];
51 $CB = [:LineBreak = Contingent_Break:];
52 $CJ = [:LineBreak = Conditional_Japanese_Starter:];
53 $CL = [[:LineBreak = Close_Punctuation:] \u201d];
54 # $CM = [:LineBreak = Combining_Mark:];
55 $CP = [:LineBreak = Close_Parenthesis:];
56 $CR = [:LineBreak = Carriage_Return:];
57 $EB = [:LineBreak = EB:];
58 $EM = [:LineBreak = EM:];
59 $EXX = [\uFF01 \uFF1F];
60 $EX = [[:LineBreak = Exclamation:] - $EXX];
61 $GL = [:LineBreak = Glue:];
62 $HL = [:LineBreak = Hebrew_Letter:];
63 $HY = [:LineBreak = Hyphen:];
64 $H2 = [:LineBreak = H2:];
65 $H3 = [:LineBreak = H3:];
66 # CSS Loose tailoring: CJ resolves to ID
67 $ID = [[:LineBreak = Ideographic:] $CJ];
68 $IN = [:LineBreak = Inseperable:];
69 $IS = [:LineBreak = Infix_Numeric:];
70 $JL = [:LineBreak = JL:];
71 $JV = [:LineBreak = JV:];
72 $JT = [:LineBreak = JT:];
73 $LF = [:LineBreak = Line_Feed:];
74 $NL = [:LineBreak = Next_Line:];
75 $NSX = [\u301C \u30A0 \u3005 \u303B \u309D \u309E \u30FD \u30FE \u203C \u2047 \u2048 \u2049 \u30FB \uFF1A \uFF1B \uFF65];
76 $NS = [[:LineBreak = Nonstarter:] - $NSX];
77 $NU = [:LineBreak = Numeric:];
78 $OP = [[:LineBreak = Open_Punctuation:] \u201c];
79 $POX = [\u00B0 \u2030 \u2032 \u2033 \u2035 \u2103 \u2109 \uFE6A \uFF05 \uFFE0];
80 $PO = [[:LineBreak = Postfix_Numeric:] - $POX];
81 $PRX = [\u00A4 \u00B1 \u20AC \u2116 \uFE69 \uFF04 \uFFE1 \uFFE5 \uFFE6];
82 $PR = [[:LineBreak = Prefix_Numeric:] - $PRX];
83 $QU = [[:LineBreak = Quotation:] - [\u201c\u201d]];
84 $RI = [:LineBreak = Regional_Indicator:];
85 $SA = [:LineBreak = Complex_Context:];
86 $SG = [:LineBreak = Surrogate:];
87 $SP = [:LineBreak = Space:];
88 $SY = [:LineBreak = Break_Symbols:];
89 $VF = [:LineBreak = Virama_Final:];
90 $VI = [:LineBreak = Virama:];
91 $WJ = [:LineBreak = Word_Joiner:];
92 $XX = [:LineBreak = Unknown:];
93 $ZW = [:LineBreak = ZWSpace:];
94 $ZWJ = [:LineBreak = ZWJ:];
95
96 $EastAsian = [\p{ea=F}\p{ea=W}\p{ea=H}];
97
98 $ExtPictUnassigned = [\p{Extended_Pictographic} & \p{Cn}];
99
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.
102 # By LB1, SA characters with general categor of Mn or Mc also resolve to CM.
103
104 $CM = [[:LineBreak = Combining_Mark:] $ZWJ [$SA & [[:Mn:][:Mc:]]]];
105 $CMX = [[$CM] - [$ZWJ]];
106
107 # Dictionary character set, for triggering language-based break engines. Currently
108 # limited to LineBreak=Complex_Context (SA).
109
110 $dictionary = [$SA];
111
112 #
113 # Rule LB1. By default, treat AI (characters with ambiguous east Asian width),
114 # SA (Dictionary chars, excluding Mn and Mc)
115 # SG (Unpaired Surrogates)
116 # XX (Unknown, unassigned)
117 # as $AL (Alphabetic)
118 #
119 $ALPlus = [$AL $AI $SG $XX [$SA-[[:Mn:][:Mc:]]]];
120
121
122 ## -------------------------------------------------
123
124 #
125 # CAN_CM is the set of characters that may combine with CM combining chars.
126 # Note that Linebreak UAX 14's concept of a combining char and the rules
127 # for what they can combine with are _very_ different from the rest of Unicode.
128 #
129 # Note that $CM itself is left out of this set. If CM is needed as a base
130 # it must be listed separately in the rule.
131 #
132 $CAN_CM = [^$SP $BK $CR $LF $NL $ZW $CM]; # Bases that can take CMs
133 $CANT_CM = [ $SP $BK $CR $LF $NL $ZW $CM]; # Bases that can't take CMs
134
135 #
136 # AL_FOLLOW set of chars that can unconditionally follow an AL
137 # Needed in rules where stand-alone $CM s are treated as AL.
138 #
139 $AL_FOLLOW = [$BK $CR $LF $NL $ZW $SP $CL $CP $EX $HL $IS $SY $WJ $GL [$OP - $EastAsian] $QU $BA $BAX $HY $NS $IN $NU $PR $PO $POX $ALPlus];
140
141
142 #
143 # Rule LB 4, 5 Mandatory (Hard) breaks.
144 #
145 $LB4Breaks = [$BK $CR $LF $NL];
146 $LB4NonBreaks = [^$BK $CR $LF $NL $CM];
147 $CR $LF {100};
148
149 #
150 # LB 6 Do not break before hard line breaks.
151 #
152 $LB4NonBreaks? $LB4Breaks {100}; # LB 5 do not break before hard breaks.
153 $CAN_CM $CM* $LB4Breaks {100};
154 ^$CM+ $LB4Breaks {100};
155
156 # LB 7 x SP
157 # x ZW
158 $LB4NonBreaks [$SP $ZW];
159 $CAN_CM $CM* [$SP $ZW];
160 ^$CM+ [$SP $ZW];
161
162 #
163 # LB 8 Break after zero width space
164 # ZW SP* ÷
165 #
166 $LB8Breaks = [$LB4Breaks $ZW];
167 $LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]];
168 $ZW $SP* / [^$SP $ZW $LB4Breaks];
169
170 # LB 8a ZWJ x Do not break Emoji ZWJ sequences.
171 #
172 $ZWJ [^$CM];
173
174 # LB 9 Combining marks. X $CM needs to behave like X, where X is not $SP, $BK $CR $LF $NL
175 # $CM not covered by the above needs to behave like $AL
176 # See definition of $CAN_CM.
177
178 $CAN_CM $CM+; # Stick together any combining sequences that don't match other rules.
179 ^$CM+;
180
181 #
182 # LB 11 Do not break before or after WORD JOINER & related characters.
183 #
184 $CAN_CM $CM* $WJ;
185 $LB8NonBreaks $WJ;
186 ^$CM+ $WJ;
187
188 $WJ $CM* .;
189
190 #
191 # LB 12 Do not break after NBSP and related characters.
192 # GL x
193 #
194 $GL $CM* .;
195
196 #
197 # LB 12a Do not break before NBSP and related characters ...
198 # [^SP BA HY] x GL
199 #
200 [[$LB8NonBreaks] - [$SP $BA $BAX $HY]] $CM* $GL;
201 ^$CM+ $GL;
202
203
204
205 # LB 13 Don't break before ']' or '!' or '/', even after spaces.
206 #
207 # Do not include $EXX here
208 $LB8NonBreaks $CL;
209 $CAN_CM $CM* $CL;
210 ^$CM+ $CL; # by rule 10, stand-alone CM behaves as AL
211
212 $LB8NonBreaks $CP;
213 $CAN_CM $CM* $CP;
214 ^$CM+ $CP; # by rule 10, stand-alone CM behaves as AL
215
216 $LB8NonBreaks $EX;
217 $CAN_CM $CM* $EX;
218 ^$CM+ $EX; # by rule 10, stand-alone CM behaves as AL
219
220 $LB8NonBreaks $SY;
221 $CAN_CM $CM* $SY;
222 ^$CM+ $SY; # by rule 10, stand-alone CM behaves as AL
223
224
225 #
226 # LB 14 Do not break after OP, even after spaces
227 # Note subtle interaction with "SP IS /" rules in LB14a.
228 # This rule consumes the SP, chaining happens on the IS, effectivley overriding the SP IS rules,
229 # which is the desired behavior.
230 #
231 $OP $CM* $SP* .;
232
233 $OP $CM* $SP+ $CM+ $AL_FOLLOW?; # by rule 10, stand-alone CM behaves as AL
234 # by rule 8, CM following a SP is stand-alone.
235
236
237 # LB 15a
238 ($OP $CM* $SP+ | [$OP $QU $GL] $CM*) ([\p{Pi} & $QU] $CM* $SP*)+ .;
239 ($OP $CM* $SP+ | [$OP $QU $GL] $CM*) ([\p{Pi} & $QU] $CM* $SP*)+ $SP $CM+ $AL_FOLLOW?;
240 ^([\p{Pi} & $QU] $CM* $SP*)+ .;
241 ^([\p{Pi} & $QU] $CM* $SP*)+ $SP $CM+ $AL_FOLLOW?;
242
243 # LB 15b
244 $LB8NonBreaks [\p{Pf} & $QU] $CM* [$SP $GL $WJ $CL $QU $CP $EX $IS $SY $BK $CR $LF $NL $ZW {eof}];
245 $CAN_CM $CM* [\p{Pf} & $QU] $CM* [$SP $GL $WJ $CL $QU $CP $EX $IS $SY $BK $CR $LF $NL $ZW {eof}];
246 ^$CM+ [\p{Pf} & $QU] $CM* [$SP $GL $WJ $CL $QU $CP $EX $IS $SY $BK $CR $LF $NL $ZW {eof}];
247
248 # Messy interaction: manually chain between LB 15b and LB 15a on Pf Pi.
249 $LB8NonBreaks [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ .;
250 $LB8NonBreaks [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ $SP $CM+ $AL_FOLLOW?;
251 $CAN_CM $CM* [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ .;
252 $CAN_CM $CM* [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ $SP $CM+ $AL_FOLLOW?;
253 ^$CM+ [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ .;
254 ^$CM+ [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ $SP $CM+ $AL_FOLLOW?;
255
256
257 # LB 15c Force a break before start of a number with a leading decimal pt, e.g. " .23"
258 # Note: would be simpler to express as "$SP / $IS $CM* $NU;", but ICU rules have limitations.
259 # See issue ICU-20303
260
261
262 $CanFollowIS = [$BK $CR $LF $NL $SP $ZW $WJ $GL $CL $CP $EX $IS $SY $QU $BA $BAX $HY $NS $ALPlus $HL $IN];
263 $SP $IS / [^ $CanFollowIS $NU $CM];
264 $SP $IS $CM* $CMX / [^ $CanFollowIS $NU $CM];
265
266 #
267 # LB 15d Do not break before numeric separators (IS), even after spaces.
268 # SP IS QU is handled below as part of LB 19.
269
270 [$LB8NonBreaks - $SP] $IS;
271 $SP $IS $CM* [$CanFollowIS {eof}];
272 $SP $IS $CM* $ZWJ [^$CM $NU];
273
274 $CAN_CM $CM* $IS;
275 ^$CM+ $IS; # by rule 10, stand-alone CM behaves as AL
276
277
278 # LB 16
279 # Do not break between closing punctuation and $NS, even with intervening spaces
280 # But DO allow a break between closing punctuation and $NSX, don't include it here
281 ($CL | $CP) $CM* $SP* $NS;
282
283 # LB 17
284 $B2 $CM* $SP* $B2;
285
286 #
287 # LB 18 Break after spaces.
288 #
289 $LB18NonBreaks = [$LB8NonBreaks - [$SP]];
290 $LB18Breaks = [$LB8Breaks $SP];
291
292
293 # LB 19 and LB 19a.
294 # Instead of implementing both as keep-together rules as in UAX #14, we have an
295 # East_Asian_Width and General_Category-insensitive keep-together rule
296 # equivalent to the old LB19 × QU and QU ×, and then we poke holes into it based
297 # on context. This avoids having to do manual chaining over multiple characters
298 # with many other rules over multiple characters, as a keep-together LB19a would
299 # overlap in context with at least LB14, LB15a, LB15a, LB15d, LB30a, and itself.
300 $LB18NonBreaks $CM* $QU;
301 ^$CM+ $QU;
302
303 [$LB18NonBreaks & $EastAsian - [$OP $GL]] / [\p{Pi} & $QU] $CM* [ $EastAsian - $CM];
304 [$LB18NonBreaks & $EastAsian - [$OP $GL]] $CM* $CMX / [\p{Pi} & $QU] $CM* [ $EastAsian - $CM];
305
306 $QU $CM* .;
307 [$LB18NonBreaks & $EastAsian] $CM* [\p{Pf} & $QU] / [ $EastAsian - [$NS $BA $EX $CL $IN $IS $GL $CM]];
308 [$LB18NonBreaks & $EastAsian] $CM* [\p{Pf} & $QU] $CM* $CMX / [ $EastAsian - [$NS $BA $EX $CL $IN $IS $GL $CM]];
309
310 # LB 20
311 # <break> $CB
312 # $CB <break>
313 #
314 $LB20NonBreaks = [$LB18NonBreaks - $CB];
315
316 # LB 20a Don't break between Hyphens and Letters when there is a break preceding the hyphen.
317 # Originally added as a Finnish tailoring, promoted to default ICU behavior (ICU-8151),
318 # and then to default UAX #14 behaviour (UTC-179-C32).
319 #
320 ^($HY | $HH) $CM* $ALPlus;
321 $GL $CM* ($HY | $HH) $CM* $ALPlus;
322 # Non-breaking CB from LB8a:
323 $CB $CM* $ZWJ ($HY | $HH) $CM* $ALPlus;
324 # Non-breaking SP from LB14:
325 $OP $CM* $SP+ ($HY | $HH) $CM* $ALPlus;
326 # Non-breaking SP from LB15a:
327 ($OP $CM* $SP+ | [$OP $QU $GL] $CM*) ([\p{Pi} & $QU] $CM* $SP*)+ $SP ($HY | $HH) $CM* $ALPlus;
328 ^([\p{Pi} & $QU] $CM* $SP*)+ $SP ($HY | $HH) $CM* $ALPlus;
329 # Non-breaking SP from LB15a following LB15b:
330 $LB8NonBreaks [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ $SP ($HY | $HH) $CM* $ALPlus;
331 $CAN_CM $CM* [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ $SP ($HY | $HH) $CM* $ALPlus;
332 ^$CM+ [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ $SP ($HY | $HH) $CM* $ALPlus;
333
334 # LB 21 x (BA | HY | NS)
335 # BB x
336 #
337 # DO allow breaks here before $NSX, so don't include it.
338 # And DO allow breaks between ID and $BAX, so split out the handling of ID and do not include $BAX for them.
339 [$LB20NonBreaks - $ID] $CM* ($BA | $BAX | $HY | $NS);
340 $ID $CM* ($BA | $HY | $NS);
341
342
343 ^$CM+ ($BA | $BAX | $HY | $NS);
344
345 $BB $CM* [^$CB]; # $BB x
346 $BB $CM* $LB20NonBreaks;
347
348 # LB 21a Do not break after the hyphen in Hebrew + Hyphen + non-Hebrew
349 # HL (HY | BA) x [^HL]
350 #
351 $HL $CM* ($HY | [ $BA - $EastAsian ] | $BAX ) $CM* [^$CB $HL]?;
352
353 # LB 21b (forward) Don't break between SY and HL
354 # (break between HL and SY already disallowed by LB 13 above)
355 $SY $CM* $HL;
356
357
358 # LB 22 Do not break before ellipses
359 #
360 [$LB20NonBreaks - $IN] $CM* $IN; # line_loose tailoring
361 ^$CM+ $IN;
362
363
364 # LB 23
365 #
366 ($ALPlus | $HL) $CM* $NU;
367 ^$CM+ $NU; # Rule 10, any otherwise unattached CM behaves as AL
368 $NU $CM* ($ALPlus | $HL);
369
370 # LB 23a
371 # Do not include $POX here
372 #
373 $PR $CM* ($ID | $EB | $EM);
374 ($ID | $EB | $EM) $CM* $PO;
375
376
377 #
378 # LB 24
379 #
380 # Do not include $PRX here
381 ($PR | $PO | $POX) $CM* ($ALPlus | $HL);
382 ($ALPlus | $HL) $CM* ($PR | $PO | $POX); # TODO: should this be ($PR | $PRX | $PO)
383 ^$CM+ ($PR | $PO | $POX); # Rule 10, any otherwise unattached CM behaves as AL
384
385 #
386 # LB 25 Numbers.
387 #
388 # Here do not include $PRX at the beginning or $POX at the end
389 (($PR | $PO | $POX) $CM*)? (($OP | $HY) $CM*)? ($IS $CM*)? $NU ($CM* ($NU | $SY | $IS))*
390 ($CM* ($CL | $CP))? ($CM* ($PR | $PRX | $PO))?;
391
392 # LB 26 Do not break a Korean syllable
393 #
394 $JL $CM* ($JL | $JV | $H2 | $H3);
395 ($JV | $H2) $CM* ($JV | $JT);
396 ($JT | $H3) $CM* $JT;
397
398 # LB 27 Treat korean Syllable Block the same as ID (don't break it)
399 # Do not include $POX or $PRX here
400 ($JL | $JV | $JT | $H2 | $H3) $CM* $PO;
401 $PR $CM* ($JL | $JV | $JT | $H2 | $H3);
402
403
404 # LB 28 Do not break between alphabetics
405 #
406 ($ALPlus | $HL) $CM* ($ALPlus | $HL);
407 ^$CM+ ($ALPlus | $HL); # The $CM+ is from rule 10, an unattached CM is treated as AL
408
409 #LB 28a Do not break Orthographic syllables
410 ($AP $CM*)? ($AS | $AK | [◌] ) ($CM* $VI $CM* ($AK | [◌] ))* ($CM* $VI | (($CM* ($AS | $AK | [◌] ) )? $CM* $VF))?;
411
412 # LB 29
413 $IS $CM* ($ALPlus | $HL);
414
415 # LB 30
416 ($ALPlus | $HL | $NU) $CM* [$OP - $EastAsian];
417 ^$CM+ [$OP - $EastAsian]; # The $CM+ is from rule 10, an unattached CM is treated as AL.
418 [$CP - $EastAsian] $CM* ($ALPlus | $HL | $NU);
419
420 # LB 30a Do not break between regional indicators. Break after pairs of them.
421 # Tricky interaction with LB8a: ZWJ x . together with ZWJ acting like a CM.
422 $RI $CM* $RI / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $BAX $HY $NS $IN $CM]];
423 $RI $CM* $RI $CM* [$CM-$ZWJ] / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $BAX $HY $NS $IN $CM]];
424 $RI $CM* $RI $CM* [$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $BAX $HY $NS $IN $ZWJ {eof}];
425 # note: the preceding rule includes {eof} rather than having the last [set] term qualified with '?'
426 # because of the chain-out behavior difference. The rule must chain out only from the [set characters],
427 # not from the preceding $RI or $CM, which it would be able to do if the set were optional.
428
429 # LB30b Do not break between an emoji base (or potential emoji) and an emoji modifier.
430 $EB $CM* $EM;
431 $ExtPictUnassigned $CM* $EM;
432
433 # LB 31 Break everywhere else.
434 # Match a single code point if no other rule applies.
435 .;