Ejemplo n.º 1
0
        public void ParseUnbalancedMarkdownGridTableToDataTest()
        {
            string md = @"
        +------------------------------------------+----------------+------------+
        | Header 1                                 | Header 2       |
        +==========================================+================+============+
        | Column 1                                 | Column 2 Text  | Column 3   |
        +------------------------------------------+----------------+------------+
        | Column 4                                 | Column 5 Text  | 
        | and a bottle of Russian rum              |                |            
        | with broken glass                        |                |           
        +------------------------------------------+----------------+------------+
        | Column 6                                 | Column 7 Text  | Column 8   |
        +------------------------------------------+----------------+------------+
        | Column 9                                 | Column 10 Text | Column 11  |
        | ho ho and a bottle of rum                |                |            |
        +------------------------------------------+----------------+------------+
        ";

            var parser = new TableParserHtml();
            var data   = parser.ParseMarkdownToData(md);

            Console.WriteLine(data.Rows.Count);
            Console.WriteLine(parser.ToGridTableMarkdown(data));

            Assert.IsTrue(data.Rows.Count == 4, "Table should have returned 4 rows");

            Assert.IsTrue(data.Headers[0] == "Header 1");                             // header filled
            Assert.IsTrue(data.Rows[1][1] == "Column 5 Text", data.Rows[1][1] + "!"); // 2nd row filled

            Assert.IsTrue(data.Rows[1][0].Contains("\nand a bottle of"));
        }
Ejemplo n.º 2
0
        public void ParseMarkdownGridTableToDataTest()
        {
            string md = @"
    +------------------------------------------+----------------+------------+
    | Header 1                                 | Header 2       | Header 3   |
    +==========================================+================+============+
    | Column 1                                 | Column 2 Text  | Column 3   |
    +------------------------------------------+----------------+------------+
    | Column 1 Row 2                           | Column 5 Text  | Column 5.5 |
    | and a bottle of Russian rum              |                |            |
    | with broken glass                        |                |            |
    +------------------------------------------+----------------+------------+
    | Column 6                                 | Column 7 Text  | Column 8   |
    +------------------------------------------+----------------+------------+
    | Column 9                                 | Column 10 Text | Column 11  |
    | ho ho and a bottle of rum                |                |            |
    +------------------------------------------+----------------+------------+
        ";

            var parser = new TableParserHtml();
            var data   = parser.ParseMarkdownToData(md);

            Console.WriteLine(data.Rows.Count + " Rows Parsed:");
            Console.WriteLine(parser.ToGridTableMarkdown(data));

            Assert.IsTrue(data.Rows.Count == 4, "Table should have returned 4 rows");
            Assert.IsTrue(data.Rows[1][0].Contains("\nand a bottle of"));
        }
Ejemplo n.º 3
0
        public void UnbalancedPipeTableParsingTest()
        {
            var md = @"| Header 1 | Header 2 |
        |------------|------------|------------|
        | Column 1   | Column 2   | More Stuff |
        | Column 1.1 | Column 2.1 | More Stuff |";


            var parser = new TableParserHtml();
            var data   = parser.ParseMarkdownToData(md);

            Console.WriteLine(data.Rows.Count);
            Console.WriteLine(parser.ToPipeTableMarkdown(data));

            Assert.IsTrue(data.Rows.Count == 2, "Table should have returned 2 rows");
            Assert.IsTrue(data.Rows[0][1] == "Column 2");
        }
Ejemplo n.º 4
0
        public void ParseMarkdownPipeTableToDataTest2()
        {
            string md = @"
        a  | b 
        --|--
        0  | 1 
        3  | 4
        ";

            var parser = new TableParserHtml();
            var data   = parser.ParseMarkdownToData(md);

            Console.WriteLine(data.Rows.Count);
            Console.WriteLine(parser.ToPipeTableMarkdown(data));

            Assert.IsTrue(data.Rows.Count == 2, "Table should have returned 2 rows");
            Assert.IsTrue(data.Rows[0][1] == "1");
        }
