Esempio n. 1
0
        public string Transform(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(string.Empty);
            }

            var result = CommonMark.CommonMarkConverter.Convert(text);

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

            result = HtmlTagsRegex.Replace(result, m =>
            {
                htmlTags.Enqueue(m.Groups[0].Value);
                return(EmaPlaceholder);
            });

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

            result = HtmlTagsRegex.Replace(result, m =>
            {
                if (m.Groups[0].Value == EmaPlaceholder)
                {
                    return(htmlTags.Dequeue());
                }
                //new wikiword link
                return(m.Groups[0].Value);
            });

            return(result);
        }
Esempio n. 2
0
        public string Transform(string text)
        {
            if (string.IsNullOrEmpty(text))
                return string.Empty;

            var result = CommonMark.CommonMarkConverter.Convert(text);

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

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

            result = HtmlTagsRegex.Replace(result, m =>
            {
                if (m.Groups[0].Value == EmaPlaceholder)
                {
                    return htmlTags.Dequeue();
                }
                //new wikiword link
                return m.Groups[0].Value;
            });

            return result;
        }