Exemplo n.º 1
0
        public void Parse_BuildCorrectTree_WithBoldTag()
        {
            const string text   = "bar";
            var          tokens = new[]
            {
                new Token(0, Bold.Representation, TokenType.OpeningTag, Bold),
                new Token(2, text, TokenType.Text),
                new Token(5, Bold.Representation, TokenType.ClosingTag, Bold)
            };
            var expected = new MarkdownBoldElement(Bold.Representation);

            expected.ChildNodes.Add(new Text(text));

            TestParsing(tokens, expected);
        }
Exemplo n.º 2
0
        public void Parse_BuildCorrectTree_WhenItalicIsEmbeddedInBoldTag()
        {
            const string text   = "baz";
            var          tokens = new[]
            {
                new Token(0, Bold.Representation, TokenType.OpeningTag, Bold),
                new Token(2, Italic.Representation, TokenType.OpeningTag, Italic),
                new Token(3, text, TokenType.Text),
                new Token(6, Italic.Representation, TokenType.ClosingTag, Italic),
                new Token(7, Bold.Representation, TokenType.ClosingTag, Bold)
            };
            var italic = new MarkdownItalicElement(Italic.Representation);

            italic.ChildNodes.Add(new Text(text));
            var expected = new MarkdownBoldElement(Bold.Representation);

            expected.ChildNodes.Add(italic);

            TestParsing(tokens, expected);
        }
Exemplo n.º 3
0
        public void Parse_BuildCorrectTree_WhenTagsIntersect()
        {
            var tokens = new[]
            {
                new Token(0, Bold.Representation, TokenType.OpeningTag, Bold),
                new Token(2, "foo", TokenType.Text),
                new Token(5, Italic.Representation, TokenType.OpeningTag, Italic),
                new Token(6, "bar", TokenType.Text),
                new Token(9, Bold.Representation, TokenType.ClosingTag, Bold),
                new Token(11, "baz", TokenType.Text),
                new Token(14, Italic.Representation, TokenType.ClosingTag, Italic)
            };
            var boldElement = new MarkdownBoldElement(Bold.Representation);

            boldElement.ChildNodes.Add(new Text("foo"));
            boldElement.ChildNodes.Add(new Text(Italic.Representation));
            boldElement.ChildNodes.Add(new Text("bar"));
            var expected = new INode[] { boldElement, new Text("baz"), new Text(Italic.Representation) };

            TestParsing(tokens, expected);
        }