+# 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.
#
#
# Line Breaking Rules
# Implement default line breaking as defined by
-# Unicode Standard Annex #14 Revision 35 for Unicode 8.0
+# Unicode Standard Annex #14 Revision 37 for Unicode 9.0
# http://www.unicode.org/reports/tr14/
-# tailored as noted in 2nd paragraph below..
+# tailored as noted in 2nd paragraph below.
#
-# Includes the Emoji breaking proposals from Unicode L2/16-011R3.
-# http://www.unicode.org/L2/L2016/16011r3-break-prop-emoji.pdf
+# Includes extensions to the handling of emoji ZWJ sequences from
+# https://goo.gl/cluFCn
#
# TODO: Rule LB 8 remains as it was in Unicode 5.2
# This is only because of a limitation of ICU break engine implementation,
# This tailors the line break behavior for Finnish, while otherwise behaving
# per UAX 14 which corresponds to CSS line-break=strict (BCP47 -u-lb-strict).
# It sets characters of class CJ to behave like NS.
+#
+# 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;
-!!lookAheadHardBreak;
-#
-# !!lookAheadHardBreak Described here because it is (as yet) undocumented elsewhere
-# and only used for the line break rules.
-#
-# It is used in the implementation of rule LB 10
-# which says to treat any combining mark that is not attached to a base
-# character as if it were of class AL (alphabetic).
-#
-# The problem occurs in the reverse rules.
-#
-# Consider a sequence like, with correct breaks as shown
-# LF ID CM AL AL
-# ^ ^ ^
-# Then consider the sequence without the initial ID (ideographic)
-# LF CM AL AL
-# ^ ^
-# Our CM, which in the first example was attached to the ideograph,
-# is now unattached, becomes an alpha, and joins in with the other
-# alphas.
-#
-# When iterating forwards, these sequences do not present any problems
-# When iterating backwards, we need to look ahead when encountering
-# a CM to see whether it attaches to something further on or not.
-# (Look-ahead in a reverse rule is looking towards the start)
-#
-# If the CM is unattached, we need to force a break.
-#
-# !!lookAheadHardBreak forces the run time state machine to
-# stop immediately when a look ahead rule ( '/' operator) matches,
-# and set the match position to that of the look-ahead operator,
-# no matter what other rules may be in play at the time.
-#
-# See rule LB 19 for an example.
-#
-
-# Temporary definitions of Emoji Base and Emoji Modifiers, until properties are available.
-
-$EB = [\u261D\u26F9\u270A-\u270D\U0001F385\U0001F3C3-\U0001F3C4\U0001F3CA-\U0001F3CB\U0001F442-\U0001F443\U0001F446-\U0001F450\U0001F466-\U0001F469\U0001F46E\U0001F470-\U0001F478\U0001F47C\U0001F481-\U0001F483\U0001F485-\U0001F487\U0001F4AA\U0001F575\U0001F590\U0001F595-\U0001F596\U0001F645-\U0001F647\U0001F64B-\U0001F64F\U0001F6A3\U0001F6B4-\U0001F6B6\U0001F6C0\U0001F918];
-$EM = [\U0001F3FB-\U0001F3FF];
-
-$AI = [[:LineBreak = Ambiguous:] - [\u2640\u2642]];
-$AL = [[:LineBreak = Alphabetic:] - [$EM\u2764]];
+$AI = [:LineBreak = Ambiguous:];
+$AL = [:LineBreak = Alphabetic:];
$BA = [:LineBreak = Break_After:];
-$HH = [\u2010];
+$HH = [\u2010]; # \u2010 is HYPHEN, default line break is BA.
$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:] \u200d];
+# $CM = [:LineBreak = Combining_Mark:];
$CP = [:LineBreak = Close_Parenthesis:];
$CR = [:LineBreak = Carriage_Return:];
+$EB = [[:LineBreak = EB:] \U0001F46A-\U0001F46D\U0001F46F\U0001F91D\U0001F93C];
+$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:][\u2640\u2642\u2764] - $EB];
+$ID = [:LineBreak = Ideographic:];
$IN = [:LineBreak = Inseperable:];
$IS = [:LineBreak = Infix_Numeric:];
$JL = [:LineBreak = JL:];
$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:];
$WJ = [:LineBreak = Word_Joiner:];
$XX = [:LineBreak = Unknown:];
$ZW = [:LineBreak = ZWSpace:];
-$ZWJ = [\u200d];
+$ZWJ = [:LineBreak = ZWJ:];
+
+$EmojiNRK = [[\p{Emoji}] - [$RI \u002a\u00230-9©®™〰〽]];
+# Data for Extended Pictographic scraped from CLDR common/properties/ExtendedPictographic.txt, r13267
+$Extended_Pict = [\U0001F774-\U0001F77F\U00002700-\U00002701\U00002703-\U00002704\U0000270E\U00002710-\U00002711\U00002765-\U00002767\U0001F030-\U0001F093\U0001F094-\U0001F09F\U0001F10D-\U0001F10F\U0001F12F\U0001F16C-\U0001F16F\U0001F1AD-\U0001F1E5\U0001F260-\U0001F265\U0001F203-\U0001F20F\U0001F23C-\U0001F23F\U0001F249-\U0001F24F\U0001F252-\U0001F25F\U0001F266-\U0001F2FF\U0001F7D5-\U0001F7FF\U0001F000-\U0001F003\U0001F005-\U0001F02B\U0001F02C-\U0001F02F\U0001F322-\U0001F323\U0001F394-\U0001F395\U0001F398\U0001F39C-\U0001F39D\U0001F3F1-\U0001F3F2\U0001F3F6\U0001F4FE\U0001F53E-\U0001F548\U0001F54F\U0001F568-\U0001F56E\U0001F571-\U0001F572\U0001F57B-\U0001F586\U0001F588-\U0001F589\U0001F58E-\U0001F58F\U0001F591-\U0001F594\U0001F597-\U0001F5A3\U0001F5A6-\U0001F5A7\U0001F5A9-\U0001F5B0\U0001F5B3-\U0001F5BB\U0001F5BD-\U0001F5C1\U0001F5C5-\U0001F5D0\U0001F5D4-\U0001F5DB\U0001F5DF-\U0001F5E0\U0001F5E2\U0001F5E4-\U0001F5E7\U0001F5E9-\U0001F5EE\U0001F5F0-\U0001F5F2\U0001F5F4-\U0001F5F9\U00002605\U00002607-\U0000260D\U0000260F-\U00002610\U00002612\U00002616-\U00002617\U00002619-\U0000261C\U0000261E-\U0000261F\U00002621\U00002624-\U00002625\U00002627-\U00002629\U0000262B-\U0000262D\U00002630-\U00002637\U0000263B-\U00002647\U00002654-\U0000265F\U00002661-\U00002662\U00002664\U00002667\U00002669-\U0000267A\U0000267C-\U0000267E\U00002680-\U00002691\U00002695\U00002698\U0000269A\U0000269D-\U0000269F\U000026A2-\U000026A9\U000026AC-\U000026AF\U000026B2-\U000026BC\U000026BF-\U000026C3\U000026C6-\U000026C7\U000026C9-\U000026CD\U000026D0\U000026D2\U000026D5-\U000026E8\U000026EB-\U000026EF\U000026F6\U000026FB-\U000026FC\U000026FE-\U000026FF\U00002388\U0001FA00-\U0001FFFD\U0001F0A0-\U0001F0AE\U0001F0B1-\U0001F0BF\U0001F0C1-\U0001F0CF\U0001F0D1-\U0001F0F5\U0001F0AF-\U0001F0B0\U0001F0C0\U0001F0D0\U0001F0F6-\U0001F0FF\U0001F80C-\U0001F80F\U0001F848-\U0001F84F\U0001F85A-\U0001F85F\U0001F888-\U0001F88F\U0001F8AE-\U0001F8FF\U0001F900-\U0001F90B\U0001F91F\U0001F928-\U0001F92F\U0001F931-\U0001F932\U0001F94C\U0001F95F-\U0001F96B\U0001F992-\U0001F997\U0001F9D0-\U0001F9E6\U0001F90C-\U0001F90F\U0001F93F\U0001F94D-\U0001F94F\U0001F96C-\U0001F97F\U0001F998-\U0001F9BF\U0001F9C1-\U0001F9CF\U0001F9E7-\U0001F9FF\U0001F6C6-\U0001F6CA\U0001F6D3-\U0001F6D4\U0001F6E6-\U0001F6E8\U0001F6EA\U0001F6F1-\U0001F6F2\U0001F6F7-\U0001F6F8\U0001F6D5-\U0001F6DF\U0001F6ED-\U0001F6EF\U0001F6F9-\U0001F6FF];
+
+# 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:]]]];
# Dictionary character set, for triggering language-based break engines. Currently
-# limited to LineBreak=Complex_Context. Note that this set only works in Unicode
-# 5.0 or later as the definition of Complex_Context was corrected to include all
-# characters requiring dictionary break.
+# limited to LineBreak=Complex_Context (SA).
-$dictionary = [:LineBreak = Complex_Context:];
+$dictionary = [$SA];
#
# Rule LB1. By default, treat AI (characters with ambiguous east Asian width),
-# SA (South East Asian: Thai, Lao, Khmer)
+# SA (Dictionary chars, excluding Mn and Mc)
# SG (Unpaired Surrogates)
# XX (Unknown, unassigned)
# as $AL (Alphabetic)
#
-$ALPlus = [$AL $AI $SA $SG $XX];
-
-#
-# Combining Marks. X $CM* behaves as if it were X. Rule LB6.
-#
-$ALcm = $ALPlus $CM*;
-$BAcm = $BA $CM*;
-$HHcm = $HH $CM*;
-$BBcm = $BB $CM*;
-$B2cm = $B2 $CM*;
-$CLcm = $CL $CM*;
-$CPcm = $CP $CM*;
-$EXcm = $EX $CM*;
-$GLcm = $GL $CM*;
-$HLcm = $HL $CM*;
-$HYcm = $HY $CM*;
-$H2cm = $H2 $CM*;
-$H3cm = $H3 $CM*;
-$INcm = $IN $CM*;
-$IScm = $IS $CM*;
-$JLcm = $JL $CM*;
-$JVcm = $JV $CM*;
-$JTcm = $JT $CM*;
-$NScm = $NS $CM*;
-$NUcm = $NU $CM*;
-$OPcm = $OP $CM*;
-$POcm = $PO $CM*;
-$PRcm = $PR $CM*;
-$QUcm = $QU $CM*;
-$RIcm = $RI $CM*;
-$SYcm = $SY $CM*;
-$WJcm = $WJ $CM*;
+$ALPlus = [$AL $AI $SG $XX [$SA-[[:Mn:][:Mc:]]]];
+
## -------------------------------------------------
!!forward;
-#
-# Each class of character can stand by itself as an unbroken token, with trailing combining stuff
-#
-$ALPlus $CM+;
-$BA $CM+;
-$HH $CM+;
-$BB $CM+;
-$B2 $CM+;
-$CL $CM+;
-$CP $CM+;
-$EB $CM+;
-$EM $CM+;
-$EX $CM+;
-$GL $CM+;
-$HL $CM+;
-$HY $CM+;
-$H2 $CM+;
-$H3 $CM+;
-$ID $CM+;
-$IN $CM+;
-$IS $CM+;
-$JL $CM+;
-$JV $CM+;
-$JT $CM+;
-$NS $CM+;
-$NU $CM+;
-$OP $CM+;
-$PO $CM+;
-$PR $CM+;
-$QU $CM+;
-$RI $CM+;
-$SY $CM+;
-$WJ $CM+;
-
#
# 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
#
# AL_FOLLOW set of chars that can unconditionally follow an AL
# Needed in rules where stand-alone $CM s are treated as AL.
-# Chaining is disabled with CM because it causes other failures,
-# so for this one case we need to manually list out longer sequences.
#
-$AL_FOLLOW_NOCM = [$BK $CR $LF $NL $ZW $SP];
-$AL_FOLLOW_CM = [$CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $HH $HY $NS $IN $NU $ALPlus];
-$AL_FOLLOW = [$AL_FOLLOW_NOCM $AL_FOLLOW_CM];
+$AL_FOLLOW = [$BK $CR $LF $NL $ZW $SP $CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $HH $HY $NS $IN $NU $PR $PO $ALPlus];
#
$LB8Breaks = [$LB4Breaks $ZW];
$LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]];
-# LB 8a ZWJ x ID Emoji proposal.
+# LB 8a ZWJ x (ID | Extended_Pict | EmojiNRK) Emoji ZWJ sequences.
#
-$ZWJ ($ID | $EB | $EM);
+$ZWJ ($ID | $Extended_Pict | $EmojiNRK);
# 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
#
# LB 11 Do not break before or after WORD JOINER & related characters.
#
-$CAN_CM $CM* $WJcm;
-$LB8NonBreaks $WJcm;
-^$CM+ $WJcm;
+$CAN_CM $CM* $WJ;
+$LB8NonBreaks $WJ;
+^$CM+ $WJ;
-$WJcm $CANT_CM;
-$WJcm $CAN_CM $CM*;
+$WJ $CM* .;
#
# LB 12 Do not break after NBSP and related characters.
# GL x
#
-$GLcm $CAN_CM $CM*;
-$GLcm $CANT_CM;
+$GL $CM* .;
#
# LB 12a Do not break before NBSP and related characters ...
# [^SP BA HY] x GL
#
-[[$LB8NonBreaks] - [$SP $BA $HH $HY]] $CM* $GLcm;
-^$CM+ $GLcm;
+[[$LB8NonBreaks] - [$SP $BA $HH $HY]] $CM* $GL;
+^$CM+ $GL;
#
# LB 14 Do not break after OP, even after spaces
#
-$OPcm $SP* $CAN_CM $CM*;
-$OPcm $SP* $CANT_CM;
+$OP $CM* $SP* .;
-$OPcm $SP+ $CM+ $AL_FOLLOW?; # by rule 10, stand-alone CM behaves as AL
+$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 15
-$QUcm $SP* $OPcm;
+$QU $CM* $SP* $OP;
# LB 16
-($CLcm | $CPcm) $SP* $NScm;
+($CL | $CP) $CM* $SP* $NS;
# LB 17
-$B2cm $SP* $B2cm;
+$B2 $CM* $SP* $B2;
#
# LB 18 Break after spaces.
# LB 19
# x QU
-$LB18NonBreaks $CM* $QUcm;
-^$CM+ $QUcm;
+$LB18NonBreaks $CM* $QU;
+^$CM+ $QU;
# QU x
-$QUcm .?;
+$QU $CM* .;
# LB 20
# LB 21 x (BA | HY | NS)
# BB x
#
-$LB20NonBreaks $CM* ($BAcm | $HHcm | $HYcm | $NScm) / $AL;
-$LB20NonBreaks $CM* ($BAcm | $HHcm | $HYcm | $NScm);
+$LB20NonBreaks $CM* ($BA | $HH | $HY | $NS) $CM* / $AL;
+$LB20NonBreaks $CM* ($BA | $HH | $HY | $NS);
($HY | $HH) $AL;
-^$CM+ ($BAcm | $HYcm | $HHcm | $NScm);
+^$CM+ ($BA | $HY | $HH | $NS);
-$BBcm [^$CB]; # $BB x
-$BBcm $LB20NonBreaks $CM*;
+$BB $CM* [^$CB]; # $BB x
+$BB $CM* $LB20NonBreaks;
# LB 21a Don't break after Hebrew + Hyphen
# HL (HY | BA) x
-#
-$HLcm ($HYcm | $BAcm | $HHcm) [^$CB]?;
+#
+$HL $CM* ($HY | $BA | $HH) $CM* [^$CB]?;
# LB 21b (forward) Don't break between SY and HL
# (break between HL and SY already disallowed by LB 13 above)
-$SYcm $HLcm;
+$SY $CM* $HL;
# LB 22
-($ALcm | $HLcm) $INcm;
-^$CM+ $INcm; # by rule 10, any otherwise unattached CM behaves as AL
-$EXcm $INcm;
-($ID | $EB | $EM) $CM* $INcm;
-$INcm $INcm;
-$NUcm $INcm;
+($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;
+$NU $CM* $IN;
# $LB 23
-($ID | $EB | $EM) $CM* $POcm;
-$ALcm $NUcm; # includes $LB19
-$HLcm $NUcm;
-^$CM+ $NUcm; # Rule 10, any otherwise unattached CM behaves as AL
-$NUcm $ALcm;
-$NUcm $HLcm;
+#
+($ALPlus | $HL) $CM* $NU;
+^$CM+ $NU; # 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
#
-$PRcm ($ID | $EB | $EM);
-$PRcm ($ALcm | $HLcm);
-$POcm ($ALcm | $HLcm);
-($ALcm | $HLcm) ($PRcm | $POcm);
-^$CM+ ($PRcm | $POcm); # Rule 10, any otherwise unattached CM behaves as AL
+($PR | $PO) $CM* ($ALPlus | $HL);
+($ALPlus | $HL) $CM* ($PR | $PO);
+^$CM+ ($PR | $PO); # Rule 10, any otherwise unattached CM behaves as AL
#
# LB 25 Numbers.
#
-($PRcm | $POcm)? ($OPcm | $HYcm)? $NUcm ($NUcm | $SYcm | $IScm)* ($CLcm | $CPcm)? ($PRcm | $POcm)?;
+(($PR | $PO) $CM*)? (($OP | $HY) $CM*)? $NU ($CM* ($NU | $SY | $IS))*
+ ($CM* ($CL | $CP))? ($CM* ($PR | $PO))?;
# LB 26 Do not break a Korean syllable
#
-$JLcm ($JLcm | $JVcm | $H2cm | $H3cm);
-($JVcm | $H2cm) ($JVcm | $JTcm);
-($JTcm | $H3cm) $JTcm;
+$JL $CM* ($JL | $JV | $H2 | $H3);
+($JV | $H2) $CM* ($JV | $JT);
+($JT | $H3) $CM* $JT;
# LB 27 Treat korean Syllable Block the same as ID (don't break it)
-($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $INcm;
-($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $POcm;
-$PRcm ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm);
+($JL | $JV | $JT | $H2 | $H3) $CM* $IN;
+($JL | $JV | $JT | $H2 | $H3) $CM* $PO;
+$PR $CM* ($JL | $JV | $JT | $H2 | $H3);
# LB 28 Do not break between alphabetics
#
-($ALcm | $HLcm) ($ALcm | $HLcm);
-^$CM+ ($ALcm | $HLcm); # The $CM+ is from rule 10, an unattached CM is treated as AL
+($ALPlus | $HL) $CM* ($ALPlus | $HL);
+^$CM+ ($ALPlus | $HL); # The $CM+ is from rule 10, an unattached CM is treated as AL
# LB 29
-$IScm ($ALcm | $HLcm);
+$IS $CM* ($ALPlus | $HL);
# LB 30
-($ALcm | $HLcm | $NUcm) $OPcm;
-^$CM+ $OPcm; # The $CM+ is from rule 10, an unattached CM is treated as AL.
-$CPcm ($ALcm | $HLcm | $NUcm);
+($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);
# LB 30a Do not break between regional indicators. Break after pairs of them.
# Tricky interaction with LB8a: ZWJ x ID
-$RIcm $RI / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM] {eof}];
-$RIcm $RI $CM* $ZWJ / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM $ID $EB $EM] {eof}];
-$RIcm $RI $CM* [$CM-$ZWJ] / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM] {eof}];
+$RI $CM* $RI / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM] {eof}];
+$RI $CM* $RI $CM* $ZWJ / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM $ID $Extended_Pict $EmojiNRK] {eof}];
+$RI $CM* $RI $CM* [$CM-$ZWJ] / [[^$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS $CM] {eof}];
-$RIcm $RIcm [$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS {eof}];
-$RIcm $RIcm $ZWJ ($ID | $EB | $EM);
+$RI $CM* $RI $CM* [$BK $CR $LF $NL $SP $ZW $WJ $CL $CP $EX $IS $SY $GL $QU $BA $HY $NS {eof}];
+$RI $CM* $RI $CM* $ZWJ ($ID | $Extended_Pict | $EmojiNRK);
# LB 30b Do not break between an Emoji Base and an Emoji Modifier
$EB $CM* $EM;
!!reverse;
-^$CM+ $ALPlus;
-^$CM+ $BA;
-^$CM+ $HH;
-^$CM+ $BB;
-^$CM+ $B2;
-^$CM+ $CL;
-^$CM+ $CP;
-^$CM+ $EB;
-^$CM+ $EM;
-^$CM+ $EX;
-^$CM+ $GL;
-^$CM+ $HL;
-^$CM+ $HY;
-^$CM+ $H2;
-^$CM+ $H3;
-^$CM+ $ID;
-^$CM+ $IN;
-^$CM+ $IS;
-^$CM+ $JL;
-^$CM+ $JV;
-^$CM+ $JT;
-^$CM+ $NS;
-^$CM+ $NU;
-^$CM+ $OP;
-^$CM+ $PO;
-^$CM+ $PR;
-^$CM+ $QU;
-^$CM+ $RI;
-^$CM+ $SY;
-^$CM+ $WJ;
-^$CM+;
+# LB 9 Combining Marks.
+# Stick together any combining sequences that don't match other rules.
+^$CM+ $CAN_CM?;
#
# Sequences of the form (shown forwards)
# a rule compiler bug which complains about
# empty sets otherwise.
-#
-# Sequences of the form (shown forwards)
-# [CANT_CM] <break> [CM] <break> [PR]
-# The CM needs to behave as an AL
-# This rule is concerned about getting the second of the two <breaks> in place.
-#
-
-# Apple early addition, remove this, superseded by LB24
-# [$PR ] / $CM+ [$BK $CR $LF $NL $ZW $SP {eof}];
-
-
# LB 4, 5, 6
# Requires an engine enhancement.
# / $SP* $ZW
-# LB 8a ZWJ x ID Unicode Emoji proposal L2/16-011R3
-# The ZWJ will look like a CM to whatever precedes it.
+# LB 8a ZWJ x (ID | Extended_Pict | EmojiNRK)
#
-($ID | $EB | $EM) $ZWJ $CM* $CAN_CM?;
+($ID | $Extended_Pict | $EmojiNRK) $ZWJ $CM* $CAN_CM?;
# LB 9,10 Combining marks.
$IS [$LB8NonBreaks-$CM];
$SY [$LB8NonBreaks-$CM];
-# Rule 13 & 14 taken together for an edge case.
-# Match this, shown forward
-# OP SP+ ($CM+ behaving as $AL) (CL | CP | EX | IS | IY)
-# This really wants to chain at the $CM+ (which is acting as an $AL)
-# except for $CM chaining being disabled.
-[$CL $CP $EX $IS $SY] $CM+ $SP+ $CM* $OP;
# LB 14 OP SP* x
#
-$CAN_CM $SP* $CM* $OP;
- $CANT_CM $SP* $CM* $OP;
-$AL_FOLLOW? $CM+ $SP $SP* $CM* $OP; # by LB 10, behaves like $AL_FOLLOW? $AL $SP* $CM* $OP
-
- $AL_FOLLOW_NOCM $CM+ $SP+ $CM* $OP;
-$AL_FOLLOW_CM $CM+ $SP+ $CM* $OP;
+. $SP* $CM* $OP;
+$AL_FOLLOW? $CM+ $SP+ $CM* $OP; # by LB 10, behaves like $AL_FOLLOW? $AL $SP+ $CM* $OP
# LB 15
# LB 21
($BA | $HH | $HY | $NS) $CM* [$LB20NonBreaks-$CM]; # . x (BA | HY | NS)
-[$LB20NonBreaks-$CM] $CM* $BB; # BB x .
+[$LB20NonBreaks-$CM] $CM* $BB; # BB x .
[^$CB] $CM* $BB; #
# LB21a
$IN $CM* $NU;
# LB 23
-$PO $CM* ($ID | $EB | $EM);
$NU $CM* ($ALPlus | $HL);
($ALPlus | $HL) $CM* $NU;
-# LB 24
+# LB23a
($ID | $EB | $EM) $CM* $PR;
-($ALPlus | $HL) $CM* $PR;
-($ALPlus | $HL) $CM* $PO;
-$CM* ($PR | $PO) $CM* ($ALPlus | $HL);
-$CM* ($PR | $PO) $CM+ / [$BK $CR $LF $NL $ZW $SP {eof}];
+$PO $CM* ($ID | $EB | $EM);
+
+# LB 24
+($ALPlus | $HL) $CM* ($PR | $PO);
+($PR | $PO) $CM* ($ALPlus | $HL);
+
# LB 25
($CM* ($PR | $PO))? ($CM* ($CL | $CP))? ($CM* ($NU | $IS | $SY))* $CM* $NU ($CM* ($OP | $HY))? ($CM* ($PR | $PO))?;