Ejemplo n.º 5
0
        public void ParseMarkdownPipeTableToDataTest()
        {
            string md = @"
        | Header1              | Header 2 | Header 3 |
        |--------------------:|----------|----------|
        | column 1             | Column 2 | Column 3 |
        | Custom Table Content | Column 5 | Column 6 |
        | Column 7             | Column 8 | Column 9 |
        ";

            var parser = new TableParserHtml();
            var data   = parser.ParseMarkdownToData(md);

            Console.WriteLine(data.Rows.Count);
            Console.WriteLine(parser.ToPipeTableMarkdown(data));

            Assert.IsTrue(data.Rows.Count == 3, "Table should have returned 3 rows");
            Assert.IsTrue(data.Rows[0][1] == "Column 2");
        }
Ejemplo n.º 6
0
        public void ExtraUnbalancedPipeTableParsingTest()
        {
            var md = @"| Header 1 | Header 2 |
        |------------|------------|------------|
        | Column 1   | Column 2   |
        | Column 1.1 | Column 2.1 | More Stuff | Even More Stuff |";

            Console.WriteLine($"Original: \n{md}\n\n");

            var parser = new TableParserHtml();
            var data   = parser.ParseMarkdownToData(md);

            Console.WriteLine(data.Rows.Count + " Rows Parsed:");
            Console.WriteLine(parser.ToPipeTableMarkdown(data));

            Assert.IsTrue(data.Rows.Count == 2, "Table should have returned 2 rows");
            Assert.IsTrue(string.IsNullOrWhiteSpace(data.Rows[0][2]));  // header
            Assert.IsTrue(!string.IsNullOrWhiteSpace(data.Rows[1][2]));
            Assert.IsTrue(data.Rows[0][1] == "Column 2");
            Assert.IsTrue(data.Rows[1][2] == "More Stuff");
        }
Ejemplo n.º 7
0
        public void ParseComplexMarkdownGridTableToDataTest()
        {
            var md = @"
        +-----------------------------------+-----------------------------------+
        | Attribute                         | Function                          |
        +===================================+===================================+
        | **display: flex**                 | Top level attribute that enables  |
        |                                   | Flexbox formatting on the         |
        |                                   | container it is applied to.       |
        |                                   |                                   |
        |                                   | **display:flex**                  |
        +-----------------------------------+-----------------------------------+
        | **flex-direction**                | Determines horizontal (row) or    |
        |                                   | vertical (column) flow direction  |
        |                                   | elements in the container.        |
        |                                   |                                   |
        |                                   | **row,column**                    |
        +-----------------------------------+-----------------------------------+
        | **flex-wrap**                     | Determines how content wraps when |
        |                                   | the content overflows the         |
        |                                   | container.                        |
        |                                   |                                   |
        |                                   | **wrap, nowrap, wrap-reverse**    |
        +-----------------------------------+-----------------------------------+
        | **flex-flow**                     | Combination of flex-direction and |
        |                                   | flex-wrap as a single attribute.  |
        |                                   |                                   |
        |                                   | **flex-flow: row nowrap**         |
        +-----------------------------------+-----------------------------------+
        | **justify-content**               | Aligns content along the flex     |
        |                                   | flow direction.                   |
        |                                   |                                   |
        |                                   | **flex-start, flex-end, center,   |
        |                                   | space-between, space-around**     |
        +-----------------------------------+-----------------------------------+
        | **align-items**                   | Like align-content but aligns     |
        |                                   | content along the perpendicular   |
        |                                   | axis.                             |
        |                                   |                                   |
        |                                   | **flex-start, flex-end, center,   |
        |                                   | stretch, baseline**               |
        +-----------------------------------+-----------------------------------+
        | **align-content**                 | Aligns multi-line content so that |
        |                                   | multiple lines of content line up |
        |                                   | when wrapping.                    |
        |                                   |                                   |
        |                                   | **flex-start, flex-end, center,   |
        |                                   | space-between, space-around,      |
        |                                   | stretch**                         |
        +-----------------------------------+-----------------------------------+
        ";

            var parser = new TableParserHtml();
            var data   = parser.ParseMarkdownToData(md);

            Console.WriteLine(data.Rows.Count + " Rows Parsed:");
            Console.WriteLine(parser.ToGridTableMarkdown(data));

            Assert.IsTrue(data.Rows.Count == 7, "Table should have returned 7 rows");
            Assert.IsTrue(data.Rows[1][0].Contains("**flex-direction**"));
        }