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); }
public void DataToMarkdownPipeTableMultiLineTest() { var data = GetTableMultiLineData(); var parser = new TableParserHtml(); string html = parser.ToPipeTableMarkdown(data); Console.WriteLine(html); Assert.IsTrue(html.Contains("| Row 8 Column 1 |")); }
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"); }
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"); }
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"); }
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"); }