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/html_flow.rs | 362 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 202 insertions(+), 160 deletions(-) (limited to 'tests/html_flow.rs') diff --git a/tests/html_flow.rs b/tests/html_flow.rs index d35a570..d3dfe59 100644 --- a/tests/html_flow.rs +++ b/tests/html_flow.rs @@ -1,14 +1,13 @@ extern crate micromark; -use micromark::{micromark, micromark_with_options, Options}; - -const DANGER: &Options = &Options { - allow_dangerous_html: true, - allow_dangerous_protocol: false, - default_line_ending: None, -}; +use micromark::{micromark, micromark_with_options, Constructs, Options}; #[test] fn html_flow() { + let danger = Options { + allow_dangerous_html: true, + ..Options::default() + }; + assert_eq!( micromark(""), "<!-- asd -->", @@ -16,21 +15,34 @@ fn html_flow() { ); assert_eq!( - micromark_with_options("", DANGER), + micromark_with_options("", &danger), "", "should support a heading w/ rank 1" ); - // To do: turning things off. - // assert_eq!( - // micromark_with_options("", {extensions: [{disable: {null: ["htmlFlow"]}}]}), - // "

<x>

", - // "should support turning off html (flow)" - // ); + assert_eq!( + micromark_with_options( + "", + &Options { + constructs: Constructs { + html_flow: false, + ..Constructs::default() + }, + ..Options::default() + } + ), + "

<x>

", + "should support turning off html (flow)" + ); } #[test] fn html_flow_1_raw() { + let danger = Options { + allow_dangerous_html: true, + ..Options::default() + }; + assert_eq!( micromark_with_options( "

@@ -40,7 +52,7 @@ main :: IO ()
 main = print $ parseTags tags
 
okay", - DANGER + &danger ), "

 import Text.HTML.TagSoup
@@ -60,7 +72,7 @@ main = print $ parseTags tags
 document.getElementById(\"demo\").innerHTML = \"Hello JavaScript!\";
 
 okay",
-            DANGER
+            &danger
         ),
         "1. *bar*", DANGER),
+        micromark_with_options("1. *bar*", &danger),
         "1. *bar*",
         "should support raw tags w/ more data on ending line"
     );
 
     assert_eq!(
-        micromark_with_options("</script\nmore

", "should not support a raw closing tag" ); assert_eq!( - micromark_with_options("", DANGER), + micromark_with_options("", &danger), "", "should support blank lines in raw" ); assert_eq!( - micromark_with_options(">