Exemplo n.º 1
0
        public void AccidentalOrderedList()
        {
            string source = @"1987\. What a great year to be born.";

            var expected = new TokenListBuilder()
                .String(0, 0, "1987. What a great year to be born.");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 2
0
        public void OneLine()
        {
            string source = @"I am amazing.";

            var expected = new TokenListBuilder()
                .String(0, 0, "I am amazing.");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 3
0
        public void Plus_OneItem()
        {
            string source = @"+ Item";

            var expected = new TokenListBuilder()
                .UnorderedList(0, 0)
                    .String(0, 2, "Item");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 4
0
        public void OneItemLargeIndexNumber()
        {
            string source = @"123. Item";

            var expected = new TokenListBuilder()
                .OrderedList(0, 0)
                    .String(0, 5, "Item");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 5
0
        public void Header1_OneLine_Valid()
        {
            string source = @"# Header1";

            var expected = new TokenListBuilder()
                .Header1(0, 0)
                    .String(0, 2, "Header1");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 6
0
        public void StartText_OneLink_Http()
        {
            string source = @"[A link](http://domain.tld/folder/file.ext) in a text";

            var expected = new TokenListBuilder()
                    .LinkLabel(0, 0, "A link")
                    .LinkUrl(0, 8, "http://domain.tld/folder/file.ext")
                    .String(0, 43, " in a text");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 7
0
        public void Header1_NewlineBefore_Valid()
        {
            string source = "\n# Header1";

            var expected = new TokenListBuilder()
                .Newline(0, 0)
                    .Header1(1, 0)
                    .String(1, 2, "Header1");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 8
0
        public void NestedOneLine()
        {
            string source = @">> something quoted";

            var expected = new TokenListBuilder()
                .Blockquote(0, 0)
                    .Blockquote(0, 1)
                    .String(0, 3, "something quoted");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 9
0
        public void EndText_OneLink_Http()
        {
            string source = @"This is a text with [a link](http://domain.tld/folder/file.ext)";

            var expected = new TokenListBuilder()
                .String(0, 0, "This is a text with ")
                    .LinkLabel(0, 20, "a link")
                    .LinkUrl(0, 28, "http://domain.tld/folder/file.ext");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 10
0
        public void Header2_NewlineAfter_Valid()
        {
            string source = @"## Header2
            ";

            var expected = new TokenListBuilder()
                .Header2(0, 0)
                    .String(0, 3, "Header2")
                    .Newline(0, 10);

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 11
0
        public void Empty_WithLang()
        {
            string source = @"```javascript
            ```";

            var expected = new TokenListBuilder()
                .CodeOpen(0, 0, "javascript")
                    .Newline(0, 13)
                    .CodeClose(1, 0);

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 12
0
        public void MultipleLines()
        {
            string source = @"I am amazing.
            And everyone knows it :)";

            var expected = new TokenListBuilder()
                .String(0, 0, "I am amazing.")
                    .Newline(0, 13)
                    .String(1, 0, "And everyone knows it :)");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 13
0
        public void Emphasis_EndText()
        {
            string source = @"He looks _strong_";

            var expected = new TokenListBuilder()
                .String(0, 0, "He looks ")
                    .Emphasis(0, 9)
                    .String(0, 10, "strong")
                    .Emphasis(0, 16);

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 14
0
        public void Emphasis_StartText()
        {
            string source = @"_Strong_ words, sir.";

            var expected = new TokenListBuilder()
                .Emphasis(0, 0)
                    .String(0, 1, "Strong")
                    .Emphasis(0, 7)
                    .String(0, 8, " words, sir.");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 15
0
        public void MultipleLines()
        {
            string source = @"> something quoted
            > second line";

            var expected = new TokenListBuilder()
                .Blockquote(0, 0)
                    .String(0, 2, "something quoted")
                    .Newline(0, 18)
                    .Blockquote(1, 0)
                    .String(1, 2, "second line");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 16
0
        public void Mixed_MidText()
        {
            string source = @"He looks *_strong_* tonight.";

            var expected = 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.");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 17
0
        public void Mixed_ThreeItems()
        {
            string source = @"- Item 1
            * Item 2
            + Item 3";

            var expected = 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");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 18
0
        public void ThreeItems()
        {
            string source = @"1. Item 1
            2. Item 2
            3. Item 3";

            var expected = new TokenListBuilder()
                .OrderedList(0, 0)
                    .String(0, 3, "Item 1")
                    .Newline(0, 9)
                    .OrderedList(1, 0)
                    .String(1, 3, "Item 2")
                    .Newline(1, 9)
                    .OrderedList(2, 0)
                    .String(2, 3, "Item 3");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 19
0
        public void MixedNesting()
        {
            string source = @">> something quoted
            > more recent quote
            And this is now";

            var expected = new TokenListBuilder()
                .Blockquote(0, 0)
                    .Blockquote(0, 1)
                    .String(0, 3, "something quoted")
                    .Newline(0, 19)
                    .Blockquote(1, 0)
                    .String(1, 2, "more recent quote")
                    .Newline(1, 19)
                    .String(2, 0, "And this is now");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
        public void ThreeLines_NewlineAfter_Valid()
        {
            string source = @"Header1
            =======
            ";
            var expected = new TokenListBuilder()
                .String(0, 0, "Header1")
                    .Newline(0, 7)
                    .StrongLine(1, 0)
                    .StrongLine(1, 1)
                    .StrongLine(1, 2)
                    .StrongLine(1, 3)
                    .StrongLine(1, 4)
                    .StrongLine(1, 5)
                    .StrongLine(1, 6)
                    .Newline(1, 7);

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
        public void ThreeLines_NewlineBefore_Valid()
        {
            string source = @"
            Header2
            -------";
            var expected = new TokenListBuilder()
                .Newline(0, 0)
                    .String(1, 0, "Header2")
                    .Newline(1, 7)
                    .Line(2, 0)
                    .Line(2, 1)
                    .Line(2, 2)
                    .Line(2, 3)
                    .Line(2, 4)
                    .Line(2, 5)
                    .Line(2, 6);

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 22
0
        public void JsLoop_NoLang()
        {
            string source = @"```
            for (var i=0; i<10; i++) {
            // do something
            }
            ```";

            var expected = 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);

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 23
0
        public void NonFormattingUse()
        {
            string source = @"He is a real * in this community.
            Words_With_Underscore.
            An _ in the middle of everything.
            Strange*Use of a star.";

            var expected = new TokenListBuilder()
                .String(0, 0, "He is a real * in this community.")
                    .Newline(0, 33)
                    .String(1, 0, "Words_With_Underscore.")
                    .Newline(1, 22)
                    .String(2, 0, "An _ in the middle of everything.")
                    .Newline(2, 33)
                    .String(3, 0, "Strange*Use of a star.");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 24
0
        public void TwoLines_NoText()
        {
            string source = @">
            >";

            var expected = new TokenListBuilder()
                .Blockquote(0, 0)
                    .Newline(0, 1)
                    .Blockquote(1, 0);

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 25
0
        public void Strong_MidText()
        {
            string source = @"He looks *strong* tonight.";

            var expected = new TokenListBuilder()
                .String(0, 0, "He looks ")
                    .Strong(0, 9)
                    .String(0, 10, "strong")
                    .Strong(0, 16)
                    .String(0, 17, " tonight.");

            Tokenizer nizer = new Tokenizer();
            List<Token> actual = nizer.Tokenize(source);

            CollectionAssert.AreEqual(expected.List, actual);
        }
Exemplo n.º 26
0
        public void TooManyHashes()
        {
            string source = @"#### Header";

            Tokenizer nizer = new Tokenizer();

            try
            {
                nizer.Tokenize(source);

                Assert.Fail("A syntax exception should have been thrown");
            }

            catch (SyntaxException)
            {
                // hephey
            }
        }