public string ChangeText(string text)
        {
            IEnumerable <WNode> nodes = Tagger.Parse(text);

            if (ChangeToJotai)
            {
                Changer.PreferDearu = (JotaiPreferences & JotaiPreferences.PreferDearu) != 0;
                var buffer = new EditBuffer(nodes);
                Changer.ToJotai(buffer);
                nodes = buffer;
            }
            Combiner.CombineMode = CombineMode;
            switch (WidthPreferences
                    & (WidthPreferences.HalfwidthParentheses | WidthPreferences.FullwidthParentheses))
            {
            case WidthPreferences.HalfwidthParentheses:
                Combiner.Postprocess = TokenCombiner.AsciiParentheses;
                break;

            case WidthPreferences.FullwidthParentheses:
                Combiner.Postprocess = TokenCombiner.FullWidthParentheses;
                break;

            default:
                Combiner.Postprocess = null;
                break;
            }
            if (WidthPreferences.None != (WidthPreferences
                                          & (WidthPreferences.FullwidthAlphabets
                                             | WidthPreferences.FullwidthDigits
                                             | WidthPreferences.FullwidthSymbols
                                             | WidthPreferences.CustomFullwidthSet)))
            {
                var p = TokenCombiner.SimpleFullwidthPostprocess(
                    WidthPreferences.HasFlag(WidthPreferences.FullwidthAlphabets) ? TokenCombiner.AsciiAlphabets : null,
                    WidthPreferences.HasFlag(WidthPreferences.FullwidthDigits) ? TokenCombiner.AsciiDigits : null,
                    WidthPreferences.HasFlag(WidthPreferences.FullwidthSymbols) ? TokenCombiner.OtherAsciiSymbols : null,
                    WidthPreferences.HasFlag(WidthPreferences.CustomFullwidthSet) ? CustomFullwidthSet : null);
                var q = Combiner.Postprocess;
                Combiner.Postprocess = (q == null) ? p : sb => p(q(sb));
            }
            if (WidthPreferences.None != (WidthPreferences
                                          & WidthPreferences.CustomHalfwidthSet))
            {
                var p = TokenCombiner.SimpleHalfwidthPostprocess(
                    WidthPreferences.HasFlag(WidthPreferences.CustomHalfwidthSet) ? CustomHalfwidthSet : null);
                var q = Combiner.Postprocess;
                Combiner.Postprocess = (q == null) ? p : sb => p(q(sb));
            }
            var result = Combiner.Combine(nodes);

            return(result);
        }
Пример #2
0
 public string Combine(IEnumerable <TToken> tokens)
 {
     return(TokenCombiner.Combine(tokens, CombineMode, Space, Renderer, Spacer, Postprocess));
 }