Debian Codegraph @

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

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