Exemplo n.º 1
0
        private string transform(string text)
        {
            if (string.IsNullOrEmpty(text))
                return string.Empty;

            var parser = new Markdown();
            parser.ExtendWith(new StatefulCheckboxPattern());

            var t = parser.Transform(text);

            //prevent html from being replaced by wikiwords
            var htmlTags = new Queue<string>();
            t = _htmlTagsRegex.Replace(t, m =>
            {
                htmlTags.Enqueue(m.Groups[0].Value);
                return _emaPlaceholder;
            });

            //don't extend markdown with this pattern because it will destroy links
            t = new WikiWordsPattern().Transform(t);

            return _htmlTagsRegex.Replace(t, m =>
            {
                if (m.Groups[0].Value == _emaPlaceholder)
                {
                    return htmlTags.Dequeue();
                }
                else
                {
                    //new wikiword link
                    return m.Groups[0].Value;
                }
            });
        }
Exemplo n.º 2
0
        private string transform(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(string.Empty);
            }

            var parser = new Markdown();

            parser.ExtendWith(new StatefulCheckboxPattern());

            var t = parser.Transform(text);

            //prevent html from being replaced by wikiwords
            var htmlTags = new Queue <string>();

            t = htmlTagsRegex.Replace(t, m =>
            {
                htmlTags.Enqueue(m.Groups[0].Value);
                return(EMA_PLACEHOLDER);
            });

            //don't extend markdown with this pattern because it will destroy links
            t = new WikiWordsPattern().Transform(t);

            return(htmlTagsRegex.Replace(t, m =>
            {
                if (m.Groups[0].Value == EMA_PLACEHOLDER)
                {
                    return htmlTags.Dequeue();
                }
                else
                {
                    //new wikiword link
                    return m.Groups[0].Value;
                }
            }));
        }