diff --git a/packages/table/src/example.json b/packages/table/src/example.json deleted file mode 100644 index 62f5cc1b..00000000 --- a/packages/table/src/example.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "table", - "arguments": {}, - "data": "10 | **bold text** | silly \n second | row | here \n", - "inline": false -} diff --git a/packages/table/src/main.rs b/packages/table/src/main.rs index 83c9b377..7f566e23 100644 --- a/packages/table/src/main.rs +++ b/packages/table/src/main.rs @@ -240,6 +240,7 @@ impl TryFrom<&str> for Borders { // The struct holding a table. Since the text contained within holds pointers to stdin, we need // lifetimes to avoid copying #[derive(Debug)] +#[allow(dead_code)] struct Table<'a> { width: usize, height: usize, @@ -255,6 +256,8 @@ impl Table<'_> { let mut vec: Vec = vec![]; let col_key = if self.width == 0 { + // If we have an empty table, we need some alignment still since otherwise + // we get an latex error "|l|".to_string() } else if self.borders == Borders::All || self.borders == Borders::Vertical { self.alignment.latex_str(self.width, true) @@ -267,11 +270,14 @@ impl Table<'_> { vec.push(raw!("\\begin{center}\n")); vec.push(raw!(format!("\\begin{{tabular}} {{ {} }}\n", col_key))); + // Only "None" borders should not have top row if self.borders != Borders::None { vec.push(raw!("\\hline\n")); } + // Loop though all rows for (idx, row) in self.content.iter().enumerate() { + // Collect all inline_content values, if heading add bold tags ** let values = if idx == 0 && self.header { row.iter() .map(|c| format!("**{c}**")) @@ -283,6 +289,7 @@ impl Table<'_> { .collect::>() }; + // For each cell in the row, push it and add & between, and \\\n to the end for (idx, val) in values.into_iter().enumerate() { if idx != 0 { vec.push(raw!(" & ")); @@ -291,13 +298,16 @@ impl Table<'_> { } vec.push(raw!(" \\\\\n")); + // If we should have a border in-between all rows, add it if self.borders == Borders::All || self.borders == Borders::Horizontal { vec.push(raw!("\\hline\n")); } } - if self.borders == Borders::Outer { - vec.push(raw!(r"\hline")) + // Both horizontal and all already added this line, so it only needs to be + // added on outer and vertical + if self.borders == Borders::Outer || self.borders == Borders::Vertical { + vec.push(raw!("\\hline\n")) } vec.push(raw!("\\end{tabular}\n")); vec.push(raw!(r"\end{center}")); @@ -307,27 +317,31 @@ impl Table<'_> { // Turns this table to HTML and gets a JSON value (containing mostly raw stuff) to return fn to_html(&self) -> Value { let mut vec: Vec = vec![]; + // Push opening tag, border style on table if outer borders if self.borders == Borders::None { vec.push(raw!("")); } else { vec.push(raw!( - r#"
"# )); } + // Here is the style for all th/td elements let inside_border_style = if self.borders == Borders::All { - "border: 1px solid black; border-collapse: collapse;" + " border: 1px solid black; border-collapse: collapse;" } else if self.borders == Borders::Vertical { - "border-left: 1px solid black; border-right: 1px solid black; border-collapse: collapse;" + " border-left: 1px solid black; border-right: 1px solid black; border-collapse: collapse;" } else if self.borders == Borders::Horizontal { - "border-top: 1px solid black; border-bottom: 1px solid black; border-collapse: collapse;" + " border-top: 1px solid black; border-bottom: 1px solid black; border-collapse: collapse;" } else { "" }; + // Loop though each row for (idx, row) in self.content.iter().enumerate() { vec.push(raw!("")); + // If it is the header, use th, else use td if idx == 0 && self.header { for (idx, elem) in row.iter().enumerate() { let alignment = self.alignment.for_column(idx).html_style(); @@ -357,6 +371,7 @@ impl Table<'_> { } // Parses the JSON input to a table, if possible. Warnings/errors are printed out when running this. +// Many of the arguments uses try_into() to optionally get a Border, Alignment etc fn parse_table(input: &Value) -> Option
{ let delimiter = input["arguments"]["delimiter"].as_str().unwrap(); if delimiter.contains('\\') { diff --git a/packages/table/tests/test_all_border_html.json b/packages/table/tests/test_all_border_html.json new file mode 100644 index 00000000..8d50f649 --- /dev/null +++ b/packages/table/tests/test_all_border_html.json @@ -0,0 +1,87 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "left", + "borders": "all", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "html", + "__test_expected_result": [ + { + "data": "
", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_all_border_latex.json b/packages/table/tests/test_all_border_latex.json new file mode 100644 index 00000000..e1c3483b --- /dev/null +++ b/packages/table/tests/test_all_border_latex.json @@ -0,0 +1,75 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "left", + "borders": "all", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "latex", + "__test_expected_result": [ + { + "data": "\\begin{center}\n", + "name": "raw" + }, + { + "data": "\\begin{tabular} { |l|l| }\n", + "name": "raw" + }, + { + "data": "\\hline\n", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "\\hline\n", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "\\hline\n", + "name": "raw" + }, + { + "data": "\\end{tabular}\n", + "name": "raw" + }, + { + "data": "\\end{center}", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_heading_html.json b/packages/table/tests/test_heading_html.json new file mode 100644 index 00000000..a8d929b1 --- /dev/null +++ b/packages/table/tests/test_heading_html.json @@ -0,0 +1,87 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "bold", + "alignment": "left", + "borders": "none", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "html", + "__test_expected_result": [ + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_heading_latex.json b/packages/table/tests/test_heading_latex.json new file mode 100644 index 00000000..c7e684e7 --- /dev/null +++ b/packages/table/tests/test_heading_latex.json @@ -0,0 +1,63 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "bold", + "alignment": "left", + "borders": "none", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "latex", + "__test_expected_result": [ + { + "data": "\\begin{center}\n", + "name": "raw" + }, + { + "data": "\\begin{tabular} { ll }\n", + "name": "raw" + }, + { + "data": "**a**", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "**b**", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "\\end{tabular}\n", + "name": "raw" + }, + { + "data": "\\end{center}", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_horizontal_border_html.json b/packages/table/tests/test_horizontal_border_html.json new file mode 100644 index 00000000..8d8ae0f0 --- /dev/null +++ b/packages/table/tests/test_horizontal_border_html.json @@ -0,0 +1,87 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "left", + "borders": "horizontal", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "html", + "__test_expected_result": [ + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_horizontal_border_latex.json b/packages/table/tests/test_horizontal_border_latex.json new file mode 100644 index 00000000..1c2453e6 --- /dev/null +++ b/packages/table/tests/test_horizontal_border_latex.json @@ -0,0 +1,75 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "left", + "borders": "horizontal", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "latex", + "__test_expected_result": [ + { + "data": "\\begin{center}\n", + "name": "raw" + }, + { + "data": "\\begin{tabular} { |ll| }\n", + "name": "raw" + }, + { + "data": "\\hline\n", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "\\hline\n", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "\\hline\n", + "name": "raw" + }, + { + "data": "\\end{tabular}\n", + "name": "raw" + }, + { + "data": "\\end{center}", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_mixed_alignment_html.json b/packages/table/tests/test_mixed_alignment_html.json new file mode 100644 index 00000000..2295a1c1 --- /dev/null +++ b/packages/table/tests/test_mixed_alignment_html.json @@ -0,0 +1,87 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "rc", + "borders": "none", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "html", + "__test_expected_result": [ + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_mixed_alignment_latex.json b/packages/table/tests/test_mixed_alignment_latex.json new file mode 100644 index 00000000..21500584 --- /dev/null +++ b/packages/table/tests/test_mixed_alignment_latex.json @@ -0,0 +1,63 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "rc", + "borders": "none", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "latex", + "__test_expected_result": [ + { + "data": "\\begin{center}\n", + "name": "raw" + }, + { + "data": "\\begin{tabular} { rc }\n", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "\\end{tabular}\n", + "name": "raw" + }, + { + "data": "\\end{center}", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_no_strip.json b/packages/table/tests/test_no_strip.json new file mode 100644 index 00000000..ece522e4 --- /dev/null +++ b/packages/table/tests/test_no_strip.json @@ -0,0 +1,87 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "left", + "borders": "none", + "strip_whitespace": "false" + }, + "data": "a | b \nc|d", + "inline": false, + "__test_transform_to": "html", + "__test_expected_result": [ + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "a ", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": " b ", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_outer_border_html.json b/packages/table/tests/test_outer_border_html.json new file mode 100644 index 00000000..14df4c48 --- /dev/null +++ b/packages/table/tests/test_outer_border_html.json @@ -0,0 +1,87 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "left", + "borders": "outer", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "html", + "__test_expected_result": [ + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_outer_border_latex.json b/packages/table/tests/test_outer_border_latex.json new file mode 100644 index 00000000..4c3472a7 --- /dev/null +++ b/packages/table/tests/test_outer_border_latex.json @@ -0,0 +1,71 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "left", + "borders": "outer", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "latex", + "__test_expected_result": [ + { + "data": "\\begin{center}\n", + "name": "raw" + }, + { + "data": "\\begin{tabular} { |ll| }\n", + "name": "raw" + }, + { + "data": "\\hline\n", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "\\hline\n", + "name": "raw" + }, + { + "data": "\\end{tabular}\n", + "name": "raw" + }, + { + "data": "\\end{center}", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_right_alignment_html.json b/packages/table/tests/test_right_alignment_html.json new file mode 100644 index 00000000..f150cec2 --- /dev/null +++ b/packages/table/tests/test_right_alignment_html.json @@ -0,0 +1,87 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "right", + "borders": "none", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "html", + "__test_expected_result": [ + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_right_alignment_latex.json b/packages/table/tests/test_right_alignment_latex.json new file mode 100644 index 00000000..5191176b --- /dev/null +++ b/packages/table/tests/test_right_alignment_latex.json @@ -0,0 +1,63 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "right", + "borders": "none", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "latex", + "__test_expected_result": [ + { + "data": "\\begin{center}\n", + "name": "raw" + }, + { + "data": "\\begin{tabular} { rr }\n", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "\\end{tabular}\n", + "name": "raw" + }, + { + "data": "\\end{center}", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_strip.json b/packages/table/tests/test_strip.json new file mode 100644 index 00000000..67a60fab --- /dev/null +++ b/packages/table/tests/test_strip.json @@ -0,0 +1,87 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "left", + "borders": "none", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "html", + "__test_expected_result": [ + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_vertical_border_html.json b/packages/table/tests/test_vertical_border_html.json new file mode 100644 index 00000000..145e7eeb --- /dev/null +++ b/packages/table/tests/test_vertical_border_html.json @@ -0,0 +1,87 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "left", + "borders": "vertical", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "html", + "__test_expected_result": [ + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": "", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": "
", + "name": "raw" + } + ] +} diff --git a/packages/table/tests/test_vertical_border_latex.json b/packages/table/tests/test_vertical_border_latex.json new file mode 100644 index 00000000..d9e98c9e --- /dev/null +++ b/packages/table/tests/test_vertical_border_latex.json @@ -0,0 +1,71 @@ +{ + "name": "table", + "arguments": { + "delimiter": "|", + "header": "none", + "alignment": "left", + "borders": "vertical", + "strip_whitespace": "true" + }, + "data": "a | b \n c|d", + "inline": false, + "__test_transform_to": "latex", + "__test_expected_result": [ + { + "data": "\\begin{center}\n", + "name": "raw" + }, + { + "data": "\\begin{tabular} { |l|l| }\n", + "name": "raw" + }, + { + "data": "\\hline\n", + "name": "raw" + }, + { + "data": "a", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "b", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "c", + "name": "inline_content" + }, + { + "data": " & ", + "name": "raw" + }, + { + "data": "d", + "name": "inline_content" + }, + { + "data": " \\\\\n", + "name": "raw" + }, + { + "data": "\\hline\n", + "name": "raw" + }, + { + "data": "\\end{tabular}\n", + "name": "raw" + }, + { + "data": "\\end{center}", + "name": "raw" + } + ] +}