2 # Copyright (C) 2016 and later: Unicode, Inc. and others.
3 # License & terms of use: http://www.unicode.org/copyright.html
4 # Copyright (C) 2002-2016, International Business Machines Corporation
5 # and others. All Rights Reserved.
10 # See Unicode Standard Annex #29.
11 # These rules are based on UAX #29 Revision 34 for Unicode Version 12.0
13 # Note: Updates to word.txt will usually need to be merged into
14 # word_POSIX.txt also.
16 ##############################################################################
18 # Character class definitions from TR 29
20 ##############################################################################
22 ### BEGIN CUSTOMIZATION
23 ### This file contains LibreOffice-specific rule customizations.
25 ### To aid future maintainability:
26 ### - The change location should be bracketed by comments of this form.
27 ### - The original rule should be commented out, and the modified rule placed alongside.
28 ### - By doing this, maintainers can more easily compare to an upstream baseline.
33 !!quoted_literals_only;
37 # Character Class Definitions.
42 $CR = [\p{Word_Break = CR}];
43 $LF = [\p{Word_Break = LF}];
44 $Newline = [\p{Word_Break = Newline}];
45 $Extend = [\p{Word_Break = Extend}-$Han];
46 $ZWJ = [\p{Word_Break = ZWJ}];
47 $Regional_Indicator = [\p{Word_Break = Regional_Indicator}];
48 $Format = [\p{Word_Break = Format}];
49 $Katakana = [\p{Word_Break = Katakana}];
50 $Hebrew_Letter = [\p{Word_Break = Hebrew_Letter}];
51 $ALetter = [\p{Word_Break = ALetter}];
52 $Single_Quote = [\p{Word_Break = Single_Quote}];
53 $MidLetter = [\p{Word_Break = MidLetter}];
54 $MidNum = [\p{Word_Break = MidNum}];
55 $Numeric = [\p{Word_Break = Numeric}];
56 $WSegSpace = [\p{Word_Break = WSegSpace}];
57 $Extended_Pict = [\p{Extended_Pictographic}];
59 ### BEGIN CUSTOMIZATION
60 ### i#13494: For the purposes of editing, standalone punctuation should be treated as a word.
61 ### This change subtracts undesired characters from the above families
63 # $MidNumLet = [\p{Word_Break = MidNumLet}];
64 $MidNumLet = [\p{Word_Break = MidNumLet}-[:name= FULL STOP:]];
66 # $ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
67 $ExtendNumLet = [\p{Word_Break = ExtendNumLet}-[:name= LOW LINE:]-[:name = NARROW NO-BREAK SPACE:]];
69 ### tdf#46950: Right double-quotes are also used as substitutes for Hebrew gershaim
70 # $Double_Quote = [\p{Word_Break = Double_Quote}];
71 $Double_Quote = [[\p{Word_Break = Double_Quote}][:name= RIGHT DOUBLE QUOTATION MARK:]];
75 $Hiragana = [:Hiragana:];
76 $Ideographic = [\p{Ideographic}];
79 # Dictionary character set, for triggering language-based break engines. Currently
80 # limited to LineBreak=Complex_Context. Note that this set only works in Unicode
81 # 5.0 or later as the definition of Complex_Context was corrected to include all
82 # characters requiring dictionary break.
84 $Control = [\p{Grapheme_Cluster_Break = Control}];
85 $HangulSyllable = [\uac00-\ud7a3];
86 $ComplexContext = [:LineBreak = Complex_Context:];
87 $KanaKanji = [$Han $Hiragana $Katakana];
88 $dictionaryCJK = [$KanaKanji $HangulSyllable];
89 $dictionary = [$ComplexContext $dictionaryCJK];
91 # TODO: check if handling of katakana in dictionary makes rules incorrect/void
93 # leave CJK scripts out of ALetterPlus
94 $ALetterPlus = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];
97 ## -------------------------------------------------
103 # Rule 3c Do not break within emoji zwj sequences.
104 # ZWJ × \p{Extended_Pictographic}. Precedes WB4, so no intervening Extend chars allowed.
108 # Rule 3d - Keep horizontal whitespace together.
110 $WSegSpace $WSegSpace;
112 # Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
113 # of a region of Text.
115 $ExFm = [$Extend $Format $ZWJ];
117 ^$ExFm+; # This rule fires only when there are format or extend characters at the
118 # start of text, or immediately following another boundary. It groups them, in
119 # the event there are more than one.
121 [^$CR $LF $Newline $ExFm] $ExFm*; # This rule rule attaches trailing format/extends to words,
122 # with no special rule status value.
124 $Numeric $ExFm* {100}; # This group of rules also attach trailing format/extends, but
125 $ALetterPlus $ExFm* {200}; # with rule status set based on the word's final base character.
126 $HangulSyllable {200};
127 $Hebrew_Letter $ExFm* {200};
128 $Katakana $ExFm* {400}; # note: these status values override those from rule 5
129 $Hiragana $ExFm* {400}; # by virtue of being numerically larger.
130 $Ideographic $ExFm* {400}; #
134 # Do not break between most letters.
136 ($ALetterPlus | $Hebrew_Letter) $ExFm* ($ALetterPlus | $Hebrew_Letter);
139 ($ALetterPlus | $Hebrew_Letter) $ExFm* ($MidLetter | $MidNumLet | $Single_Quote) $ExFm* ($ALetterPlus | $Hebrew_Letter) {200};
142 $Hebrew_Letter $ExFm* $Single_Quote {200};
145 $Hebrew_Letter $ExFm* $Double_Quote $ExFm* $Hebrew_Letter;
149 $Numeric $ExFm* $Numeric;
153 ($ALetterPlus | $Hebrew_Letter) $ExFm* $Numeric;
157 $Numeric $ExFm* ($ALetterPlus | $Hebrew_Letter);
161 $Numeric $ExFm* ($MidNum | $MidNumLet | $Single_Quote) $ExFm* $Numeric;
164 # to be consistent with $KanaKanji $KanaKanhi, changed
166 # See also TestRuleStatus in intltest/rbbiapts.cpp
167 $Katakana $ExFm* $Katakana {400};
170 # allow to select numbers with narrow no-break spaces as thousand separators
171 $ExtendNumLetNNBSP = [\p{Word_Break = ExtendNumLet}];
173 $ALetterPlus $ExFm* $ExtendNumLet {200}; # (13a)
174 $Hebrew_Letter $ExFm* $ExtendNumLet {200}; # (13a)
175 $Numeric $ExFm* $ExtendNumLetNNBSP {100}; # (13a)
176 $Katakana $ExFm* $ExtendNumLet {400}; # (13a)
177 $ExtendNumLet $ExFm* $ExtendNumLet {200}; # (13a)
179 $ExtendNumLet $ExFm* $ALetterPlus {200}; # (13b)
180 $ExtendNumLet $ExFm* $Hebrew_Letter {200}; # (13b)
181 $ExtendNumLetNNBSP $ExFm* $Numeric {100}; # (13b)
182 $ExtendNumLet $ExFm* $Katakana {400}; # (13b)
185 # Pairs of Regional Indicators stay together.
186 # With incoming rule chaining disabled by ^, this rule will match exactly two of them.
187 # No other rule begins with a Regional_Indicator, so chaining cannot extend the match.
189 ^$Regional_Indicator $ExFm* $Regional_Indicator;
191 # special handling for CJK characters: chain for later dictionary segmentation
192 $HangulSyllable $HangulSyllable {200};
193 $KanaKanji $KanaKanji {400}; # different rule status if both kana and kanji found
195 ### BEGIN CUSTOMIZATION
196 ### i#13494: For the purposes of editing, standalone punctuation should be treated as a word.
197 ### This customization does not replace any rules.
198 [[:P:][:S:]-[:name = FULL STOP:]]*
199 [[:name = FULL STOP:]]*;
200 ### END CUSTOMIZATION
203 # Match a single code point if no other rule applies.