aboutsummaryrefslogtreecommitdiffstats
path: root/tests/attention.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-18 16:31:14 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-18 16:31:14 +0200
commit5403261e8213f68633a09fc3e9bc2e6e2cd777b2 (patch)
treebb3a6419ef42f7611c2cb24fe7024228f579331b /tests/attention.rs
parent03544cafaa82ba4bd7e0bc3372fc59549a8dc0cc (diff)
downloadmarkdown-rs-5403261e8213f68633a09fc3e9bc2e6e2cd777b2.tar.gz
markdown-rs-5403261e8213f68633a09fc3e9bc2e6e2cd777b2.tar.bz2
markdown-rs-5403261e8213f68633a09fc3e9bc2e6e2cd777b2.zip
Add support for turning off constructs
Diffstat (limited to 'tests/attention.rs')
-rw-r--r--tests/attention.rs42
1 files changed, 25 insertions, 17 deletions
diff --git a/tests/attention.rs b/tests/attention.rs
index 1d30dd4..9a3e2fe 100644
--- a/tests/attention.rs
+++ b/tests/attention.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 attention() {
+ let danger = Options {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..Options::default()
+ };
+
// Rule 1.
assert_eq!(
micromark("*foo bar*"),
@@ -764,25 +764,25 @@ fn attention() {
);
assert_eq!(
- micromark_with_options("*<img src=\"foo\" title=\"*\"/>", DANGER),
+ micromark_with_options("*<img src=\"foo\" title=\"*\"/>", &danger),
"<p>*<img src=\"foo\" title=\"*\"/></p>",
"should not end inside HTML"
);
assert_eq!(
- micromark_with_options("*<img src=\"foo\" title=\"*\"/>", DANGER),
+ micromark_with_options("*<img src=\"foo\" title=\"*\"/>", &danger),
"<p>*<img src=\"foo\" title=\"*\"/></p>",
"should not end emphasis inside HTML"
);
assert_eq!(
- micromark_with_options("**<a href=\"**\">", DANGER),
+ micromark_with_options("**<a href=\"**\">", &danger),
"<p>**<a href=\"**\"></p>",
"should not end strong inside HTML (1)"
);
assert_eq!(
- micromark_with_options("__<a href=\"__\">", DANGER),
+ micromark_with_options("__<a href=\"__\">", &danger),
"<p>__<a href=\"__\"></p>",
"should not end strong inside HTML (2)"
);
@@ -811,10 +811,18 @@ fn attention() {
"should not end strong emphasis inside autolinks (2)"
);
- // To do: turning things off.
- // assert_eq!(
- // micromark("*a*", {extensions: [{disable: {null: ["attention"]}}]}),
- // "<p>*a*</p>",
- // "should support turning off attention"
- // );
+ assert_eq!(
+ micromark_with_options(
+ "*a*",
+ &Options {
+ constructs: Constructs {
+ attention: false,
+ ..Constructs::default()
+ },
+ ..Options::default()
+ }
+ ),
+ "<p>*a*</p>",
+ "should support turning off attention"
+ );
}