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/attention.rs | 20 +++++--- tests/autolink.rs | 20 +++++--- tests/block_quote.rs | 13 +++-- tests/character_escape.rs | 20 +++++--- tests/character_reference.rs | 19 ++++--- tests/code_fenced.rs | 15 +++--- tests/code_indented.rs | 28 +++++++---- tests/code_text.rs | 20 +++++--- tests/commonmark.rs | 9 ++-- tests/definition.rs | 20 +++++--- tests/frontmatter.rs | 15 +++--- tests/fuzz.rs | 15 ++++-- tests/gfm_autolink_literal.rs | 9 ++-- tests/gfm_footnote.rs | 47 +++++++++++++----- tests/gfm_strikethrough.rs | 23 ++++++--- tests/gfm_table.rs | 102 +++++++++++++++++++++++++++----------- tests/gfm_tagfilter.rs | 26 +++++++--- tests/gfm_task_list_item.rs | 9 ++-- tests/hard_break_escape.rs | 13 +++-- tests/hard_break_trailing.rs | 13 +++-- tests/heading_atx.rs | 13 +++-- tests/heading_setext.rs | 13 +++-- tests/html_flow.rs | 61 ++++++++++++++++++----- tests/html_text.rs | 19 ++++--- tests/image.rs | 20 +++++--- tests/link_reference.rs | 32 ++++++++---- tests/link_resource.rs | 11 ++-- tests/list.rs | 23 ++++++--- tests/math_flow.rs | 15 +++--- tests/math_text.rs | 47 +++++++++++------- tests/mdx_esm.rs | 13 +++-- tests/mdx_expression_flow.rs | 27 ++++++---- tests/mdx_expression_text.rs | 27 ++++++---- tests/mdx_jsx_flow.rs | 14 ++++-- tests/mdx_jsx_text.rs | 64 ++++++++++++++---------- tests/mdx_swc.rs | 23 +++++---- tests/misc_dangerous_html.rs | 9 ++-- tests/misc_default_line_ending.rs | 12 +++-- tests/misc_line_ending.rs | 9 ++-- tests/misc_tabs.rs | 8 ++- tests/thematic_break.rs | 13 +++-- tests/xxx_document.rs | 6 +-- tests/xxx_jsx_rewrite.rs | 6 +-- 43 files changed, 627 insertions(+), 314 deletions(-) (limited to 'tests') 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( "", &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 b 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( "", &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 ", &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() + } } )?, "

a

", @@ -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]: 'c'", &Options::default())?, + micromark_to_mdast("[a]: '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() + } } )?, "

a@b.c+d@e.f

", 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() + } } )?, "

Noot.1

@@ -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() + } } )?, "

1

@@ -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() + } } )?, "

1

@@ -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() + } } )?, "

1

@@ -1603,7 +1626,7 @@ multi-paragraph list items. 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() + })?, "\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,], 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( "