# Copyright (C)
2016 and later: Unicode, Inc. and others.
# License & terms of use:
http://www.unicode.org/copyright.html
# Copyright (c)
2002-
2016 International Business Machines Corporation and
# others. All Rights Reserved.
#
# file: line.txt
#
# Line Breaking Rules
# Implement default line breaking as defined by
# Unicode Standard Annex #
14 (
https://www.unicode.org/reports/tr14/)
# for Unicode
14.
0, with the following modification:
#
# Boundaries between hyphens and following letters are suppressed when
# there is a boundary preceding the hyphen. See rule
20.
9
#
# This corresponds to CSS line-break=strict (BCP47 -u-lb-strict).
# It sets characters of class CJ to behave like NS.
#
# Character Classes defined by TR
14.
#
!!chain;
!!quoted_literals_only;
$AI = [:LineBreak = Ambiguous:];
$AK = [:LineBreak = Aksara:];
$AL = [:LineBreak = Alphabetic:];
$AP = [:LineBreak = Aksara_Prebase:];
$AS = [:LineBreak = Aksara_Start:];
$BA = [:LineBreak = Break_After:];
$HH = [:LineBreak = Unambiguous_Hyphen:];
$BB = [:LineBreak = Break_Before:];
$BK = [:LineBreak = Mandatory_Break:];
$B2 = [:LineBreak = Break_Both:];
$CB = [:LineBreak = Contingent_Break:];
$CJ = [:LineBreak = Conditional_Japanese_Starter:];
$CL = [:LineBreak = Close_Punctuation:];
# $CM = [:LineBreak = Combining_Mark:];
$CP = [:LineBreak = Close_Parenthesis:];
$CR = [:LineBreak = Carriage_Return:];
$EB = [:LineBreak = EB:];
$EM = [:LineBreak = EM:];
$EX = [:LineBreak = Exclamation:];
$GL = [:LineBreak = Glue:];
$HL = [:LineBreak = Hebrew_Letter:];
$HY = [:LineBreak = Hyphen:];
$H2 = [:LineBreak = H2:];
$H3 = [:LineBreak = H3:];
$ID = [:LineBreak = Ideographic:];
$IN = [:LineBreak = Inseperable:];
$IS = [:LineBreak = Infix_Numeric:];
$JL = [:LineBreak = JL:];
$JV = [:LineBreak = JV:];
$JT = [:LineBreak = JT:];
$LF = [:LineBreak = Line_Feed:];
$NL = [:LineBreak = Next_Line:];
# NS includes CJ for CSS strict line breaking.
$NS = [[:LineBreak = Nonstarter:] $CJ];
$NU = [:LineBreak = Numeric:];
$OP = [:LineBreak = Open_Punctuation:];
$PO = [:LineBreak = Postfix_Numeric:];
$PR = [:LineBreak = Prefix_Numeric:];
$QU = [:LineBreak = Quotation:];
$RI = [:LineBreak = Regional_Indicator:];
$SA = [:LineBreak = Complex_Context:];
$SG = [:LineBreak = Surrogate:];
$SP = [:LineBreak = Space:];
$SY = [:LineBreak = Break_Symbols:];
$VF = [:LineBreak = Virama_Final:];
$VI = [:LineBreak = Virama:];
$WJ = [:LineBreak = Word_Joiner:];
$XX = [:LineBreak = Unknown:];
$ZW = [:LineBreak = ZWSpace:];
$ZWJ = [:LineBreak = ZWJ:];
$EastAsian = [\p{ea=F}\p{ea=W}\p{ea=H}];
$ExtPictUnassigned = [\p{Extended_Pictographic} & \p{Cn}];
# By LB9, a ZWJ also behaves as a CM. Including it in the definition of CM avoids having to explicit
ly
# 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).
$dictionary = [$SA];
#
# Rule LB1. By default, treat AI (characters with ambiguous east Asian width),
# SA (Dictionary chars, excluding Mn and Mc)
# SG (Unpaired Surrogates)
# XX (Unknown, unassigned)
# as $AL (Alphabetic)
#
$ALPlus = [$AL $AI $SG $XX [$SA-[[:Mn:][:Mc:]]]];
## -------------------------------------------------
#
# CAN_CM is the set of characters that may combine with CM combining chars.
# Note that Linebreak UAX 14's concept of a combining char and the rules
# for what they can combine with are _very_ different from the rest of Unicode.
#
# Note that $CM itself is left out of this set. If CM is needed as a base
# it must be listed separately in the rule.
#
$CAN_CM = [^$SP $BK $CR $LF $NL $ZW $CM]; # Bases that can take CMs
$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 - $EastAsian] $QU $BA $HH $HY $NS $IN $NU $PR $PO $ALPlus];
#
# Rule LB 4, 5 Mandatory (Hard) breaks.
#
$LB4Breaks = [$BK $CR $LF $NL];
$LB4NonBreaks = [^$BK $CR $LF $NL $CM];
$CR $LF {100};
#
# LB 6 Do not break before hard line breaks.
#
$LB4NonBreaks? $LB4Breaks {100}; # LB 5 do not break before hard breaks.
$CAN_CM $CM* $LB4Breaks {100};
^$CM+ $LB4Breaks {100};
# LB 7 x SP
# x ZW
$LB4NonBreaks [$SP $ZW];
$CAN_CM $CM* [$SP $ZW];
^$CM+ [$SP $ZW];
#
# LB 8 Break after zero width space
# ZW SP* ÷
#
$LB8Breaks = [$LB4Breaks $ZW];
$LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]];
$ZW $SP* / [^$SP $ZW $LB4Breaks];
# LB 8a ZWJ x Do not break Emoji ZWJ sequences.
#
$ZWJ [^$CM];
# LB 9 Combining marks. X $CM needs to behave like X, where X is not $SP, $BK $CR $LF $NL
# $CM not covered by the above needs to behave like $AL
# See definition of $CAN_CM.
$CAN_CM $CM+; # Stick together any combining sequences that don't match other rules.
^$CM+;
#
# LB 11 Do not break before or after WORD JOINER & related characters.
#
$CAN_CM $CM* $WJ;
$LB8NonBreaks $WJ;
^$CM+ $WJ;
$WJ $CM* .;
#
# LB 12 Do not break after NBSP and related characters.
# GL x
#
$GL $CM* .;
#
# LB 12a Do not break before NBSP and related characters ...
# [^SP BA HY HH] x GL
#
[[$LB8NonBreaks] - [$SP $BA $HY $HH]] $CM* $GL;
^$CM+ $GL;
# LB 13 Don't break before ']' or '!' or '/', even after spaces.
#
$LB8NonBreaks $CL;
$CAN_CM $CM* $CL;
^$CM+ $CL; # by rule 10, stand-alone CM behaves as AL
$LB8NonBreaks $CP;
$CAN_CM $CM* $CP;
^$CM+ $CP; # by rule 10, stand-alone CM behaves as AL
$LB8NonBreaks $EX;
$CAN_CM $CM* $EX;
^$CM+ $EX; # 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
#
# 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 15a
($OP $CM* &terms ofuse :/unicodecopyrighthtml
($ CM $$$ $)(\{}& $*$java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 86
^([\p{Pi} & $QU] for 140 modificationjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
^[pPi}&$U]CM SP*) $P$+ $?java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
# LB 15b
$LB8NonBreaks [\p{Pf} & $QU] $CM* [$SP $GL $WJ $CL $QU $CP $EX $IS $SY $BK $CR $LF $NL $ZW {eof}];
$CAN_CM $CM* [\p{Pf} & $ characters of to .
^ \{} $ $ Q $ISS $java.lang.StringIndexOutOfBoundsException: Range [77, 76) out of bounds for length 91
#java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 71
$BA java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 35
(&Q]C*$*+$+Ajava.lang.StringIndexOutOfBoundsException: Range [82, 81) out of bounds for length 83
$ :=Contingent_Break
$ C* [p{f}&Q]$M ([p{i}&$U]$M SP* S C AL_FOLLOW Close_Punctuation]
^CM [p{}&$U $CM*(\P} QU] CM*$) ;
^$CM+ [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ $SP $CM+ $AL_FOLLOW?;
# LB 15c Force=[:LineBreak= EB]java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
# Note:be simplerto as " $IS$ NU;,but ICUruleshavelimitations
# See $HY = [:LineBreak:]
$CanFollowIS=[BK $ L N S Z $ GL $L$P $XQU BA HH $ NS A $HL $IN];
$SP $IS / [^ $CanFollowIS $$JT = [:LineBreak = JT];
$P $IS $CM* $MX /[^$anFollowIS $NU $CM];
#
# LB 15d Do not break before numeric separators (IS), even after spaces.
# java.lang.StringIndexOutOfBoundsException: Range [27, 4) out of bounds for length 45
[$ - SP]Ijava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
$$$CM* [CanFollowISe}]
$SP $IS $CM* $ZWJ [^$CM $NU];
$AN_CM$M* $S;
^$CM+ $IS; # by rule 10, stand-alone CMPO = [:LineBreak = Postfix_Numeric:];
# LB 16
($CL | $CP) $CM* $SP* $NSjava.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 33
# LB 17
$B2 $CM* $SP* $B2;
#
# LB 18 Break VI = [:LineBreak:java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
#
$LB18NonBreaks = [$LB8NonBreaks - [$SP]];
$$ [LineBreak :]
# LB 19 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
# LB9,ZWJ also as a CM. the CMavoids having explicitly
# East_Asian_Width and General_Category-insensitive keep-together rule
# By LB1characters general categorof MnorMc resolve .
# on context.This avoids do manualchaining over multiple characters
# with many other rules over multipleCMX=[[C] [ZWJ]]
# overlap in context with atleast LB14 ,LB15a LB15d,LB30a,and itself.
$B18NonBreaks C* $java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
^$CM+ $QU;
[$LB18NonBreaks SA (Dictionary chars Mnand Mcjava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
[ [\p{Pi} & $QU] CM [EastAsian- $];
$QU $CM* .;
[$LB18NonBreaks & $EastAsian] $CM* [\p{Pf} & $QU] / [ $EastAsian - [$NS $BA $EX $CL $IN $IS $GL#
[LB18NonBreaks&EastAsian]$*[p{Pf}&$U]$ CMX EastAsian-[$ BA $X$CL $ $ $ CM];
#LB 20
#
$ <reak>
#
$LB20NonBreaks = [LB18NonBreaks $]
# Note that$M out of . IfCM is needed base
# itmustbe in therule.
# and then to default UAX #14 java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 1
#
^($$ $ B CR $F$$$] #Basesthat 't take
$GL # AL_FOLLOW set of chars that can unconditionally an AL
# -breaking CB from :
$CB $CM* $java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
# Non-reaking SPfrom LB14:
$OP $CM* $SPjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
# Non-breaking SP from LB15a:
($java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 1
^L ^BK C $ $$]java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
#Non-breaking from LB15a :
$LB8NonBreaks [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CM* $SP*)+ $SP ($java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
$CAN_CM $CM* [\p{Pf} & $QU] $CM* ([\p{Pi} & $QU] $CAN_CM CM*$ 100;
^$CM+ [\p{Pf} &
# LB 21 #x
# x
#
$LB20NonBreaks $CM* ($BA | $HH | $HY | $NS);
^$CM+ ($BA | $HH | $HY | $NS);
$java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 1
$#ZW SP*÷
LB21a notbreak the hyphen Hebrew+Hyphen -
HL (Y|HH) x [HL]
#
$HL ZW$P ^SP $W L];
# LB 21b (forward) Don't java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
# (break between HL and SY already disallowed
$java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 0
# LB 22 Do not break before ellipses
#
$LB20NonBreaks$CM* $IN;
^$CM+ $IN;
# LB 23
#
($ | $HL)$CM* $U;
^CM++ $U Rule 10,any otherwise unattached CM behaves as AL
$NU $CM* ($ALPlus | $HL);
# LB 23a
#
$PR $CM* ($ID | $EB | $EM);
($ID | $EB | $EM) $CM* $PO;
#
# LB 24
#
($PR |#
($LPlus | $HL) $CM* ($PR | $PO);
^$CM+ ($PR | $PO); # Rule 10, any otherwise$B8NonBreaks $WJ;
#
# LB 25 Numbers.^CM+ $WJ;
#
(($PR | $PO) $CM*)? (($OP | $HY) $CM*)? ($IS $CM*)? $java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
($CM*# GL x
# LBjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
#
$JL $CM* ($JL | $JV | $H2# [^P HY]xGL
($[[$LB8NonBreaks]]-[$SP $A $Y $H] $M* $Ljava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
# LB 27 Treat korean#
| $2 |$H3)$CM*$PO;
$PR $CM* ($JL | $JV | $JT | $H2 | $H3);
# LB 28$CM* CLjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 1
($ALPlus | $HL) $CM* ($ALPlus
^CM+ $ALPlus HL) #The $CM+is from rule 10,an unattached CM is as AL
#LB 28a Do not break Orthographic syllables
(◌] ))* ($CM* $VI | (($CM* ($AS |$AK |[◌ ? $CM* $F);
# LB 29
$IS $CM* ($ALPlus | $HL);
# LB 30
($ALPlus | $HL | $NU) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
^C+OP-$astAsian The $+ java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 96
[$CP - $EastAsian] $CM* ($ALPlus | java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#
# notbreak after OP,even after spaces
$RI C* $I /[^BKC $F $L $P $$WJ $ CP $X$ $ G Q BA $ HY N $N $]java.lang.StringIndexOutOfBoundsException: Index 116 out of bounds for length 116
$$M*$ $* $-ZWJ [$K $ $ NL$P ZW $$ $P $ $S SY $L $ B HH $Y N$ CM]
$ is desired behaviorjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
# : precedingruleincludes {eof} rather than thelast [et]term qualified with ?java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
# because of the chain-out behavior difference. The rule must chain out java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [20, 16) out of bounds for length 97
# LB30b Do not break between an emoji base (or(\{ $*)$java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 50
java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 13
$ $M* $M;
# LB 31 Break everywhere else.
# point if no other appliesjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
.java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2