X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/0f5d89e82340278ed3d7d50029f37cab2c41a57e..340931cb2e044a2141d11567dd0f782524e32994:/icuSources/data/brkitr/rules/line_loose.txt?ds=inline diff --git a/icuSources/data/brkitr/rules/line_loose.txt b/icuSources/data/brkitr/rules/line_loose.txt index 1326d90f..2794554e 100644 --- a/icuSources/data/brkitr/rules/line_loose.txt +++ b/icuSources/data/brkitr/rules/line_loose.txt @@ -8,14 +8,11 @@ # # Line Breaking Rules # Implement default line breaking as defined by -# Unicode Standard Annex #14 Revision 40 for Unicode 11.0 -# http://www.unicode.org/reports/tr14/ +# Unicode Standard Annex #14 Revision 44 for Unicode 13.0 +# http://www.unicode.org/reports/tr14/, with the following modification: # -# tailored as noted in 2nd paragraph below. -# -# TODO: Rule LB 8 remains as it was in Unicode 5.2 -# This is only because of a limitation of ICU break engine implementation, -# not because the older behavior is desirable. +# Boundaries between hyphens and following letters are suppressed when +# there is a boundary preceding the hyphen. See rule 20.9 # # This tailors the line break behavior to correspond to CSS # line-break=loose (BCP47 -u-lb-loose) as defined for languages other than @@ -35,6 +32,7 @@ $AI = [:LineBreak = Ambiguous:]; $AL = [:LineBreak = Alphabetic:]; $BA = [:LineBreak = Break_After:]; +$HH = [\u2010]; # \u2010 is HYPHEN, default line break is BA. $BB = [:LineBreak = Break_Before:]; $BK = [:LineBreak = Mandatory_Break:]; $B2 = [:LineBreak = Break_Both:]; @@ -44,7 +42,7 @@ $CL = [:LineBreak = Close_Punctuation:]; # $CM = [:LineBreak = Combining_Mark:]; $CP = [:LineBreak = Close_Parenthesis:]; $CR = [:LineBreak = Carriage_Return:]; -$EB = [[:LineBreak = EB:] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C]; +$EB = [:LineBreak = EB:]; $EM = [:LineBreak = EM:]; $EX = [:LineBreak = Exclamation:]; $GL = [:LineBreak = Glue:]; @@ -78,11 +76,19 @@ $XX = [:LineBreak = Unknown:]; $ZW = [:LineBreak = ZWSpace:]; $ZWJ = [:LineBreak = ZWJ:]; +# OP30 and CP30 are variants of OP and CP that appear in-line in rule LB30 from UAX 14, +# without a formal name. Because ICU rules require multiple uses of the expressions, +# give them a single definition with a name + +$OP30 = [$OP - [\p{ea=F}\p{ea=W}\p{ea=H}]]; +$CP30 = [$CP - [\p{ea=F}\p{ea=W}\p{ea=H}]]; + # By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicitly # list it in the numerous rules that use CM. # By LB1, SA characters with general categor of Mn or Mc also resolve to CM. $CM = [[:LineBreak = Combining_Mark:] $ZWJ [$SA & [[:Mn:][:Mc:]]]]; +$CMX = [[$CM] - [$ZWJ]]; # Dictionary character set, for triggering language-based break engines. Currently # limited to LineBreak=Complex_Context (SA). @@ -116,7 +122,7 @@ $CANT_CM = [ $SP $BK $CR $LF $NL $ZW $CM]; # Bases that can't take CMs # AL_FOLLOW set of chars that can unconditionally follow an AL # Needed in rules where stand-alone $CM s are treated as AL. # -$AL_FOLLOW = [$BK $CR $LF $NL $ZW $SP $CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $HY $NS $IN $NU $PR $PO $ALPlus]; +$AL_FOLLOW = [$BK $CR $LF $NL $ZW $SP $CL $CP $EX $HL $IS $SY $WJ $GL $OP30 $QU $BA $HY $NS $IN $NU $PR $PO $ALPlus]; # @@ -141,12 +147,11 @@ $CAN_CM $CM* [$SP $ZW]; # # LB 8 Break after zero width space -# TODO: ZW SP* -# An engine change is required to write the reverse rule for this. -# For now, leave the Unicode 5.2 rule, ZW +# ZW SP* ÷ # $LB8Breaks = [$LB4Breaks $ZW]; $LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]]; +$ZW $SP* / [^$SP $ZW $LB4Breaks]; # LB 8a ZWJ x Do not break Emoji ZWJ sequences. # @@ -183,8 +188,8 @@ $GL $CM* .; -# -# LB 13 Don't break before ']' or '!' or ';' or '/', even after spaces. + +# LB 13 Don't break before ']' or '!' or or '/', even after spaces. # $LB8NonBreaks $CL; $CAN_CM $CM* $CL; @@ -198,10 +203,6 @@ $LB8NonBreaks $EX; $CAN_CM $CM* $EX; ^$CM+ $EX; # by rule 10, stand-alone CM behaves as AL -$LB8NonBreaks $IS; -$CAN_CM $CM* $IS; -^$CM+ $IS; # by rule 10, stand-alone CM behaves as AL - $LB8NonBreaks $SY; $CAN_CM $CM* $SY; ^$CM+ $SY; # by rule 10, stand-alone CM behaves as AL @@ -209,12 +210,36 @@ $CAN_CM $CM* $SY; # # LB 14 Do not break after OP, even after spaces +# Note subtle interaction with "SP IS /" rules in LB14a. +# This rule consumes the SP, chaining happens on the IS, effectivley overriding the SP IS rules, +# which is the desired behavior. # $OP $CM* $SP* .; $OP $CM* $SP+ $CM+ $AL_FOLLOW?; # by rule 10, stand-alone CM behaves as AL # by rule 8, CM following a SP is stand-alone. + +# LB 14a Force a break before start of a number with a leading decimal pt, e.g. " .23" +# Note: would be simpler to express as "$SP / $IS $CM* $NU;", but ICU rules have limitations. +# See issue ICU-20303 + + +$CanFollowIS = [$BK $CR $LF $NL $SP $ZW $WJ $GL $CL $CP $EX $IS $SY $QU $BA $HY $NS $ALPlus $HL $IN]; +$SP $IS / [^ $CanFollowIS $NU $CM]; +$SP $IS $CM* $CMX / [^ $CanFollowIS $NU $CM]; + +# +# LB 14b Do not break before numeric separators (IS), even after spaces. + +[$LB8NonBreaks - $SP] $IS; +$SP $IS $CM* [$CanFollowIS {eof}]; +$SP $IS $CM* $ZWJ [^$CM $NU]; + +$CAN_CM $CM* $IS; +^$CM+ $IS; # by rule 10, stand-alone CM behaves as AL + + # LB 15 $QU $CM* $SP* $OP; @@ -241,18 +266,25 @@ $LB18NonBreaks $CM* $QU; # QU x $QU $CM* .; - # LB 20 # $CB # $CB - +# $LB20NonBreaks = [$LB18NonBreaks - $CB]; +# LB 20.09 Don't break between Hyphens and Letters when there is a break preceding the hyphen. +# Originally added as a Finnish tailoring, now promoted to default ICU behavior. +# Note: this is not default UAX-14 behaviour. See issue ICU-8151. +# +^($HY | $HH) $CM* $ALPlus; + # LB 21 x (BA | HY | NS) # BB x # # DO allow breaks here before NSX, so don't include it $LB20NonBreaks $CM* ($BA | $HY | $NS); + + ^$CM+ ($BA | $HY | $NS); $BB $CM* [^$CB]; # $BB x @@ -267,16 +299,14 @@ $HL $CM* ($HY | $BA) $CM* [^$CB]?; # (break between HL and SY already disallowed by LB 13 above) $SY $CM* $HL; -# LB 22 -($ALPlus | $HL) $CM* $IN; -^$CM+ $IN; # by rule 10, any otherwise unattached CM behaves as AL -$EX $CM* $IN; -($ID | $EB | $EM) $CM* $IN; -# $IN $CM* $IN; # delete this rule for CSS loose -$NU $CM* $IN; + +# LB 22 Do not break before ellipses +# +[$LB20NonBreaks - $IN] $CM* $IN; # line_loose tailoring +^$CM+ $IN; -# $LB 23 +# LB 23 # ($ALPlus | $HL) $CM* $NU; ^$CM+ $NU; # Rule 10, any otherwise unattached CM behaves as AL @@ -298,7 +328,7 @@ $PR $CM* ($ID | $EB | $EM); # # LB 25 Numbers. # -(($PR | $PO) $CM*)? (($OP | $HY) $CM*)? $NU ($CM* ($NU | $SY | $IS))* +(($PR | $PO) $CM*)? (($OP | $HY) $CM*)? ($IS $CM*)? $NU ($CM* ($NU | $SY | $IS))* ($CM* ($CL | $CP))? ($CM* ($PR | $PO))?; # LB 26 Do not break a Korean syllable @@ -322,15 +352,15 @@ $PR $CM* ($JL | $JV | $JT | $H2 | $H3); $IS $CM* ($ALPlus | $HL); # LB 30 -($ALPlus | $HL | $NU) $CM* $OP; -^$CM+ $OP; # The $CM+ is from rule 10, an unattached CM is treated as AL. -$CP $CM* ($ALPlus | $HL | $NU); +($ALPlus | $HL | $NU) $CM* $OP30; +^$CM+ $OP30; # The $CM+ is from rule 10, an unattached CM is treated as AL. +$CP30 $CM* ($ALPlus | $HL | $NU); # LB 30a Do not break between regional indicators. Break after pairs of them. # Tricky interaction with LB8a: ZWJ x . together with ZWJ acting like a CM. -$RI $CM* $RI / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM]]; -$RI $CM* $RI $CM* [$CM-$ZWJ] / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM]]; -$RI $CM* $RI $CM* [$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $ZWJ {eof}]; +$RI $CM* $RI / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $IN $CM]]; +$RI $CM* $RI $CM* [$CM-$ZWJ] / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $IN $CM]]; +$RI $CM* $RI $CM* [$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $IN $ZWJ {eof}]; # note: the preceding rule includes {eof} rather than having the last [set] term qualified with '?' # because of the chain-out behavior difference. The rule must chain out only from the [set characters], # not from the preceding $RI or $CM, which it would be able to do if the set were optional.