use super::*; #[test] fn table() { html_opts!( [extension.table], concat!("| a | b |\n", "|---|:-:|\n", "| c | d |\n"), concat!( "
| a | \n", "b | \n", "
|---|---|
| c | \n", "d | \n", "
123\n", "456
\n", "| a | \n", "b | \n", "
|---|---|
| d | \n", "e | \n", "
a\n-b
\n"); } #[test] fn table_misparse_2() { html_opts!([extension.table], "a\n-b\n-c", "a\n-b\n-c
\n"); } #[test] fn nested_tables_1() { html_opts!( [extension.table], concat!("- p\n", "\n", " |a|b|\n", " |-|-|\n", " |c|d|\n",), concat!( "p
\n", "| a | \n", "b | \n", "
|---|---|
| c | \n", "d | \n", "
| a | \n", "b | \n", "
|---|---|
| c | \n", "d | \n", "
\n", "\n", ), ); } #[test] fn sourcepos_with_preceding_para_no_spaces() { assert_ast_match!( [extension.table], "123\n" "456\n" "| a | b |\n" "| - | - |\n" "| c | d |\n" , (document (1:1-5:9) [ (paragraph (1:1-2:3) [ (text (1:1-1:3) "123") (softbreak (1:4-1:4)) (text (2:1-2:3) "456") ]) (table (3:1-5:9) [ (table_row (3:1-3:9) [ (table_cell (3:2-3:4) [ (text (3:3-3:3) "a") ]) (table_cell (3:6-3:8) [ (text (3:7-3:7) "b") ]) ]) (table_row (5:1-5:9) [ (table_cell (5:2-5:4) [ (text (5:3-5:3) "c") ]) (table_cell (5:6-5:8) [ (text (5:7-5:7) "d") ]) ]) ]) ]) ); } #[test] fn sourcepos_with_preceding_para_spaces_before_table() { assert_ast_match!( [extension.table], "123\n" "456\n" " | a | b |\n" " | - | - |\n" " | c | d |\n" , (document (1:1-5:10) [ (paragraph (1:1-2:3) [ (text (1:1-1:3) "123") (softbreak (1:4-1:4)) (text (2:1-2:3) "456") ]) (table (3:2-5:10) [ (table_row (3:2-3:10) [ (table_cell (3:3-3:5) [ (text (3:4-3:4) "a") ]) (table_cell (3:7-3:9) [ (text (3:8-3:8) "b") ]) ]) (table_row (5:2-5:10) [ (table_cell (5:3-5:5) [ (text (5:4-5:4) "c") ]) (table_cell (5:7-5:9) [ (text (5:8-5:8) "d") ]) ]) ]) ]) ); } #[test] fn sourcepos_with_preceding_para_spaces_before_para() { assert_ast_match!( [extension.table], " 123\n" " 456\n" "| a | b |\n" "| - | - |\n" "| c | d |\n" , (document (1:1-5:9) [ (paragraph (1:2-2:5) [ (text (1:2-1:4) "123") (softbreak (1:5-1:5)) (text (2:3-2:5) "456") ]) (table (3:1-5:9) [ (table_row (3:1-3:9) [ (table_cell (3:2-3:4) [ (text (3:3-3:3) "a") ]) (table_cell (3:6-3:8) [ (text (3:7-3:7) "b") ]) ]) (table_row (5:1-5:9) [ (table_cell (5:2-5:4) [ (text (5:3-5:3) "c") ]) (table_cell (5:6-5:8) [ (text (5:7-5:7) "d") ]) ]) ]) ]) ); } #[test] fn sourcepos_with_preceding_para_spaces_before_both() { assert_ast_match!( [extension.table], " 123\n" " 456\n" " | a | b |\n" " | - | - |\n" " | c | d |\n" , (document (1:1-5:10) [ (paragraph (1:2-2:5) [ (text (1:2-1:4) "123") (softbreak (1:5-1:5)) (text (2:3-2:5) "456") ]) (table (3:2-5:10) [ (table_row (3:2-3:10) [ (table_cell (3:3-3:5) [ (text (3:4-3:4) "a") ]) (table_cell (3:7-3:9) [ (text (3:8-3:8) "b") ]) ]) (table_row (5:2-5:10) [ (table_cell (5:3-5:5) [ (text (5:4-5:4) "c") ]) (table_cell (5:7-5:9) [ (text (5:8-5:8) "d") ]) ]) ]) ]) ); } #[test] fn table_crlf() { assert_ast_match!( [extension.table], "| a | b |\r\n" "| - | - |\r\n" "| c | d |\r\n" , (document (1:1-3:9) [ (table (1:1-3:9) [ (table_row (1:1-1:9) [ (table_cell (1:2-1:4) [ (text (1:3-1:3) "a") ]) (table_cell (1:6-1:8) [ (text (1:7-1:7) "b") ]) ]) (table_row (3:1-3:9) [ (table_cell (3:2-3:4) [ (text (3:3-3:3) "c") ]) (table_cell (3:6-3:8) [ (text (3:7-3:7) "d") ]) ]) ]) ]) ); } #[test] fn table_cr() { assert_ast_match!( [extension.table], "| a | b |\r" "| - | - |\r" "| c | d |\r" , (document (1:1-3:9) [ (table (1:1-3:9) [ (table_row (1:1-1:9) [ (table_cell (1:2-1:4) [ (text (1:3-1:3) "a") ]) (table_cell (1:6-1:8) [ (text (1:7-1:7) "b") ]) ]) (table_row (3:1-3:9) [ (table_cell (3:2-3:4) [ (text (3:3-3:3) "c") ]) (table_cell (3:6-3:8) [ (text (3:7-3:7) "d") ]) ]) ]) ]) ); } #[test] fn table_no_body_no_eol_at_eof() { assert_ast_match!( [extension.table], "| a |\n" "| - |" , (document (1:1-2:5) [ (table (1:1-2:5) [ (table_row (1:1-1:5) [ (table_cell (1:2-1:4) [ (text (1:3-1:3) "a") ]) ]) ]) ]) ); } #[test] fn table_with_trailing_para() { assert_ast_match!( [extension.table], "| a |\n" "| - |\n" "\n" "ok" , (document (1:1-4:2) [ (table (1:1-2:5) [ (table_row (1:1-1:5) [ (table_cell (1:2-1:4) [ (text (1:3-1:3) "a") ]) ]) ]) (paragraph (4:1-4:2) [ (text (4:1-4:2) "ok") ]) ]) ); } #[test] fn table_with_trailing_para_and_leading_whitespace() { assert_ast_match!( [extension.table], " | a |\n" " | - |\n" "\n" " ok" , (document (1:1-4:3) [ (table (1:3-2:7) [ (table_row (1:3-1:8) [ (table_cell (1:4-1:7) [ (text (1:5-1:5) "a") ]) ]) ]) (paragraph (4:2-4:3) [ (text (4:2-4:3) "ok") ]) ]) ); } #[test] fn table_missing_cell_sourcepos() { assert_ast_match!( [extension.table], "|a|b|\n" "|-|-|\n" "|c|\n" , (document (1:1-3:3) [ (table (1:1-3:3) [ (table_row (1:1-1:5) [ (table_cell (1:2-1:2) [ (text (1:2-1:2) "a") ]) (table_cell (1:4-1:4) [ (text (1:4-1:4) "b") ]) ]) (table_row (3:1-3:3) [ (table_cell (3:2-3:2) [ (text (3:2-3:2) "c") ]) (table_cell (3:3-3:3) ) ]) ]) ]) ); } #[test] fn table_missing_cell_with_text_sourcepos() { assert_ast_match!( [extension.table], "|a|b|\n" "|-|-|\n" "|c|d\n" , (document (1:1-3:4) [ (table (1:1-3:4) [ (table_row (1:1-1:5) [ (table_cell (1:2-1:2) [ (text (1:2-1:2) "a") ]) (table_cell (1:4-1:4) [ (text (1:4-1:4) "b") ]) ]) (table_row (3:1-3:4) [ (table_cell (3:2-3:2) [ (text (3:2-3:2) "c") ]) (table_cell (3:4-3:4) [ (text (3:4-3:4) "d") ]) ]) ]) ]) ); } #[test] fn table_missing_cells_sourcepos() { assert_ast_match!( [extension.table], "|a|b|c|\n" "|-|-|-|\n" "|d|\n" , (document (1:1-3:3) [ (table (1:1-3:3) [ (table_row (1:1-1:7) [ (table_cell (1:2-1:2) [ (text (1:2-1:2) "a") ]) (table_cell (1:4-1:4) [ (text (1:4-1:4) "b") ]) (table_cell (1:6-1:6) [ (text (1:6-1:6) "c") ]) ]) (table_row (3:1-3:3) [ (table_cell (3:2-3:2) [ (text (3:2-3:2) "d") ]) (table_cell (3:3-3:3) ) (table_cell (3:3-3:3) ) ]) ]) ]) ); }\n", "\n", "
\n", "\n", " \n", "\n", "\n", "a \n", "b \n", "\n", " \n", "\n", "c \n", "d \n", "