示例#1
0
        protected override IList <TextUnit> SplitUnit(TextUnit textUnit)
        {
            var foundIndex = FindLocInStr(textUnit.Text, _splitItems, out var foundItem);

            if (textUnit.CanSplit == false || foundIndex == -1)
            {
                return(new List <TextUnit> {
                    textUnit
                });
            }

            var retList       = new List <TextUnit>();
            var firstPart     = textUnit.Text.Substring(0, foundIndex);
            var lastPartStart = foundIndex + foundItem.Length;
            var lastPart      = textUnit.Text.Substring(lastPartStart, textUnit.Text.Length - lastPartStart);

            if (!string.IsNullOrEmpty(firstPart))
            {
                retList.AddRange(SplitUnit(TextUnit.CreateUnit(firstPart)));
            }
            retList.Add(TextUnit.CreateUnit(foundItem, false));
            if (!string.IsNullOrEmpty(lastPart))
            {
                retList.AddRange(SplitUnit(TextUnit.CreateUnit(lastPart)));
            }

            return(retList);
        }