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/code_indented.rs | 140 ++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 72 deletions(-) (limited to 'tests/code_indented.rs') diff --git a/tests/code_indented.rs b/tests/code_indented.rs index 6735954..cb316e7 100644 --- a/tests/code_indented.rs +++ b/tests/code_indented.rs @@ -1,5 +1,5 @@ extern crate micromark; -use micromark::micromark; +use micromark::{micromark, micromark_with_options, Constructs, Options}; #[test] fn code_indented() { @@ -117,75 +117,71 @@ fn code_indented() { "should not support lazyness (7)" ); - // To do: turning things off. - // assert_eq!( - // micromark(" a", {extensions: [{disable: {null: ["codeIndented"]}}]}), - // "

a

", - // "should support turning off code (indented, 1)" - // ); - - // assert_eq!( - // micromark("> a\n b", { - // extensions: [{disable: {null: ["codeIndented"]}}] - // }), - // "
\n

a\nb

\n
", - // "should support turning off code (indented, 2)" - // ); - - // assert_eq!( - // micromark("- a\n b", { - // extensions: [{disable: {null: ["codeIndented"]}}] - // }), - // "", - // "should support turning off code (indented, 3)" - // ); - - // assert_eq!( - // micromark("- a\n - b", { - // extensions: [{disable: {null: ["codeIndented"]}}] - // }), - // "", - // "should support turning off code (indented, 4)" - // ); - - // assert_eq!( - // micromark("- a\n - b", { - // extensions: [{disable: {null: ["codeIndented"]}}] - // }), - // "", - // "should support turning off code (indented, 5)" - // ); - - // assert_eq!( - // micromark("```\na\n ```", { - // extensions: [{disable: {null: ["codeIndented"]}}] - // }), - // "
a\n
", - // "should support turning off code (indented, 6)" - // ); - - // assert_eq!( - // micromark("a ", { - // allowDangerousHtml: true, - // extensions: [{disable: {null: ["codeIndented"]}}] - // }), - // "

a

", - // "should support turning off code (indented, 7)" - // ); - - // assert_eq!( - // micromark("- Foo\n---", { - // extensions: [{disable: {null: ["codeIndented"]}}] - // }), - // "\n
", - // "should support turning off code (indented, 8)" - // ); - - // assert_eq!( - // micromark("- Foo\n ---", { - // extensions: [{disable: {null: ["codeIndented"]}}] - // }), - // "", - // "should support turning off code (indented, 9)" - // ); + let off = Options { + constructs: Constructs { + code_indented: false, + ..Constructs::default() + }, + ..Options::default() + }; + + assert_eq!( + micromark_with_options(" a", &off), + "

a

", + "should support turning off code (indented, 1)" + ); + + assert_eq!( + micromark_with_options("> a\n b", &off), + "
\n

a\nb

\n
", + "should support turning off code (indented, 2)" + ); + + assert_eq!( + micromark_with_options("- a\n b", &off), + "", + "should support turning off code (indented, 3)" + ); + + assert_eq!( + micromark_with_options("- a\n - b", &off), + "", + "should support turning off code (indented, 4)" + ); + + assert_eq!( + micromark_with_options("- a\n - b", &off), + "", + "should support turning off code (indented, 5)" + ); + + assert_eq!( + micromark_with_options("```\na\n ```", &off), + "
a\n
", + "should support turning off code (indented, 6)" + ); + + assert_eq!( + micromark_with_options( + "a ", + &Options { + allow_dangerous_html: true, + ..off.clone() + } + ), + "

a

", + "should support turning off code (indented, 7)" + ); + + assert_eq!( + micromark_with_options("- Foo\n---", &off), + "\n
", + "should support turning off code (indented, 8)" + ); + + assert_eq!( + micromark_with_options("- Foo\n ---", &off), + "", + "should support turning off code (indented, 9)" + ); } -- cgit