From cd5bb2d16c6b28332b0b6077b27b2b90a8051896 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 6 Oct 2022 15:57:55 +0200 Subject: Refactor to split parse from compile options --- tests/gfm_table.rs | 102 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 72 insertions(+), 30 deletions(-) (limited to 'tests/gfm_table.rs') diff --git a/tests/gfm_table.rs b/tests/gfm_table.rs index d6bd022..1f0b93c 100644 --- a/tests/gfm_table.rs +++ b/tests/gfm_table.rs @@ -3,14 +3,17 @@ use micromark::{ mdast::{AlignKind, InlineCode, Node, Root, Table, TableCell, TableRow, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn gfm_table() -> Result<(), String> { let gfm = Options { - constructs: Constructs::gfm(), + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -202,12 +205,15 @@ fn gfm_table() -> Result<(), String> { assert_eq!( micromark_with_options("| a |\n | - |", &Options { - constructs: Constructs { - code_indented: false, - ..Constructs::gfm() - }, - ..Options::default() - })?, + parse: ParseOptions { + constructs: Constructs { + code_indented: false, + ..Constructs::gfm() + }, + ..ParseOptions::default() + }, + ..Options::default() + })?, "\n\n\n\n\n\n
a
", "should form a table if the delimiter row is indented w/ 4 spaces and indented code is turned off" ); @@ -240,9 +246,15 @@ fn gfm_table() -> Result<(), String> { micromark_with_options( "| a |\n| - |\n", &Options { - allow_dangerous_html: true, - constructs: Constructs::gfm(), - ..Options::default() + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + } } )?, "\n\n\n\n\n\n
a
\n", @@ -251,20 +263,32 @@ fn gfm_table() -> Result<(), String> { assert_eq!( micromark_with_options("| a |\n| - |\n\tcode?", &Options { - allow_dangerous_html: true, - constructs: Constructs::gfm(), - ..Options::default() - })?, + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + } + })?, "\n\n\n\n\n\n
a
\n
code?\n
", "should be interrupted by code (indented)" ); assert_eq!( micromark_with_options("| a |\n| - |\n```js\ncode?", &Options { - allow_dangerous_html: true, - constructs: Constructs::gfm(), - ..Options::default() - })?, + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + } + })?, "\n\n\n\n\n\n
a
\n
code?\n
\n", "should be interrupted by code (fenced)" ); @@ -273,9 +297,15 @@ fn gfm_table() -> Result<(), String> { micromark_with_options( "| a |\n| - |\n***", &Options { - allow_dangerous_html: true, - constructs: Constructs::gfm(), - ..Options::default() + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + } } )?, "\n\n\n\n\n\n
a
\n
", @@ -1041,9 +1071,15 @@ bar `\|\\` "###, &Options { - allow_dangerous_html: true, - constructs: Constructs::gfm(), - ..Options::default() + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + } } )?, r###"

Grave accents

@@ -1350,9 +1386,15 @@ b *** "###, &Options { - allow_dangerous_html: true, - constructs: Constructs::gfm(), - ..Options::default() + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + } } )?, r###"

Blank line

@@ -1792,7 +1834,7 @@ normal escape: https:// assert_eq!( micromark_to_mdast( "| none | left | right | center |\n| - | :- | -: | :-: |\n| a |\n| b | c | d | e | f |", - &gfm + &gfm.parse )?, Node::Root(Root { children: vec![Node::Table(Table { @@ -1895,7 +1937,7 @@ normal escape: https:// ); assert_eq!( - micromark_to_mdast("| `a\\|b` |\n| - |", &gfm)?, + micromark_to_mdast("| `a\\|b` |\n| - |", &gfm.parse)?, Node::Root(Root { children: vec![Node::Table(Table { align: vec![AlignKind::None,], -- cgit