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
        void EmbedTable()
        {
            EmbedTableCommand = new CommandBase((parameter, command) =>
            {
                Window.TableData = Window.Interop.GetJsonTableData();

                var parser = new TableParserHtml();

                if (Window.TableMode == "Grid Table")
                {
                    Window.TableHtml = parser.ToGridTableMarkdown(Window.TableData);
                }
                else if (Window.TableMode == "HTML Table")
                {
                    Window.TableHtml = parser.ToTableHtml(Window.TableData);
                }
                else
                {
                    Window.TableHtml = parser.ToPipeTableMarkdown(Window.TableData);
                }


                mmApp.Model.ActiveEditor.SetSelectionAndFocus(Window.TableHtml);
                Window.Close();
            }, (p, c) => true);
        }
Ejemplo n.º 4
0
        public void DataToMarkdownGridTableMultiLineTest()
        {
            var data = GetTableMultiLineData();

            var    parser = new TableParserHtml();
            string html   = parser.ToGridTableMarkdown(data);

            Console.WriteLine(html);

            Assert.IsTrue(html.Contains("| Row 8 Column 1  |"));
        }
Ejemplo n.º 5
0
        public void CsvTableParserFromStringTest()
        {
            string data = @"Name,Company,city,Test

Rick,West Wind,Paia,4
Markus,EPS,Kihei,20,11
Kevin,Oak Leaf,Bumstuck VA,4
";

            var parser    = new TableParserHtml();
            var tableData = parser.ParseCsvStringToData(data, ",");

            Console.WriteLine(parser.ToGridTableMarkdown(tableData));
        }
Ejemplo n.º 6
0
        public void SimpleHtmlTableToData()
        {
            string html = @"
        <table>
        <thead>
        <tr>
            <th>Column1</th>
            <th>Column2</th>
            <th>Column3</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>Column1 Row 1</td>
            <td>Column2 Row 1</td>
            <td>Column3 Row 1</td>
        </tr>
        <tr>
            <td>Column1 Row 2</td>
            <td>Column2 Row 2</td>
            <td>Column3 Row 2</td>
        </tr>
        <tr>
            <td>Column1 Row 3</td>
            <td>Column2 Row 3</td>
            <td>Column3 Row 3</td>
        </tr>
        </tbody>
        </html>
        ";

            var parser = new TableParserHtml();
            var data   = parser.ParseHtmlToData(html);

            Assert.IsNotNull(data);

            Console.WriteLine(data.Rows.Count + " Rows Parsed:");
            Console.WriteLine(parser.ToGridTableMarkdown(data));
        }
Ejemplo n.º 7
0
        public void SimpleHtmlTableWithBasicMarkupToData()
        {
            string html = @"
        <table>
        <tr>
            <th>Column1</th>
            <th>Column2</th>
            <th>Column3</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>Column1 Row 1</td>
            <td>Column2 Row 1</td>
            <td>Column3 Row 1</td>
        </tr>
        <tr>
            <td><img src=""https://markdownmonster.west-wind.com/Images/MarkdownMonster_Icon_32.png"" />Column1 <b>RowBold</b></td>
            <td><a href=""https://west-wind.com"">Column2</a> <a href=""http://google.com"">Row 2</a></td>
            <td>Column3 Row 2</td>
        </tr>
        <tr>
            <td>Column1 Row 3</td>
            <td>Column2 Row 3</td>
            <td>Column3 Row 3</td>
        </tr>
        </table>
        ";

            var parser = new TableParserHtml();
            var data   = parser.ParseHtmlToData(html);

            Assert.IsNotNull(data);

            Console.WriteLine(data.Rows.Count + " Rows Parsed:");
            Console.WriteLine(parser.ToGridTableMarkdown(data));
        }
Ejemplo n.º 8
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**"));
        }