private static string ParseExcerpt(Match match, Dictionary <string, ExcerptInfo> excerptsInfos, TransformationData data, List <PreprocessingTextChange> changes)
        {
            var name         = match.Groups["name"].Value.ToLower();
            var contentGroup = match.Groups["content"];
            var content      = contentGroup.Value;

            content = ExcerptBlock.Replace(content, m => ParseExcerpt(m, excerptsInfos, data, null));
            content = ExcerptInline.Replace(content, m => ParseExcerpt(m, excerptsInfos, data, null));

            if (excerptsInfos.ContainsKey(name))
            {
                excerptsInfos[name].Content.Append("\n" + content);
            }
            else
            {
                excerptsInfos.Add(name, new ExcerptInfo(match.Index, contentGroup.Index - match.Index, content));
            }

            if (changes != null)
            {
                changes.Add(PreprocessingTextChange.CreateRemove(match.Groups["prefix"]));
                changes.Add(PreprocessingTextChange.CreateRemove(match.Groups["postfix"]));
            }

            return(content);
        }
Esempio n. 2
0
        private string FilterEvaluator(Match match, Func <string, bool> predicate, List <PreprocessingTextChange> changes)
        {
            if (predicate(match.Groups["param"].Value))
            {
                changes.Add(PreprocessingTextChange.CreateRemove(match.Groups["begining"]));
                changes.Add(PreprocessingTextChange.CreateRemove(match.Groups["ending"]));
                return(match.Groups["content"].Value + match.Groups["postfixNewLine"].Value);
            }

            changes.Add(new PreprocessingTextChange(match.Index, match.Length, 0));
            return("");
        }