Esempio n. 1
0
        public void OneLine_Header3()
        {
            var tokens = new TokenListBuilder()
                .Header3(0, 0)
                    .String(0, 4, "Header 3");

            string expected = "<h3>Header 3</h3>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void PlainText_SingleParagraph()
        {
            var tokens = new TokenListBuilder()
                .String(0, 0, "First part of ")
                    .Newline(0, 13)
                    .String(1, 0, "a long string");

            string expected = "<p>First part of a long string</p>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void OneLevel()
        {
            var tokens = new TokenListBuilder()
                .Blockquote(0, 0)
                    .String(0, 2, "Something quoted")
                    .Newline(0, 18)
                    .Blockquote(1, 0)
                    .String(1, 2, "Second line of quote");

            string expected = "<blockquote><p>Something quoted</p><p>Second line of quote</p></blockquote>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 4
0
        public void WithFormatting_Emphasis()
        {
            var tokens = new TokenListBuilder()
                .String(0, 0, "String with ")
                    .Emphasis(0, 12)
                    .String(0, 13, "emphasis")
                    .Emphasis(0, 21)
                    .String(0, 22, " formatting");

            string expected = "<p>String with <em>emphasis</em> formatting</p>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 5
0
        public void Nested()
        {
            var tokens = new TokenListBuilder()
                .Blockquote(0, 0)
                    .Blockquote(0, 1)
                    .String(0, 2, "Oldest quote")
                    .Newline(0, 19)
                    .Blockquote(1, 0)
                    .String(1, 2, "Newer quote");

            string expected = "<blockquote><blockqoute><p>Oldest quote</p></blockquote><p>Newer quote</p></blockquote>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 6
0
        public void WithFormatting_Mixed()
        {
            var tokens = new TokenListBuilder()
                .String(0, 0, "He looks ")
                    .Strong(0, 9)
                    .Emphasis(0, 10)
                    .String(0, 11, "strong")
                    .Emphasis(0, 17)
                    .Strong(0, 18)
                    .String(0, 19, " tonight.");

            string expected = "<p>He looks <strong><em>strong</em></strong> tonight.</p>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 7
0
        public void Unordered()
        {
            var tokens = new TokenListBuilder()
                .UnorderedList(0, 0)
                    .String(0, 2, "Item 1")
                    .Newline(0, 8)
                    .UnorderedList(1, 0)
                    .String(1, 2, "Item 2")
                    .Newline(1, 8)
                    .UnorderedList(2, 0)
                    .String(2, 2, "Item 3");

            string expected = "<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 8
0
        public void Underline_Header1()
        {
            var tokens = new TokenListBuilder()
                .String(0, 0, "Header 1")
                    .Newline(0, 8)
                    .StrongLine(1, 0)
                    .StrongLine(1, 1)
                    .StrongLine(1, 2)
                    .StrongLine(1, 3)
                    .StrongLine(1, 4)
                    .StrongLine(1, 5)
                    .StrongLine(1, 6)
                    .StrongLine(1, 7);

            string expected = "<h1>Header 1</h1>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 9
0
        public void Plain_WithCode()
        {
            var tokens = new TokenListBuilder()
                .CodeOpen(0, 0, "plain")
                    .Newline(0, 3)
                    .Verbatim(1, 0, "for (var i=0; i<10; i++) {")
                    .Newline(1, 26)
                    .Verbatim(2, 0, "\t// do something")
                    .Newline(2, 16)
                    .Verbatim(3, 0, "}")
                    .Newline(3, 1)
                    .CodeClose(4, 0);

            string expected = @"<pre>for (var i=0; i<10; i++) {
            // do something
            }</pre>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 10
0
        public void WithFormatting_Strong()
        {
            var tokens = new TokenListBuilder()
                .String(0, 0, "String with ")
                    .Strong(0, 12)
                    .String(0, 13, "strong")
                    .Strong(0, 20)
                    .String(0, 21, " formatting");

            string expected = "<p>String with <strong>strong</strong> formatting</p>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 11
0
        public void WithLink()
        {
            var tokens = new TokenListBuilder()
                .String(0, 0, "This is a text about ")
                    .LinkLabel(0, 21, "a link")
                    .LinkUrl(0, 29, "http://domain.tld/folder/file.ext")
                    .String(0, 64, " in a text");

            string expected = "<p>This is a text about <a href=\"http://domain.tld/folder/file.ext\">a link</a> in a text</p>";

            HtmlEmitter emitter = new HtmlEmitter();
            string actual = emitter.Emit(tokens.List);

            Assert.AreEqual(expected, actual);
        }