diff options
Diffstat (limited to '')
43 files changed, 627 insertions, 314 deletions
diff --git a/tests/attention.rs b/tests/attention.rs index abed33c..83e68d9 100644 --- a/tests/attention.rs +++ b/tests/attention.rs @@ -3,15 +3,18 @@ use micromark::{ mdast::{Emphasis, Node, Paragraph, Root, Strong, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn attention() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -821,9 +824,12 @@ fn attention() -> Result<(), String> { micromark_with_options( "*a*", &Options { - constructs: Constructs { - attention: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + attention: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -833,7 +839,7 @@ fn attention() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a *alpha* b **bravo** c.", &Options::default())?, + micromark_to_mdast("a *alpha* b **bravo** c.", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ diff --git a/tests/autolink.rs b/tests/autolink.rs index 78725b2..7ef3caa 100644 --- a/tests/autolink.rs +++ b/tests/autolink.rs @@ -3,15 +3,18 @@ use micromark::{ mdast::{Link, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn autolink() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -253,9 +256,12 @@ fn autolink() -> Result<(), String> { micromark_with_options( "<a@b.co>", &Options { - constructs: Constructs { - autolink: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + autolink: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -267,7 +273,7 @@ fn autolink() -> Result<(), String> { assert_eq!( micromark_to_mdast( "a <https://alpha.com> b <bravo@charlie.com> c.", - &Options::default() + &ParseOptions::default() )?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { diff --git a/tests/block_quote.rs b/tests/block_quote.rs index 6b155c5..12db252 100644 --- a/tests/block_quote.rs +++ b/tests/block_quote.rs @@ -3,7 +3,7 @@ use micromark::{ mdast::{BlockQuote, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; @@ -205,9 +205,12 @@ fn block_quote() -> Result<(), String> { micromark_with_options( "> # a\n> b\n> c", &Options { - constructs: Constructs { - block_quote: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + block_quote: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -217,7 +220,7 @@ fn block_quote() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("> a", &Options::default())?, + micromark_to_mdast("> a", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::BlockQuote(BlockQuote { children: vec![Node::Paragraph(Paragraph { diff --git a/tests/character_escape.rs b/tests/character_escape.rs index 44eff0b..54944aa 100644 --- a/tests/character_escape.rs +++ b/tests/character_escape.rs @@ -3,15 +3,18 @@ use micromark::{ mdast::{Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn character_escape() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -87,9 +90,12 @@ fn character_escape() -> Result<(), String> { micromark_with_options( "\\> a", &Options { - constructs: Constructs { - character_escape: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + character_escape: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -99,7 +105,7 @@ fn character_escape() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a \\* b", &Options::default())?, + micromark_to_mdast("a \\* b", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![Node::Text(Text { diff --git a/tests/character_reference.rs b/tests/character_reference.rs index ccf506e..1cc732e 100644 --- a/tests/character_reference.rs +++ b/tests/character_reference.rs @@ -3,7 +3,7 @@ use micromark::{ mdast::{Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; @@ -52,7 +52,11 @@ fn character_reference() -> Result<(), String> { micromark_with_options( "<a href=\"öö.html\">", &Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() } )?, @@ -197,9 +201,12 @@ fn character_reference() -> Result<(), String> { micromark_with_options( "&", &Options { - constructs: Constructs { - character_reference: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + character_reference: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -209,7 +216,7 @@ fn character_reference() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast(" & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸", &Options::default())?, + micromark_to_mdast(" & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![Node::Text(Text { diff --git a/tests/code_fenced.rs b/tests/code_fenced.rs index 06f0d6a..6da38a9 100644 --- a/tests/code_fenced.rs +++ b/tests/code_fenced.rs @@ -3,7 +3,7 @@ use micromark::{ mdast::{Code, Node, Root}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; @@ -266,9 +266,12 @@ fn code_fenced() -> Result<(), String> { micromark_with_options( "```", &Options { - constructs: Constructs { - code_fenced: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + code_fenced: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -280,7 +283,7 @@ fn code_fenced() -> Result<(), String> { assert_eq!( micromark_to_mdast( "```js extra\nconsole.log(1)\nconsole.log(2)\n```", - &Options::default() + &ParseOptions::default() )?, Node::Root(Root { children: vec![Node::Code(Code { @@ -295,7 +298,7 @@ fn code_fenced() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("```\nasd", &Options::default())?, + micromark_to_mdast("```\nasd", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Code(Code { lang: None, diff --git a/tests/code_indented.rs b/tests/code_indented.rs index 7ea08b5..fd539d3 100644 --- a/tests/code_indented.rs +++ b/tests/code_indented.rs @@ -3,7 +3,7 @@ use micromark::{ mdast::{Code, Node, Root}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; @@ -124,9 +124,12 @@ fn code_indented() -> Result<(), String> { ); let off = Options { - constructs: Constructs { - code_indented: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + code_indented: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() }; @@ -171,12 +174,17 @@ fn code_indented() -> Result<(), String> { micromark_with_options( "a <?\n ?>", &Options { - allow_dangerous_html: true, - constructs: Constructs { - code_indented: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + code_indented: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, - ..Options::default() + compile: CompileOptions { + allow_dangerous_html: true, + ..CompileOptions::default() + } } )?, "<p>a <?\n?></p>", @@ -198,7 +206,7 @@ fn code_indented() -> Result<(), String> { assert_eq!( micromark_to_mdast( "\tconsole.log(1)\n console.log(2)\n", - &Options::default() + &ParseOptions::default() )?, Node::Root(Root { children: vec![Node::Code(Code { diff --git a/tests/code_text.rs b/tests/code_text.rs index f6a3379..25882c8 100644 --- a/tests/code_text.rs +++ b/tests/code_text.rs @@ -3,15 +3,18 @@ use micromark::{ mdast::{InlineCode, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn code_text() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -164,9 +167,12 @@ fn code_text() -> Result<(), String> { micromark_with_options( "`a`", &Options { - constructs: Constructs { - code_text: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + code_text: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -176,7 +182,7 @@ fn code_text() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a `alpha` b.", &Options::default())?, + micromark_to_mdast("a `alpha` b.", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ diff --git a/tests/commonmark.rs b/tests/commonmark.rs index e96623a..cc3d69a 100644 --- a/tests/commonmark.rs +++ b/tests/commonmark.rs @@ -4,15 +4,18 @@ // > It is generate from the latest CommonMark website. extern crate micromark; -use micromark::{micromark_with_options, Options}; +use micromark::{micromark_with_options, CompileOptions, Options}; use pretty_assertions::assert_eq; #[rustfmt::skip] #[test] fn commonmark() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; diff --git a/tests/definition.rs b/tests/definition.rs index bf9d8ad..8357a67 100644 --- a/tests/definition.rs +++ b/tests/definition.rs @@ -3,15 +3,18 @@ use micromark::{ mdast::{Definition, Node, Root}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn definition() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -485,9 +488,12 @@ fn definition() -> Result<(), String> { micromark_with_options( "[foo]: /url \"title\"", &Options { - constructs: Constructs { - definition: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + definition: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -497,7 +503,7 @@ fn definition() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("[a]: <b> 'c'", &Options::default())?, + micromark_to_mdast("[a]: <b> 'c'", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Definition(Definition { url: "b".to_string(), diff --git a/tests/frontmatter.rs b/tests/frontmatter.rs index e9f6648..335084e 100644 --- a/tests/frontmatter.rs +++ b/tests/frontmatter.rs @@ -3,16 +3,19 @@ use micromark::{ mdast::{Node, Root, Toml, Yaml}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn frontmatter() -> Result<(), String> { let frontmatter = Options { - constructs: Constructs { - frontmatter: true, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + frontmatter: true, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() }; @@ -72,7 +75,7 @@ fn frontmatter() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("---\na: b\n---", &frontmatter)?, + micromark_to_mdast("---\na: b\n---", &frontmatter.parse)?, Node::Root(Root { children: vec![Node::Yaml(Yaml { value: "a: b".to_string(), @@ -84,7 +87,7 @@ fn frontmatter() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("+++\ntitle = \"Jupyter\"\n+++", &frontmatter)?, + micromark_to_mdast("+++\ntitle = \"Jupyter\"\n+++", &frontmatter.parse)?, Node::Root(Root { children: vec![Node::Toml(Toml { value: "title = \"Jupyter\"".to_string(), diff --git a/tests/fuzz.rs b/tests/fuzz.rs index 47dbea5..8233ebf 100644 --- a/tests/fuzz.rs +++ b/tests/fuzz.rs @@ -1,5 +1,7 @@ extern crate micromark; -use micromark::{micromark, micromark_with_options, Constructs, Options}; +use micromark::{ + micromark, micromark_with_options, CompileOptions, Constructs, Options, ParseOptions, +}; use pretty_assertions::assert_eq; #[test] @@ -16,9 +18,14 @@ fn fuzz() -> Result<(), String> { micromark_with_options( "a@b.c+d@e.f", &Options { - constructs: Constructs::gfm(), - gfm_tagfilter: true, - ..Options::default() + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { + gfm_tagfilter: true, + ..CompileOptions::default() + } } )?, "<p><a href=\"mailto:a@b.c\">a@b.c</a><a href=\"mailto:+d@e.f\">+d@e.f</a></p>", diff --git a/tests/gfm_autolink_literal.rs b/tests/gfm_autolink_literal.rs index d699343..9297163 100644 --- a/tests/gfm_autolink_literal.rs +++ b/tests/gfm_autolink_literal.rs @@ -3,14 +3,17 @@ use micromark::{ mdast::{Link, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn gfm_autolink_literal() -> Result<(), String> { let gfm = Options { - constructs: Constructs::gfm(), + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -2743,7 +2746,7 @@ www.a/~ assert_eq!( micromark_to_mdast( "a https://alpha.com b bravo@charlie.com c www.delta.com d xmpp:echo@foxtrot.com e mailto:golf@hotel.com f.", - &gfm + &gfm.parse )?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { diff --git a/tests/gfm_footnote.rs b/tests/gfm_footnote.rs index 364bf90..29b0092 100644 --- a/tests/gfm_footnote.rs +++ b/tests/gfm_footnote.rs @@ -3,14 +3,17 @@ use micromark::{ mdast::{FootnoteDefinition, FootnoteReference, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn gfm_footnote() -> Result<(), String> { let gfm = Options { - constructs: Constructs::gfm(), + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -38,10 +41,15 @@ fn gfm_footnote() -> Result<(), String> { micromark_with_options( "Noot.[^a]\n\n[^a]: dingen", &Options { - constructs: Constructs::gfm(), + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { gfm_footnote_label: Some("Voetnoten".to_string()), gfm_footnote_back_label: Some("Terug naar de inhoud".to_string()), - ..Options::default() + ..CompileOptions::default() + } } )?, "<p>Noot.<sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p> @@ -60,9 +68,14 @@ fn gfm_footnote() -> Result<(), String> { micromark_with_options( "[^a]\n\n[^a]: b", &Options { - constructs: Constructs::gfm(), + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { gfm_footnote_label_tag_name: Some("h1".to_string()), - ..Options::default() + ..CompileOptions::default() + } } )?, "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p> @@ -81,9 +94,14 @@ fn gfm_footnote() -> Result<(), String> { micromark_with_options( "[^a]\n\n[^a]: b", &Options { - constructs: Constructs::gfm(), + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { gfm_footnote_label_attributes: Some("class=\"footnote-heading\"".to_string()), - ..Options::default() + ..CompileOptions::default() + } } )?, "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p> @@ -102,9 +120,14 @@ fn gfm_footnote() -> Result<(), String> { micromark_with_options( "[^a]\n\n[^a]: b", &Options { - constructs: Constructs::gfm(), - gfm_footnote_clobber_prefix: Some("".to_string()), - ..Options::default() + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, + compile: CompileOptions { + gfm_footnote_clobber_prefix: Some("".to_string()), + ..CompileOptions::default() + } } )?, "<p><sup><a href=\"#fn-a\" id=\"fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p> @@ -1603,7 +1626,7 @@ multi-paragraph list items. <a href="#user-content-fnref-longnote" data-footnote ); assert_eq!( - micromark_to_mdast("[^a]: b\n\tc\n\nd [^a] e.", &gfm)?, + micromark_to_mdast("[^a]: b\n\tc\n\nd [^a] e.", &gfm.parse)?, Node::Root(Root { children: vec![ Node::FootnoteDefinition(FootnoteDefinition { diff --git a/tests/gfm_strikethrough.rs b/tests/gfm_strikethrough.rs index e392700..ac6b62c 100644 --- a/tests/gfm_strikethrough.rs +++ b/tests/gfm_strikethrough.rs @@ -3,14 +3,17 @@ use micromark::{ mdast::{Delete, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn gfm_strikethrough() -> Result<(), String> { let gfm = Options { - constructs: Constructs::gfm(), + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -368,8 +371,11 @@ u ~**xxx**~ zzz micromark_with_options( "a ~b~ ~~c~~ d", &Options { - constructs: Constructs::gfm(), - gfm_strikethrough_single_tilde: false, + parse: ParseOptions { + constructs: Constructs::gfm(), + gfm_strikethrough_single_tilde: false, + ..ParseOptions::default() + }, ..Options::default() } )?, @@ -381,8 +387,11 @@ u ~**xxx**~ zzz micromark_with_options( "a ~b~ ~~c~~ d", &Options { - constructs: Constructs::gfm(), - gfm_strikethrough_single_tilde: true, + parse: ParseOptions { + constructs: Constructs::gfm(), + gfm_strikethrough_single_tilde: true, + ..ParseOptions::default() + }, ..Options::default() } )?, @@ -391,7 +400,7 @@ u ~**xxx**~ zzz ); assert_eq!( - micromark_to_mdast("a ~~alpha~~ b.", &gfm)?, + micromark_to_mdast("a ~~alpha~~ b.", &gfm.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ 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() + })?, "<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n</table>", "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<!-- HTML? -->", &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() + } } )?, "<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n</table>\n<!-- HTML? -->", @@ -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() + } + })?, "<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n</table>\n<pre><code>code?\n</code></pre>", "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() + } + })?, "<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n</table>\n<pre><code class=\"language-js\">code?\n</code></pre>\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() + } } )?, "<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n</table>\n<hr />", @@ -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###"<h1>Grave accents</h1> @@ -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###"<h2>Blank line</h2> @@ -1792,7 +1834,7 @@ normal escape: <a href="https://github.com/github/cmark-gfm/issues/277">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: <a href="https://github.com/github/cmark-gfm/issues/277">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,], diff --git a/tests/gfm_tagfilter.rs b/tests/gfm_tagfilter.rs index 68246bd..9321d01 100644 --- a/tests/gfm_tagfilter.rs +++ b/tests/gfm_tagfilter.rs @@ -1,5 +1,5 @@ extern crate micromark; -use micromark::{micromark_with_options, Options}; +use micromark::{micromark_with_options, CompileOptions, Options}; use pretty_assertions::assert_eq; #[test] @@ -8,7 +8,10 @@ fn gfm_tagfilter() -> Result<(), String> { micromark_with_options( "<iframe>", &Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + ..CompileOptions::default() + }, ..Options::default() } )?, @@ -20,7 +23,10 @@ fn gfm_tagfilter() -> Result<(), String> { micromark_with_options( "a <i>\n<script>", &Options { - gfm_tagfilter: true, + compile: CompileOptions { + gfm_tagfilter: true, + ..CompileOptions::default() + }, ..Options::default() } )?, @@ -32,8 +38,11 @@ fn gfm_tagfilter() -> Result<(), String> { micromark_with_options( "<iframe>", &Options { - gfm_tagfilter: true, - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + gfm_tagfilter: true, + ..CompileOptions::default() + }, ..Options::default() } )?, @@ -87,8 +96,11 @@ javascript:/*--></title></style></textarea></script></xmp><svg/onload='+/"/+/onm <STYLE>@import'http://xss.rocks/xss.css';</STYLE> "###, &Options { - gfm_tagfilter: true, - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + gfm_tagfilter: true, + ..CompileOptions::default() + }, ..Options::default() } )?, diff --git a/tests/gfm_task_list_item.rs b/tests/gfm_task_list_item.rs index 1a0b682..8bc0d31 100644 --- a/tests/gfm_task_list_item.rs +++ b/tests/gfm_task_list_item.rs @@ -3,14 +3,17 @@ use micromark::{ mdast::{List, ListItem, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn gfm_task_list_item() -> Result<(), String> { let gfm = Options { - constructs: Constructs::gfm(), + parse: ParseOptions { + constructs: Constructs::gfm(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -246,7 +249,7 @@ Text.</li> ); assert_eq!( - micromark_to_mdast("* [x] a\n* [ ] b\n* c", &gfm)?, + micromark_to_mdast("* [x] a\n* [ ] b\n* c", &gfm.parse)?, Node::Root(Root { children: vec![Node::List(List { ordered: false, diff --git a/tests/hard_break_escape.rs b/tests/hard_break_escape.rs index 9a984bf..2e88c95 100644 --- a/tests/hard_break_escape.rs +++ b/tests/hard_break_escape.rs @@ -3,7 +3,7 @@ use micromark::{ mdast::{Break, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; @@ -49,9 +49,12 @@ fn hard_break_escape() -> Result<(), String> { micromark_with_options( "a\\\nb", &Options { - constructs: Constructs { - hard_break_escape: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + hard_break_escape: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -61,7 +64,7 @@ fn hard_break_escape() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a\\\nb.", &Options::default())?, + micromark_to_mdast("a\\\nb.", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ diff --git a/tests/hard_break_trailing.rs b/tests/hard_break_trailing.rs index 41a320e..907356a 100644 --- a/tests/hard_break_trailing.rs +++ b/tests/hard_break_trailing.rs @@ -3,7 +3,7 @@ use micromark::{ mdast::{Break, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; @@ -115,9 +115,12 @@ fn hard_break_trailing() -> Result<(), String> { micromark_with_options( "a \nb", &Options { - constructs: Constructs { - hard_break_trailing: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + hard_break_trailing: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -127,7 +130,7 @@ fn hard_break_trailing() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a \nb.", &Options::default())?, + micromark_to_mdast("a \nb.", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ diff --git a/tests/heading_atx.rs b/tests/heading_atx.rs index c13ef1a..1b6b8a3 100644 --- a/tests/heading_atx.rs +++ b/tests/heading_atx.rs @@ -3,7 +3,7 @@ use micromark::{ mdast::{Heading, Node, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; @@ -211,9 +211,12 @@ fn heading_atx() -> Result<(), String> { micromark_with_options( "# a", &Options { - constructs: Constructs { - heading_atx: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + heading_atx: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -223,7 +226,7 @@ fn heading_atx() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("## alpha #", &Options::default())?, + micromark_to_mdast("## alpha #", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Heading(Heading { depth: 2, diff --git a/tests/heading_setext.rs b/tests/heading_setext.rs index 8050ed2..ed2dfa0 100644 --- a/tests/heading_setext.rs +++ b/tests/heading_setext.rs @@ -3,7 +3,7 @@ use micromark::{ mdast::{Heading, Node, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; @@ -278,9 +278,12 @@ fn heading_setext() -> Result<(), String> { micromark_with_options( "a\n-", &Options { - constructs: Constructs { - heading_setext: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + heading_setext: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -290,7 +293,7 @@ fn heading_setext() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("alpha\nbravo\n==", &Options::default())?, + micromark_to_mdast("alpha\nbravo\n==", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Heading(Heading { depth: 1, diff --git a/tests/html_flow.rs b/tests/html_flow.rs index 2f1d85f..ca93510 100644 --- a/tests/html_flow.rs +++ b/tests/html_flow.rs @@ -3,14 +3,18 @@ use micromark::{ mdast::{Html, Node, Root}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn html_flow() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -30,9 +34,12 @@ fn html_flow() -> Result<(), String> { micromark_with_options( "<x>", &Options { - constructs: Constructs { - html_flow: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + html_flow: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -42,7 +49,7 @@ fn html_flow() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("<div>\nstuff\n</div>", &Options::default())?, + micromark_to_mdast("<div>\nstuff\n</div>", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Html(Html { value: "<div>\nstuff\n</div>".to_string(), @@ -59,7 +66,11 @@ fn html_flow() -> Result<(), String> { #[test] fn html_flow_1_raw() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -221,7 +232,11 @@ p {color:blue;} #[test] fn html_flow_2_comment() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -326,7 +341,11 @@ fn html_flow_2_comment() -> Result<(), String> { #[test] fn html_flow_3_instruction() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -379,7 +398,11 @@ fn html_flow_3_instruction() -> Result<(), String> { #[test] fn html_flow_4_declaration() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -440,7 +463,11 @@ fn html_flow_4_declaration() -> Result<(), String> { #[test] fn html_flow_5_cdata() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -510,7 +537,11 @@ fn html_flow_5_cdata() -> Result<(), String> { #[test] fn html_flow_6_basic() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -793,7 +824,11 @@ okay.", #[test] fn html_flow_7_complete() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; diff --git a/tests/html_text.rs b/tests/html_text.rs index 40e860e..bc36bd7 100644 --- a/tests/html_text.rs +++ b/tests/html_text.rs @@ -3,14 +3,18 @@ use micromark::{ mdast::{Html, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn html_text() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -427,9 +431,12 @@ micromark_with_options("<x> a", &danger)?, micromark_with_options( "a <x>", &Options { - constructs: Constructs { - html_text: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + html_text: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -439,7 +446,7 @@ micromark_with_options("<x> a", &danger)?, ); assert_eq!( - micromark_to_mdast("alpha <i>bravo</b> charlie.", &Options::default())?, + micromark_to_mdast("alpha <i>bravo</b> charlie.", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ diff --git a/tests/image.rs b/tests/image.rs index 6669e8d..f52025d 100644 --- a/tests/image.rs +++ b/tests/image.rs @@ -3,7 +3,7 @@ use micromark::{ mdast::{Definition, Image, ImageReference, Node, Paragraph, ReferenceKind, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; @@ -201,9 +201,12 @@ fn image() -> Result<(), String> { micromark_with_options( "![x]()", &Options { - constructs: Constructs { - label_start_image: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + label_start_image: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -222,7 +225,10 @@ fn image() -> Result<(), String> { micromark_with_options( "![](javascript:alert(1))", &Options { - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() } )?, @@ -233,7 +239,7 @@ fn image() -> Result<(), String> { assert_eq!( micromark_to_mdast( "a ![alpha]() b ![bravo](charlie 'delta') c.", - &Options::default() + &ParseOptions::default() )?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { @@ -273,7 +279,7 @@ fn image() -> Result<(), String> { assert_eq!( micromark_to_mdast( "[x]: y\n\na ![x] b ![x][] c ![d][x] e.", - &Options::default() + &ParseOptions::default() )?, Node::Root(Root { children: vec![ diff --git a/tests/link_reference.rs b/tests/link_reference.rs index 680bb1d..c21ca0b 100644 --- a/tests/link_reference.rs +++ b/tests/link_reference.rs @@ -3,15 +3,18 @@ use micromark::{ mdast::{Definition, LinkReference, Node, Paragraph, ReferenceKind, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn link_reference() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -393,9 +396,12 @@ fn link_reference() -> Result<(), String> { micromark_with_options( "[x]()", &Options { - constructs: Constructs { - label_start_link: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + label_start_link: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -408,9 +414,12 @@ fn link_reference() -> Result<(), String> { micromark_with_options( "[x]()", &Options { - constructs: Constructs { - label_end: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + label_end: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -420,7 +429,10 @@ fn link_reference() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("[x]: y\n\na [x] b [x][] c [d][x] e.", &Options::default())?, + micromark_to_mdast( + "[x]: y\n\na [x] b [x][] c [d][x] e.", + &ParseOptions::default() + )?, Node::Root(Root { children: vec![ Node::Definition(Definition { diff --git a/tests/link_resource.rs b/tests/link_resource.rs index ef79653..9f136ef 100644 --- a/tests/link_resource.rs +++ b/tests/link_resource.rs @@ -3,15 +3,18 @@ use micromark::{ mdast::{Link, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Options, + CompileOptions, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn link_resource() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -466,7 +469,7 @@ fn link_resource() -> Result<(), String> { assert_eq!( micromark_to_mdast( "a [alpha]() b [bravo](charlie 'delta') c.", - &Options::default() + &ParseOptions::default() )?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { diff --git a/tests/list.rs b/tests/list.rs index d485d49..560be82 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -3,14 +3,18 @@ use micromark::{ mdast::{List, ListItem, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn list() -> Result<(), String> { let danger = Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; @@ -572,9 +576,12 @@ fn list() -> Result<(), String> { micromark_with_options( "- one\n\n two", &Options { - constructs: Constructs { - list_item: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + list_item: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -584,7 +591,7 @@ fn list() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("* a", &Options::default())?, + micromark_to_mdast("* a", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::List(List { ordered: false, @@ -610,7 +617,7 @@ fn list() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("3. a", &Options::default())?, + micromark_to_mdast("3. a", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::List(List { ordered: true, @@ -636,7 +643,7 @@ fn list() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("* a\n\n b\n* c", &Options::default())?, + micromark_to_mdast("* a\n\n b\n* c", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::List(List { ordered: false, diff --git a/tests/math_flow.rs b/tests/math_flow.rs index abb1f32..4665eef 100644 --- a/tests/math_flow.rs +++ b/tests/math_flow.rs @@ -3,17 +3,20 @@ use micromark::{ mdast::{Math, Node, Root}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn math_flow() -> Result<(), String> { let math = Options { - constructs: Constructs { - math_text: true, - math_flow: true, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + math_text: true, + math_flow: true, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() }; @@ -254,7 +257,7 @@ fn math_flow() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("$$extra\nabc\ndef\n$$", &math)?, + micromark_to_mdast("$$extra\nabc\ndef\n$$", &math.parse)?, Node::Root(Root { children: vec![Node::Math(Math { meta: Some("extra".to_string()), diff --git a/tests/math_text.rs b/tests/math_text.rs index 76aa0aa..6282181 100644 --- a/tests/math_text.rs +++ b/tests/math_text.rs @@ -3,17 +3,20 @@ use micromark::{ mdast::{InlineMath, Node, Paragraph, Root, Text}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + CompileOptions, Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn math_text() -> Result<(), String> { let math = Options { - constructs: Constructs { - math_text: true, - math_flow: true, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + math_text: true, + math_flow: true, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() }; @@ -34,11 +37,14 @@ fn math_text() -> Result<(), String> { micromark_with_options( "$foo$ $$bar$$", &Options { - math_text_single_dollar: false, - constructs: Constructs { - math_text: true, - math_flow: true, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + math_text: true, + math_flow: true, + ..Constructs::default() + }, + math_text_single_dollar: false, + ..ParseOptions::default() }, ..Options::default() } @@ -141,14 +147,19 @@ fn math_text() -> Result<(), String> { micromark_with_options( "<a href=\"$\">$", &Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, - constructs: Constructs { - math_text: true, - math_flow: true, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + math_text: true, + math_flow: true, + ..Constructs::default() + }, + ..ParseOptions::default() }, - ..Options::default() + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + } } )?, "<p><a href=\"$\">$</p>", @@ -198,7 +209,7 @@ fn math_text() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a $alpha$ b.", &math)?, + micromark_to_mdast("a $alpha$ b.", &math.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ diff --git a/tests/mdx_esm.rs b/tests/mdx_esm.rs index a9c7f4a..d6021a1 100644 --- a/tests/mdx_esm.rs +++ b/tests/mdx_esm.rs @@ -4,7 +4,7 @@ use micromark::{ mdast::{MdxjsEsm, Node, Root}, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; use test_utils::swc::{parse_esm, parse_expression}; @@ -12,9 +12,12 @@ use test_utils::swc::{parse_esm, parse_expression}; #[test] fn mdx_esm() -> Result<(), String> { let swc = Options { - constructs: Constructs::mdx(), - mdx_esm_parse: Some(Box::new(parse_esm)), - mdx_expression_parse: Some(Box::new(parse_expression)), + parse: ParseOptions { + constructs: Constructs::mdx(), + mdx_esm_parse: Some(Box::new(parse_esm)), + mdx_expression_parse: Some(Box::new(parse_expression)), + ..ParseOptions::default() + }, ..Options::default() }; @@ -243,7 +246,7 @@ fn mdx_esm() -> Result<(), String> { } assert_eq!( - micromark_to_mdast("import a from 'b'\nexport {a}", &swc)?, + micromark_to_mdast("import a from 'b'\nexport {a}", &swc.parse)?, Node::Root(Root { children: vec![Node::MdxjsEsm(MdxjsEsm { value: "import a from 'b'\nexport {a}".to_string(), diff --git a/tests/mdx_expression_flow.rs b/tests/mdx_expression_flow.rs index b02d32b..0b13149 100644 --- a/tests/mdx_expression_flow.rs +++ b/tests/mdx_expression_flow.rs @@ -4,7 +4,7 @@ use micromark::{ mdast::{MdxFlowExpression, Node, Root}, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; use test_utils::swc::{parse_esm, parse_expression}; @@ -12,7 +12,10 @@ use test_utils::swc::{parse_esm, parse_expression}; #[test] fn mdx_expression_flow_agnostic() -> Result<(), String> { let mdx = Options { - constructs: Constructs::mdx(), + parse: ParseOptions { + constructs: Constructs::mdx(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -87,7 +90,7 @@ fn mdx_expression_flow_agnostic() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("{alpha +\nbravo}", &mdx)?, + micromark_to_mdast("{alpha +\nbravo}", &mdx.parse)?, Node::Root(Root { children: vec![Node::MdxFlowExpression(MdxFlowExpression { value: "alpha +\nbravo".to_string(), @@ -104,9 +107,12 @@ fn mdx_expression_flow_agnostic() -> Result<(), String> { #[test] fn mdx_expression_flow_gnostic() -> Result<(), String> { let swc = Options { - constructs: Constructs::mdx(), - mdx_esm_parse: Some(Box::new(parse_esm)), - mdx_expression_parse: Some(Box::new(parse_expression)), + parse: ParseOptions { + constructs: Constructs::mdx(), + mdx_esm_parse: Some(Box::new(parse_esm)), + mdx_expression_parse: Some(Box::new(parse_expression)), + ..ParseOptions::default() + }, ..Options::default() }; @@ -176,9 +182,12 @@ fn mdx_expression_flow_gnostic() -> Result<(), String> { #[test] fn mdx_expression_spread() -> Result<(), String> { let swc = Options { - constructs: Constructs::mdx(), - mdx_esm_parse: Some(Box::new(parse_esm)), - mdx_expression_parse: Some(Box::new(parse_expression)), + parse: ParseOptions { + constructs: Constructs::mdx(), + mdx_esm_parse: Some(Box::new(parse_esm)), + mdx_expression_parse: Some(Box::new(parse_expression)), + ..ParseOptions::default() + }, ..Options::default() }; diff --git a/tests/mdx_expression_text.rs b/tests/mdx_expression_text.rs index 9eb9dbf..d893a70 100644 --- a/tests/mdx_expression_text.rs +++ b/tests/mdx_expression_text.rs @@ -4,7 +4,7 @@ use micromark::{ mdast::{MdxTextExpression, Node, Paragraph, Root, Text}, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; use test_utils::swc::{parse_esm, parse_expression}; @@ -12,9 +12,12 @@ use test_utils::swc::{parse_esm, parse_expression}; #[test] fn mdx_expression_text_gnostic_core() -> Result<(), String> { let swc = Options { - constructs: Constructs::mdx(), - mdx_esm_parse: Some(Box::new(parse_esm)), - mdx_expression_parse: Some(Box::new(parse_expression)), + parse: ParseOptions { + constructs: Constructs::mdx(), + mdx_esm_parse: Some(Box::new(parse_esm)), + mdx_expression_parse: Some(Box::new(parse_expression)), + ..ParseOptions::default() + }, ..Options::default() }; @@ -148,7 +151,10 @@ fn mdx_expression_text_gnostic_core() -> Result<(), String> { #[test] fn mdx_expression_text_agnostic() -> Result<(), String> { let mdx = Options { - constructs: Constructs::mdx(), + parse: ParseOptions { + constructs: Constructs::mdx(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -197,7 +203,7 @@ fn mdx_expression_text_agnostic() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a {alpha} b.", &mdx)?, + micromark_to_mdast("a {alpha} b.", &mdx.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ @@ -227,9 +233,12 @@ fn mdx_expression_text_agnostic() -> Result<(), String> { #[test] fn mdx_expression_text_gnostic() -> Result<(), String> { let swc = Options { - constructs: Constructs::mdx(), - mdx_esm_parse: Some(Box::new(parse_esm)), - mdx_expression_parse: Some(Box::new(parse_expression)), + parse: ParseOptions { + constructs: Constructs::mdx(), + mdx_esm_parse: Some(Box::new(parse_esm)), + mdx_expression_parse: Some(Box::new(parse_expression)), + ..ParseOptions::default() + }, ..Options::default() }; diff --git a/tests/mdx_jsx_flow.rs b/tests/mdx_jsx_flow.rs index 54914e6..46d2559 100644 --- a/tests/mdx_jsx_flow.rs +++ b/tests/mdx_jsx_flow.rs @@ -3,14 +3,17 @@ use micromark::{ mdast::{List, ListItem, MdxJsxFlowElement, Node, Paragraph, Root, Text}, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn mdx_jsx_flow_agnostic() -> Result<(), String> { let mdx = Options { - constructs: Constructs::mdx(), + parse: ParseOptions { + constructs: Constructs::mdx(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -52,7 +55,10 @@ fn mdx_jsx_flow_agnostic() -> Result<(), String> { #[test] fn mdx_jsx_flow_essence() -> Result<(), String> { let mdx = Options { - constructs: Constructs::mdx(), + parse: ParseOptions { + constructs: Constructs::mdx(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -147,7 +153,7 @@ fn mdx_jsx_flow_essence() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("<>\n * a\n</>", &mdx)?, + micromark_to_mdast("<>\n * a\n</>", &mdx.parse)?, Node::Root(Root { children: vec![Node::MdxJsxFlowElement(MdxJsxFlowElement { name: None, diff --git a/tests/mdx_jsx_text.rs b/tests/mdx_jsx_text.rs index 0a27bb2..9064e83 100644 --- a/tests/mdx_jsx_text.rs +++ b/tests/mdx_jsx_text.rs @@ -7,7 +7,7 @@ use micromark::{ }, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; use test_utils::swc::{parse_esm, parse_expression}; @@ -15,7 +15,10 @@ use test_utils::swc::{parse_esm, parse_expression}; #[test] fn mdx_jsx_text_core() -> Result<(), String> { let mdx = Options { - constructs: Constructs::mdx(), + parse: ParseOptions { + constructs: Constructs::mdx(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -50,7 +53,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a <b /> c.", &mdx)?, + micromark_to_mdast("a <b /> c.", &mdx.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ @@ -77,7 +80,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a <b>*c*</b> d.", &mdx)?, + micromark_to_mdast("a <b>*c*</b> d.", &mdx.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ @@ -114,7 +117,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("<a:b />.", &mdx)?, + micromark_to_mdast("<a:b />.", &mdx.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ @@ -137,7 +140,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("<a.b.c />.", &mdx)?, + micromark_to_mdast("<a.b.c />.", &mdx.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ @@ -160,7 +163,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("<a {...b} />.", &mdx)?, + micromark_to_mdast("<a {...b} />.", &mdx.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ @@ -183,7 +186,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("<a b c:d />.", &mdx)?, + micromark_to_mdast("<a b c:d />.", &mdx.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ @@ -215,7 +218,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("<a b='c' d=\"e\" f={g} />.", &mdx)?, + micromark_to_mdast("<a b='c' d=\"e\" f={g} />.", &mdx.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ @@ -251,7 +254,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("<a b=' & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸' />.", &mdx)?, + micromark_to_mdast("<a b=' & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸' />.", &mdx.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ @@ -281,7 +284,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { assert_eq!( micromark_to_mdast( "<a b='# Ӓ Ϡ �' c='" ആ ಫ' />.", - &mdx + &mdx.parse )?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { @@ -314,7 +317,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("<a b='  &x; &#; &#x; � &#abcdef0; &ThisIsNotDefined; &hi?;' />.", &mdx)?, + micromark_to_mdast("<a b='  &x; &#; &#x; � &#abcdef0; &ThisIsNotDefined; &hi?;' />.", &mdx.parse)?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ @@ -342,7 +345,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a </b> c", &mdx) + micromark_to_mdast("a </b> c", &mdx.parse) .err() .unwrap(), "1:4: Unexpected closing slash `/` in tag, expected an open tag first (mdx-jsx:unexpected-closing-slash)", @@ -350,7 +353,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a <b> c </b/> d", &mdx) + micromark_to_mdast("a <b> c </b/> d", &mdx.parse) .err() .unwrap(), "1:12: Unexpected self-closing slash `/` in closing tag, expected the end of the tag (mdx-jsx:unexpected-self-closing-slash)", @@ -358,7 +361,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a <b> c </b d> e", &mdx) + micromark_to_mdast("a <b> c </b d> e", &mdx.parse) .err() .unwrap(), "1:13: Unexpected attribute in closing tag, expected the end of the tag (mdx-jsx:unexpected-attribute)", @@ -366,7 +369,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a <>b</c> d", &mdx) + micromark_to_mdast("a <>b</c> d", &mdx.parse) .err() .unwrap(), "1:6: Unexpected closing tag `</c>`, expected corresponding closing tag for `<>` (1:3) (mdx-jsx:end-tag-mismatch)", @@ -374,7 +377,7 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("a <b>c</> d", &mdx) + micromark_to_mdast("a <b>c</> d", &mdx.parse) .err() .unwrap(), "1:7: Unexpected closing tag `</>`, expected corresponding closing tag for `<b>` (1:3) (mdx-jsx:end-tag-mismatch)", @@ -382,26 +385,26 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("*a <b>c* d</b>.", &mdx).err().unwrap(), + micromark_to_mdast("*a <b>c* d</b>.", &mdx.parse).err().unwrap(), "1:9: Expected a closing tag for `<b>` (1:4) before the end of `Emphasis` (mdx-jsx:end-tag-mismatch)", "should crash when building the ast on mismatched interleaving (1)" ); assert_eq!( - micromark_to_mdast("<a>b *c</a> d*.", &mdx).err().unwrap(), + micromark_to_mdast("<a>b *c</a> d*.", &mdx.parse).err().unwrap(), "1:8: Expected the closing tag `</a>` either before the start of `Emphasis` (1:6), or another opening tag after that start (mdx-jsx:end-tag-mismatch)", "should crash when building the ast on mismatched interleaving (2)" ); assert_eq!( - micromark_to_mdast("a <b>.", &mdx).err().unwrap(), + micromark_to_mdast("a <b>.", &mdx.parse).err().unwrap(), "1:7: Expected a closing tag for `<b>` (1:3) before the end of `Paragraph` (mdx-jsx:end-tag-mismatch)", "should crash when building the ast on mismatched interleaving (3)" ); // Note: this is flow, not text. assert_eq!( - micromark_to_mdast("<a>", &mdx).err().unwrap(), + micromark_to_mdast("<a>", &mdx.parse).err().unwrap(), "1:4: Expected a closing tag for `<a>` (1:1) (mdx-jsx:end-tag-mismatch)", "should crash when building the ast on mismatched interleaving (4)" ); @@ -412,7 +415,10 @@ fn mdx_jsx_text_core() -> Result<(), String> { #[test] fn mdx_jsx_text_agnosic() -> Result<(), String> { let mdx = Options { - constructs: Constructs::mdx(), + parse: ParseOptions { + constructs: Constructs::mdx(), + ..ParseOptions::default() + }, ..Options::default() }; @@ -452,9 +458,12 @@ fn mdx_jsx_text_agnosic() -> Result<(), String> { #[test] fn mdx_jsx_text_gnostic() -> Result<(), String> { let swc = Options { - constructs: Constructs::mdx(), - mdx_esm_parse: Some(Box::new(parse_esm)), - mdx_expression_parse: Some(Box::new(parse_expression)), + parse: ParseOptions { + constructs: Constructs::mdx(), + mdx_esm_parse: Some(Box::new(parse_esm)), + mdx_expression_parse: Some(Box::new(parse_expression)), + ..ParseOptions::default() + }, ..Options::default() }; @@ -552,7 +561,10 @@ fn mdx_jsx_text_gnostic() -> Result<(), String> { #[test] fn mdx_jsx_text_complete() -> Result<(), String> { let mdx = Options { - constructs: Constructs::mdx(), + parse: ParseOptions { + constructs: Constructs::mdx(), + ..ParseOptions::default() + }, ..Options::default() }; diff --git a/tests/mdx_swc.rs b/tests/mdx_swc.rs index 74f975a..d4b8e46 100644 --- a/tests/mdx_swc.rs +++ b/tests/mdx_swc.rs @@ -1,44 +1,47 @@ extern crate micromark; mod test_utils; -use micromark::{micromark_with_options, Constructs, Options}; +use micromark::{micromark_with_options, Constructs, Options, ParseOptions}; use pretty_assertions::assert_eq; use test_utils::swc::{parse_esm, parse_expression}; #[test] fn mdx_swc() -> Result<(), String> { - let mdx = Options { - constructs: Constructs::mdx(), - mdx_esm_parse: Some(Box::new(parse_esm)), - mdx_expression_parse: Some(Box::new(parse_expression)), + let swc = Options { + parse: ParseOptions { + constructs: Constructs::mdx(), + mdx_esm_parse: Some(Box::new(parse_esm)), + mdx_expression_parse: Some(Box::new(parse_expression)), + ..ParseOptions::default() + }, ..Options::default() }; assert_eq!( - micromark_with_options("{'}'}", &mdx)?, + micromark_with_options("{'}'}", &swc)?, "", "should support JavaScript-aware flow expressions w/ `mdx_expression_parse`" ); assert_eq!( - micromark_with_options("a {'}'} b", &mdx)?, + micromark_with_options("a {'}'} b", &swc)?, "<p>a b</p>", "should support JavaScript-aware text expressions w/ `mdx_expression_parse`" ); assert_eq!( - micromark_with_options("<a {...a/*}*/} />", &mdx)?, + micromark_with_options("<a {...a/*}*/} />", &swc)?, "", "should support JavaScript-aware attribute expressions w/ `mdx_expression_parse`" ); assert_eq!( - micromark_with_options("<a b={'}'} />", &mdx)?, + micromark_with_options("<a b={'}'} />", &swc)?, "", "should support JavaScript-aware attribute value expressions w/ `mdx_expression_parse`" ); assert_eq!( - micromark_with_options("import a from 'b'\n\nexport {a}\n\n# c", &mdx)?, + micromark_with_options("import a from 'b'\n\nexport {a}\n\n# c", &swc)?, "<h1>c</h1>", "should support JavaScript-aware ESM w/ `mdx_esm_parse`" ); diff --git a/tests/misc_dangerous_html.rs b/tests/misc_dangerous_html.rs index 8afa481..9787813 100644 --- a/tests/misc_dangerous_html.rs +++ b/tests/misc_dangerous_html.rs @@ -1,12 +1,15 @@ extern crate micromark; -use micromark::{micromark, micromark_with_options, Options}; +use micromark::{micromark, micromark_with_options, CompileOptions, Options}; use pretty_assertions::assert_eq; #[test] fn dangerous_html() -> Result<(), String> { let danger = &Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; diff --git a/tests/misc_default_line_ending.rs b/tests/misc_default_line_ending.rs index b122c50..f839e2c 100644 --- a/tests/misc_default_line_ending.rs +++ b/tests/misc_default_line_ending.rs @@ -1,5 +1,5 @@ extern crate micromark; -use micromark::{micromark, micromark_with_options, LineEnding, Options}; +use micromark::{micromark, micromark_with_options, CompileOptions, LineEnding, Options}; use pretty_assertions::assert_eq; #[test] @@ -32,7 +32,10 @@ fn default_line_ending() -> Result<(), String> { micromark_with_options( "> a", &Options { - default_line_ending: LineEnding::CarriageReturn, + compile: CompileOptions { + default_line_ending: LineEnding::CarriageReturn, + ..CompileOptions::default() + }, ..Options::default() } )?, @@ -44,7 +47,10 @@ fn default_line_ending() -> Result<(), String> { micromark_with_options( "> a\n", &Options { - default_line_ending: LineEnding::CarriageReturn, + compile: CompileOptions { + default_line_ending: LineEnding::CarriageReturn, + ..CompileOptions::default() + }, ..Options::default() } )?, diff --git a/tests/misc_line_ending.rs b/tests/misc_line_ending.rs index 6713b32..90f9df0 100644 --- a/tests/misc_line_ending.rs +++ b/tests/misc_line_ending.rs @@ -1,12 +1,15 @@ extern crate micromark; -use micromark::{micromark, micromark_with_options, Options}; +use micromark::{micromark, micromark_with_options, CompileOptions, Options}; use pretty_assertions::assert_eq; #[test] fn line_ending() -> Result<(), String> { let danger = &Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; diff --git a/tests/misc_tabs.rs b/tests/misc_tabs.rs index 5cd9f69..56698e8 100644 --- a/tests/misc_tabs.rs +++ b/tests/misc_tabs.rs @@ -1,11 +1,15 @@ extern crate micromark; -use micromark::{micromark, micromark_with_options, Options}; +use micromark::{micromark, micromark_with_options, CompileOptions, Options}; use pretty_assertions::assert_eq; #[test] fn tabs_flow() -> Result<(), String> { let danger = &Options { - allow_dangerous_html: true, + compile: CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..CompileOptions::default() + }, ..Options::default() }; diff --git a/tests/thematic_break.rs b/tests/thematic_break.rs index d8d8104..c5612bb 100644 --- a/tests/thematic_break.rs +++ b/tests/thematic_break.rs @@ -3,7 +3,7 @@ use micromark::{ mdast::{Node, Root, ThematicBreak}, micromark, micromark_to_mdast, micromark_with_options, unist::Position, - Constructs, Options, + Constructs, Options, ParseOptions, }; use pretty_assertions::assert_eq; @@ -175,9 +175,12 @@ fn thematic_break() -> Result<(), String> { micromark_with_options( "***", &Options { - constructs: Constructs { - thematic_break: false, - ..Constructs::default() + parse: ParseOptions { + constructs: Constructs { + thematic_break: false, + ..Constructs::default() + }, + ..ParseOptions::default() }, ..Options::default() } @@ -187,7 +190,7 @@ fn thematic_break() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("***", &Options::default())?, + micromark_to_mdast("***", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::ThematicBreak(ThematicBreak { position: Some(Position::new(1, 1, 0, 1, 4, 3)) diff --git a/tests/xxx_document.rs b/tests/xxx_document.rs index dcbb56b..d5c8eef 100644 --- a/tests/xxx_document.rs +++ b/tests/xxx_document.rs @@ -3,7 +3,7 @@ extern crate swc_common; extern crate swc_ecma_ast; extern crate swc_ecma_codegen; mod test_utils; -use micromark::{micromark_to_mdast, Constructs, Options}; +use micromark::{micromark_to_mdast, Constructs, ParseOptions}; use pretty_assertions::assert_eq; use test_utils::{ swc::{parse_esm, parse_expression, serialize}, @@ -15,11 +15,11 @@ use test_utils::{ fn from_markdown(value: &str) -> Result<String, String> { let mdast = micromark_to_mdast( value, - &Options { + &ParseOptions { constructs: Constructs::mdx(), mdx_esm_parse: Some(Box::new(parse_esm)), mdx_expression_parse: Some(Box::new(parse_expression)), - ..Options::default() + ..ParseOptions::default() }, )?; let hast = to_hast(&mdast); diff --git a/tests/xxx_jsx_rewrite.rs b/tests/xxx_jsx_rewrite.rs index ad7c4b4..7a1c379 100644 --- a/tests/xxx_jsx_rewrite.rs +++ b/tests/xxx_jsx_rewrite.rs @@ -3,7 +3,7 @@ extern crate swc_common; extern crate swc_ecma_ast; extern crate swc_ecma_codegen; mod test_utils; -use micromark::{micromark_to_mdast, Constructs, Options}; +use micromark::{micromark_to_mdast, Constructs, ParseOptions}; use pretty_assertions::assert_eq; use test_utils::{ jsx_rewrite::{jsx_rewrite, Options as RewriteOptions}, @@ -16,11 +16,11 @@ use test_utils::{ fn from_markdown(value: &str, options: &RewriteOptions) -> Result<String, String> { let mdast = micromark_to_mdast( value, - &Options { + &ParseOptions { constructs: Constructs::mdx(), mdx_esm_parse: Some(Box::new(parse_esm)), mdx_expression_parse: Some(Box::new(parse_expression)), - ..Options::default() + ..ParseOptions::default() }, )?; let hast = to_hast(&mdast); |