From 5403261e8213f68633a09fc3e9bc2e6e2cd777b2 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 18 Jul 2022 16:31:14 +0200 Subject: Add support for turning off constructs --- tests/definition.rs | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'tests/definition.rs') diff --git a/tests/definition.rs b/tests/definition.rs index 9bf4072..620ab69 100644 --- a/tests/definition.rs +++ b/tests/definition.rs @@ -1,14 +1,14 @@ extern crate micromark; -use micromark::{micromark, micromark_with_options, Options}; - -const DANGER: &Options = &Options { - allow_dangerous_html: true, - allow_dangerous_protocol: true, - default_line_ending: None, -}; +use micromark::{micromark, micromark_with_options, Constructs, Options}; #[test] fn definition() { + let danger = Options { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..Options::default() + }; + assert_eq!( micromark("[foo]: /url \"title\"\n\n[foo]"), "

foo

", @@ -76,7 +76,7 @@ fn definition() { ); assert_eq!( - micromark_with_options("[foo]: (baz)\n\n[foo]", DANGER), + micromark_with_options("[foo]: (baz)\n\n[foo]", &danger), "

[foo]: (baz)

\n

[foo]

", "should not support definitions w/ no whitespace between destination and title" ); @@ -357,7 +357,7 @@ fn definition() { ); assert_eq!( - micromark_with_options("[a]\n\n[a]: ", DANGER), + micromark_with_options("[a]\n\n[a]: ", &danger), "

[a]

\n

[a]: <b

", "should not support a less than in an enclosed destination" ); @@ -428,12 +428,18 @@ fn definition() { "should not support definitions w/ text + a closing paren as a raw destination" ); - // To do: turning things off. - // assert_eq!( - // micromark("[foo]: /url \"title\"", { - // extensions: [{disable: {null: ["definition"]}}] - // }), - // "

[foo]: /url "title"

", - // "should support turning off definitions" - // ); + assert_eq!( + micromark_with_options( + "[foo]: /url \"title\"", + &Options { + constructs: Constructs { + definition: false, + ..Constructs::default() + }, + ..Options::default() + } + ), + "

[foo]: /url "title"

", + "should support turning off definitions" + ); } -- cgit