protected string PhraseModifierFormat(string input, Regex regex, string tag)
        {
            PhraseModifierMatchEvaluator pmme = new PhraseModifierMatchEvaluator(tag, UseRestrictedMode);
            string res = regex.Replace(input, new MatchEvaluator(pmme.MatchEvaluator));

            return(res);
        }
Beispiel #2
0
        protected string PhraseModifierFormat(string input, string modifier, string tag)
        {
            // All phrase modifiers are one character, or a double character. Sometimes,
            // there's an additional escape character for the regex ('\').
            string compressedModifier = modifier;

            if (modifier.Length == 4)
            {
                compressedModifier = modifier.Substring(0, 2);
            }
            else if (modifier.Length == 2)
            {
                if (modifier[0] != '\\')
                {
                    compressedModifier = modifier.Substring(0, 1);
                }
                //else: compressedModifier = modifier;
            }
            //else: compressedModifier = modifier;

            // We try to remove the Textile tag used for the formatting from
            // the punctuation pattern, so that we match the end of the formatted
            // zone correctly.
            string punctuationPattern = Globals.PunctuationPattern.Replace(compressedModifier, "");

            // Now we can do the replacement.
            PhraseModifierMatchEvaluator pmme = new PhraseModifierMatchEvaluator(tag);
            string res = Regex.Replace(input,
                                       @"(?<=\s|" + punctuationPattern + @"|[{\(\[]|^)" +
                                       modifier +
                                       Globals.BlockModifiersPattern +
                                       @"(:(?<cite>(\S+)))?" +
                                       @"(?<content>[^" + compressedModifier + "]*)" +
                                       @"(?<end>" + punctuationPattern + @"*)" +
                                       modifier +
                                       @"(?=[\]\)}]|" + punctuationPattern + @"+|\s|$)",
                                       new MatchEvaluator(pmme.MatchEvaluator)
                                       );

            return(res);
        }
        protected internal string PhraseModifierFormat(string input, string modifier, string tag)
        {
            // All phrase modifiers are one character, or a double character. Sometimes,
            // there's an additional escape character for the regex ('\').
            string compressedModifier = modifier;
            if (modifier.Length == 4)
            {
                compressedModifier = modifier.Substring(0, 2);
            }
            else if (modifier.Length == 2)
            {
                if (modifier[0] != '\\')
                    compressedModifier = modifier.Substring(0, 1);
                //else: compressedModifier = modifier;
            }
            //else: compressedModifier = modifier;

            // We try to remove the Textile tag used for the formatting from
            // the punctuation pattern, so that we match the end of the formatted
            // zone correctly.
            string punctuationPattern = Globals.PunctuationPattern.Replace(compressedModifier, "");

            // Now we can do the replacement.
            PhraseModifierMatchEvaluator pmme = new PhraseModifierMatchEvaluator(tag);
            string res = Regex.Replace(input,
                                            @"(?<=\s|" + punctuationPattern + @"|[{\(\[]|^)" +
                                            modifier +
                                            Globals.BlockModifiersPattern +
                                            @"(:(?<cite>(\S+)))?" +
                                            @"(?<content>[^" + compressedModifier + "]*)" +
                                            @"(?<end>" + punctuationPattern + @"*)" +
                                            modifier +
                                            @"(?=[\]\)}]|" + punctuationPattern + @"+|\s|$)",
                                       new MatchEvaluator(pmme.MatchEvaluator)
                                      );
            return res;
        }