Esempio n. 1
0
        public void ExpandArticleMacrosTest()
        {
            MarkdownArticleProcessor ar = new MarkdownArticleProcessor(getAttributeSet());
            ArticleDto a = ar.ParseArticleRawText(
                @"---
Title:Xbox Controller Repair
Date:2014-08-02
Category:Electronics
Tags:Gaming,Electronics
---
##The internals
![:youtube 800 600](https://www.youtube.com/embed/Di5AT4MI6BY)
![:youtube 512 400](http://www.youtube.com/embed/Di5AT4MI6BY)", "Some\\File.md");

            MacroInvocation mi  = ar.LocateMacrosInContent(a)[0];
            MarkdownMacro   mdm = new MarkdownMacro("youtube", "<iframe width=\"%p1%\" height=\"%p2%\" src=\"%v1%\" frameborder=\"0\"></iframe>");

            ArticleDto[] allArticles = new ArticleDto[1];
            allArticles[0] = a;
            string finalText = mdm.Expand(mi.Parameters, mi.Values, a, allArticles);

            Assert.AreEqual(
                "<iframe width=\"800\" height=\"600\" src=\"https://www.youtube.com/embed/Di5AT4MI6BY\" frameborder=\"0\"></iframe>",
                finalText.Trim());
        }
Esempio n. 2
0
        public void EscapedArticleMacrosTest()
        {
            MarkdownArticleProcessor ar = new MarkdownArticleProcessor(getAttributeSet());
            ArticleDto a = ar.ParseArticleRawText(
                @"---
Title:Xbox Controller Repair
Date:2014-08-02
Category:Electronics
Tags:Gaming,Electronics
---
##The internals
![:youtube 800 600](https://www.youtube.com/embed/Di5AT4MI6BY)
\![:noMatchMacro parm1]", "Some\\File.md");

            MacroInvocation mi  = ar.LocateMacrosInContent(a)[0];
            MarkdownMacro   mdm = new MarkdownMacro("youtube", "<iframe width=\"%p1%\" height=\"%p2%\" src=\"%v1%\" frameborder=\"0\"></iframe>");

            ArticleDto[] allArticles = new ArticleDto[1];
            allArticles[0] = a;

            IList <MacroInvocation> miList = MarkdownUtil.LocateMarkdownMacros(a.Content);

            Assert.AreEqual(1, miList.Count);
            Assert.AreEqual("youtube", miList[0].MacroName);
        }
Esempio n. 3
0
        public void LocateMacro()
        {
            MarkdownArticleProcessor ar = new MarkdownArticleProcessor(getAttributeSet());
            ArticleDto a = ar.ParseArticleRawText(
                @"---
Title:Xbox Controller Repair
Date:2014-08-02
Category:Electronics
Tags:Gaming,Electronics
---
##The internals
![:youtube 800 600](https://www.youtube.com/embed/Di5AT4MI6BY)
![:youtube 512 400](http://www.youtube.com/embed/Di5AT4MI6BY)
![My image caption](imgs/someImageNotAMacro.jpg", "Some\\File.md");

            MacroInvocation mi  = ar.LocateMacrosInContent(a)[0];
            MarkdownMacro   mdm = new MarkdownMacro("youtube", "<iframe width=\"%p1%\" height=\"%p2%\" src=\"%v1%\" frameborder=\"0\"></iframe>");

            ArticleDto[]            allArticles = new ArticleDto[1];
            IList <MacroInvocation> mis         = ar.LocateMacrosInContent(a);

            Assert.AreEqual(2, mis.Count);
            Assert.AreEqual(17, mis[0].StartingCharIndex);
            Assert.AreEqual(79, mis[0].EndingCharIndex);
        }