aboutsummaryrefslogtreecommitdiffstats
path: root/tests/html_flow.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/html_flow.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/html_flow.rs')
-rw-r--r--tests/html_flow.rs362
1 files changed, 202 insertions, 160 deletions
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 -->"),
"&lt;!-- asd --&gt;",
@@ -16,21 +15,34 @@ fn html_flow() {
);
assert_eq!(
- micromark_with_options("<!-- asd -->", DANGER),
+ micromark_with_options("<!-- asd -->", &danger),
"<!-- asd -->",
"should support a heading w/ rank 1"
);
- // To do: turning things off.
- // assert_eq!(
- // micromark_with_options("<x>", {extensions: [{disable: {null: ["htmlFlow"]}}]}),
- // "<p>&lt;x&gt;</p>",
- // "should support turning off html (flow)"
- // );
+ assert_eq!(
+ micromark_with_options(
+ "<x>",
+ &Options {
+ constructs: Constructs {
+ html_flow: false,
+ ..Constructs::default()
+ },
+ ..Options::default()
+ }
+ ),
+ "<p>&lt;x&gt;</p>",
+ "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(
"<pre language=\"haskell\"><code>
@@ -40,7 +52,7 @@ main :: IO ()
main = print $ parseTags tags
</code></pre>
okay",
- DANGER
+ &danger
),
"<pre language=\"haskell\"><code>
import Text.HTML.TagSoup
@@ -60,7 +72,7 @@ main = print $ parseTags tags
document.getElementById(\"demo\").innerHTML = \"Hello JavaScript!\";
</script>
okay",
- DANGER
+ &danger
),
"<script type=\"text/javascript\">
// JavaScript example
@@ -80,7 +92,7 @@ h1 {color:red;}
p {color:blue;}
</style>
okay",
- DANGER
+ &danger
),
"<style
type=\"text/css\">
@@ -93,92 +105,92 @@ p {color:blue;}
);
assert_eq!(
- micromark_with_options("<style\n type=\"text/css\">\n\nfoo", DANGER),
+ micromark_with_options("<style\n type=\"text/css\">\n\nfoo", &danger),
"<style\n type=\"text/css\">\n\nfoo",
"should support raw tags w/o ending"
);
assert_eq!(
- micromark_with_options("<style>p{color:red;}</style>\n*foo*", DANGER),
+ micromark_with_options("<style>p{color:red;}</style>\n*foo*", &danger),
"<style>p{color:red;}</style>\n<p><em>foo</em></p>",
"should support raw tags w/ start and end on a single line"
);
assert_eq!(
- micromark_with_options("<script>\nfoo\n</script>1. *bar*", DANGER),
+ micromark_with_options("<script>\nfoo\n</script>1. *bar*", &danger),
"<script>\nfoo\n</script>1. *bar*",
"should support raw tags w/ more data on ending line"
);
assert_eq!(
- micromark_with_options("<script", DANGER),
+ micromark_with_options("<script", &danger),
"<script",
"should support an eof directly after a raw tag name"
);
assert_eq!(
- micromark_with_options("</script\nmore", DANGER),
+ micromark_with_options("</script\nmore", &danger),
"<p>&lt;/script\nmore</p>",
"should not support a raw closing tag"
);
assert_eq!(
- micromark_with_options("<script/", DANGER),
+ micromark_with_options("<script/", &danger),
"<p>&lt;script/</p>",
"should not support an eof after a self-closing slash"
);
assert_eq!(
- micromark_with_options("<script/\n*asd*", DANGER),
+ micromark_with_options("<script/\n*asd*", &danger),
"<p>&lt;script/\n<em>asd</em></p>",
"should not support a line ending after a self-closing slash"
);
assert_eq!(
- micromark_with_options("<script/>", DANGER),
+ micromark_with_options("<script/>", &danger),
"<script/>",
"should support an eof after a self-closing tag"
);
assert_eq!(
- micromark_with_options("<script/>\na", DANGER),
+ micromark_with_options("<script/>\na", &danger),
"<script/>\na",
"should support a line ending after a self-closing tag"
);
assert_eq!(
- micromark_with_options("<script/>a", DANGER),
+ micromark_with_options("<script/>a", &danger),
"<p><script/>a</p>",
"should not support other characters after a self-closing tag"
);
assert_eq!(
- micromark_with_options("<script>a", DANGER),
+ micromark_with_options("<script>a", &danger),
"<script>a",
"should support other characters after a raw opening tag"
);
// Extra.
assert_eq!(
- micromark_with_options("Foo\n<script", DANGER),
+ micromark_with_options("Foo\n<script", &danger),
"<p>Foo</p>\n<script",
"should support interrupting paragraphs w/ raw tags"
);
assert_eq!(
- micromark_with_options("<script>\n \n \n</script>", DANGER),
+ micromark_with_options("<script>\n \n \n</script>", &danger),
"<script>\n \n \n</script>",
"should support blank lines in raw"
);
assert_eq!(
- micromark_with_options("> <script>\na", DANGER),
+ micromark_with_options("> <script>\na", &danger),
"<blockquote>\n<script>\n</blockquote>\n<p>a</p>",
"should not support lazyness (1)"
);
assert_eq!(
- micromark_with_options("> a\n<script>", DANGER),
+ micromark_with_options("> a\n<script>", &danger),
"<blockquote>\n<p>a</p>\n</blockquote>\n<script>",
"should not support lazyness (2)"
);
@@ -186,97 +198,102 @@ p {color:blue;}
#[test]
fn html_flow_2_comment() {
+ let danger = Options {
+ allow_dangerous_html: true,
+ ..Options::default()
+ };
+
assert_eq!(
- micromark_with_options("<!-- Foo\n\nbar\n baz -->\nokay", DANGER),
+ micromark_with_options("<!-- Foo\n\nbar\n baz -->\nokay", &danger),
"<!-- Foo\n\nbar\n baz -->\n<p>okay</p>",
"should support comments (type 2)"
);
assert_eq!(
- micromark_with_options("<!-- foo -->*bar*\n*baz*", DANGER),
+ micromark_with_options("<!-- foo -->*bar*\n*baz*", &danger),
"<!-- foo -->*bar*\n<p><em>baz</em></p>",
"should support comments w/ start and end on a single line"
);
assert_eq!(
- micromark_with_options("<!-asd-->", DANGER),
+ micromark_with_options("<!-asd-->", &danger),
"<p>&lt;!-asd--&gt;</p>",
"should not support a single dash to start comments"
);
assert_eq!(
- micromark_with_options("<!-->", DANGER),
+ micromark_with_options("<!-->", &danger),
"<!-->",
"should support comments where the start dashes are the end dashes (1)"
);
assert_eq!(
- micromark_with_options("<!--->", DANGER),
+ micromark_with_options("<!--->", &danger),
"<!--->",
"should support comments where the start dashes are the end dashes (2)"
);
assert_eq!(
- micromark_with_options("<!---->", DANGER),
+ micromark_with_options("<!---->", &danger),
"<!---->",
"should support empty comments"
);
// If the `\"` is encoded, we’re in text. If it remains, we’re in HTML.
assert_eq!(
- micromark_with_options("<!--\n->\n\"", DANGER),
+ micromark_with_options("<!--\n->\n\"", &danger),
"<!--\n->\n\"",
"should not end a comment at one dash (`->`)"
);
assert_eq!(
- micromark_with_options("<!--\n-->\n\"", DANGER),
+ micromark_with_options("<!--\n-->\n\"", &danger),
"<!--\n-->\n<p>&quot;</p>",
"should end a comment at two dashes (`-->`)"
);
assert_eq!(
- micromark_with_options("<!--\n--->\n\"", DANGER),
+ micromark_with_options("<!--\n--->\n\"", &danger),
"<!--\n--->\n<p>&quot;</p>",
"should end a comment at three dashes (`--->`)"
);
assert_eq!(
- micromark_with_options("<!--\n---->\n\"", DANGER),
+ micromark_with_options("<!--\n---->\n\"", &danger),
"<!--\n---->\n<p>&quot;</p>",
"should end a comment at four dashes (`---->`)"
);
assert_eq!(
- micromark_with_options(" <!-- foo -->", DANGER),
+ micromark_with_options(" <!-- foo -->", &danger),
" <!-- foo -->",
"should support comments w/ indent"
);
assert_eq!(
- micromark_with_options(" <!-- foo -->", DANGER),
+ micromark_with_options(" <!-- foo -->", &danger),
"<pre><code>&lt;!-- foo --&gt;\n</code></pre>",
"should not support comments w/ a 4 character indent"
);
// Extra.
assert_eq!(
- micromark_with_options("Foo\n<!--", DANGER),
+ micromark_with_options("Foo\n<!--", &danger),
"<p>Foo</p>\n<!--",
"should support interrupting paragraphs w/ comments"
);
assert_eq!(
- micromark_with_options("<!--\n \n \n-->", DANGER),
+ micromark_with_options("<!--\n \n \n-->", &danger),
"<!--\n \n \n-->",
"should support blank lines in comments"
);
assert_eq!(
- micromark_with_options("> <!--\na", DANGER),
+ micromark_with_options("> <!--\na", &danger),
"<blockquote>\n<!--\n</blockquote>\n<p>a</p>",
"should not support lazyness (1)"
);
assert_eq!(
- micromark_with_options("> a\n<!--", DANGER),
+ micromark_with_options("> a\n<!--", &danger),
"<blockquote>\n<p>a</p>\n</blockquote>\n<!--",
"should not support lazyness (2)"
);
@@ -284,45 +301,50 @@ fn html_flow_2_comment() {
#[test]
fn html_flow_3_instruction() {
+ let danger = Options {
+ allow_dangerous_html: true,
+ ..Options::default()
+ };
+
assert_eq!(
- micromark_with_options("<?php\n\n echo \">\";\n\n?>\nokay", DANGER),
+ micromark_with_options("<?php\n\n echo \">\";\n\n?>\nokay", &danger),
"<?php\n\n echo \">\";\n\n?>\n<p>okay</p>",
"should support instructions (type 3)"
);
assert_eq!(
- micromark_with_options("<?>", DANGER),
+ micromark_with_options("<?>", &danger),
"<?>",
"should support empty instructions where the `?` is part of both the start and the end"
);
assert_eq!(
- micromark_with_options("<??>", DANGER),
+ micromark_with_options("<??>", &danger),
"<??>",
"should support empty instructions"
);
// Extra.
assert_eq!(
- micromark_with_options("Foo\n<?", DANGER),
+ micromark_with_options("Foo\n<?", &danger),
"<p>Foo</p>\n<?",
"should support interrupting paragraphs w/ instructions"
);
assert_eq!(
- micromark_with_options("<?\n \n \n?>", DANGER),
+ micromark_with_options("<?\n \n \n?>", &danger),
"<?\n \n \n?>",
"should support blank lines in instructions"
);
assert_eq!(
- micromark_with_options("> <?\na", DANGER),
+ micromark_with_options("> <?\na", &danger),
"<blockquote>\n<?\n</blockquote>\n<p>a</p>",
"should not support lazyness (1)"
);
assert_eq!(
- micromark_with_options("> a\n<?", DANGER),
+ micromark_with_options("> a\n<?", &danger),
"<blockquote>\n<p>a</p>\n</blockquote>\n<?",
"should not support lazyness (2)"
);
@@ -330,33 +352,38 @@ fn html_flow_3_instruction() {
#[test]
fn html_flow_4_declaration() {
+ let danger = Options {
+ allow_dangerous_html: true,
+ ..Options::default()
+ };
+
assert_eq!(
- micromark_with_options("<!DOCTYPE html>", DANGER),
+ micromark_with_options("<!DOCTYPE html>", &danger),
"<!DOCTYPE html>",
"should support declarations (type 4)"
);
assert_eq!(
- micromark_with_options("<!123>", DANGER),
+ micromark_with_options("<!123>", &danger),
"<p>&lt;!123&gt;</p>",
"should not support declarations that start w/o an alpha"
);
assert_eq!(
- micromark_with_options("<!>", DANGER),
+ micromark_with_options("<!>", &danger),
"<p>&lt;!&gt;</p>",
"should not support declarations w/o an identifier"
);
assert_eq!(
- micromark_with_options("<!a>", DANGER),
+ micromark_with_options("<!a>", &danger),
"<!a>",
"should support declarations w/o a single alpha as identifier"
);
// Extra.
assert_eq!(
- micromark_with_options("Foo\n<!d", DANGER),
+ micromark_with_options("Foo\n<!d", &danger),
"<p>Foo</p>\n<!d",
"should support interrupting paragraphs w/ declarations"
);
@@ -364,19 +391,19 @@ fn html_flow_4_declaration() {
// Note about the lower letter:
// <https://github.com/commonmark/commonmark-spec/pull/621>
assert_eq!(
- micromark_with_options("<!a\n \n \n>", DANGER),
+ micromark_with_options("<!a\n \n \n>", &danger),
"<!a\n \n \n>",
"should support blank lines in declarations"
);
assert_eq!(
- micromark_with_options("> <!a\nb", DANGER),
+ micromark_with_options("> <!a\nb", &danger),
"<blockquote>\n<!a\n</blockquote>\n<p>b</p>",
"should not support lazyness (1)"
);
assert_eq!(
- micromark_with_options("> a\n<!b", DANGER),
+ micromark_with_options("> a\n<!b", &danger),
"<blockquote>\n<p>a</p>\n</blockquote>\n<!b",
"should not support lazyness (2)"
);
@@ -384,36 +411,41 @@ fn html_flow_4_declaration() {
#[test]
fn html_flow_5_cdata() {
+ let danger = Options {
+ allow_dangerous_html: true,
+ ..Options::default()
+ };
+
assert_eq!(
micromark_with_options(
"<![CDATA[\nfunction matchwo(a,b)\n{\n if (a < b && a < 0) then {\n return 1;\n\n } else {\n\n return 0;\n }\n}\n]]>\nokay",
- DANGER
+ &danger
),
"<![CDATA[\nfunction matchwo(a,b)\n{\n if (a < b && a < 0) then {\n return 1;\n\n } else {\n\n return 0;\n }\n}\n]]>\n<p>okay</p>",
"should support cdata (type 5)"
);
assert_eq!(
- micromark_with_options("<![CDATA[]]>", DANGER),
+ micromark_with_options("<![CDATA[]]>", &danger),
"<![CDATA[]]>",
"should support empty cdata"
);
assert_eq!(
- micromark_with_options("<![CDATA]]>", DANGER),
+ micromark_with_options("<![CDATA]]>", &danger),
"<p>&lt;![CDATA]]&gt;</p>",
"should not support cdata w/ a missing `[`"
);
assert_eq!(
- micromark_with_options("<![CDATA[]]]>", DANGER),
+ micromark_with_options("<![CDATA[]]]>", &danger),
"<![CDATA[]]]>",
"should support cdata w/ a single `]` as content"
);
// Extra.
assert_eq!(
- micromark_with_options("Foo\n<![CDATA[", DANGER),
+ micromark_with_options("Foo\n<![CDATA[", &danger),
"<p>Foo</p>\n<![CDATA[",
"should support interrupting paragraphs w/ cdata"
);
@@ -421,25 +453,25 @@ fn html_flow_5_cdata() {
// Note: cmjs parses this differently.
// See: <https://github.com/commonmark/commonmark.js/issues/193>
assert_eq!(
- micromark_with_options("<![cdata[]]>", DANGER),
+ micromark_with_options("<![cdata[]]>", &danger),
"<p>&lt;![cdata[]]&gt;</p>",
"should not support lowercase cdata"
);
assert_eq!(
- micromark_with_options("<![CDATA[\n \n \n]]>", DANGER),
+ micromark_with_options("<![CDATA[\n \n \n]]>", &danger),
"<![CDATA[\n \n \n]]>",
"should support blank lines in cdata"
);
assert_eq!(
- micromark_with_options("> <![CDATA[\na", DANGER),
+ micromark_with_options("> <![CDATA[\na", &danger),
"<blockquote>\n<![CDATA[\n</blockquote>\n<p>a</p>",
"should not support lazyness (1)"
);
assert_eq!(
- micromark_with_options("> a\n<![CDATA[", DANGER),
+ micromark_with_options("> a\n<![CDATA[", &danger),
"<blockquote>\n<p>a</p>\n</blockquote>\n<![CDATA[",
"should not support lazyness (2)"
);
@@ -447,10 +479,15 @@ fn html_flow_5_cdata() {
#[test]
fn html_flow_6_basic() {
+ let danger = Options {
+ allow_dangerous_html: true,
+ ..Options::default()
+ };
+
assert_eq!(
micromark_with_options(
"<table><tr><td>\n<pre>\n**Hello**,\n\n_world_.\n</pre>\n</td></tr></table>",
- DANGER
+ &danger
),
"<table><tr><td>\n<pre>\n**Hello**,\n<p><em>world</em>.\n</pre></p>\n</td></tr></table>",
"should support html (basic)"
@@ -467,7 +504,7 @@ fn html_flow_6_basic() {
</table>
okay.",
- DANGER
+ &danger
),
"<table>
<tr>
@@ -481,121 +518,121 @@ okay.",
);
assert_eq!(
- micromark_with_options(" <div>\n *hello*\n <foo><a>", DANGER),
+ micromark_with_options(" <div>\n *hello*\n <foo><a>", &danger),
" <div>\n *hello*\n <foo><a>",
"should support html of type 6 (2)"
);
assert_eq!(
- micromark_with_options("</div>\n*foo*", DANGER),
+ micromark_with_options("</div>\n*foo*", &danger),
"</div>\n*foo*",
"should support html starting w/ a closing tag"
);
assert_eq!(
- micromark_with_options("<DIV CLASS=\"foo\">\n\n*Markdown*\n\n</DIV>", DANGER),
+ micromark_with_options("<DIV CLASS=\"foo\">\n\n*Markdown*\n\n</DIV>", &danger),
"<DIV CLASS=\"foo\">\n<p><em>Markdown</em></p>\n</DIV>",
"should support html w/ markdown in between"
);
assert_eq!(
- micromark_with_options("<div id=\"foo\"\n class=\"bar\">\n</div>", DANGER),
+ micromark_with_options("<div id=\"foo\"\n class=\"bar\">\n</div>", &danger),
"<div id=\"foo\"\n class=\"bar\">\n</div>",
"should support html w/ line endings (1)"
);
assert_eq!(
- micromark_with_options("<div id=\"foo\" class=\"bar\n baz\">\n</div>", DANGER),
+ micromark_with_options("<div id=\"foo\" class=\"bar\n baz\">\n</div>", &danger),
"<div id=\"foo\" class=\"bar\n baz\">\n</div>",
"should support html w/ line endings (2)"
);
assert_eq!(
- micromark_with_options("<div>\n*foo*\n\n*bar*", DANGER),
+ micromark_with_options("<div>\n*foo*\n\n*bar*", &danger),
"<div>\n*foo*\n<p><em>bar</em></p>",
"should support an unclosed html element"
);
assert_eq!(
- micromark_with_options("<div id=\"foo\"\n*hi*", DANGER),
+ micromark_with_options("<div id=\"foo\"\n*hi*", &danger),
"<div id=\"foo\"\n*hi*",
"should support garbage html (1)"
);
assert_eq!(
- micromark_with_options("<div class\nfoo", DANGER),
+ micromark_with_options("<div class\nfoo", &danger),
"<div class\nfoo",
"should support garbage html (2)"
);
assert_eq!(
- micromark_with_options("<div *???-&&&-<---\n*foo*", DANGER),
+ micromark_with_options("<div *???-&&&-<---\n*foo*", &danger),
"<div *???-&&&-<---\n*foo*",
"should support garbage html (3)"
);
assert_eq!(
- micromark_with_options("<div><a href=\"bar\">*foo*</a></div>", DANGER),
+ micromark_with_options("<div><a href=\"bar\">*foo*</a></div>", &danger),
"<div><a href=\"bar\">*foo*</a></div>",
"should support other tags in the opening (1)"
);
assert_eq!(
- micromark_with_options("<table><tr><td>\nfoo\n</td></tr></table>", DANGER),
+ micromark_with_options("<table><tr><td>\nfoo\n</td></tr></table>", &danger),
"<table><tr><td>\nfoo\n</td></tr></table>",
"should support other tags in the opening (2)"
);
assert_eq!(
- micromark_with_options("<div></div>\n``` c\nint x = 33;\n```", DANGER),
+ micromark_with_options("<div></div>\n``` c\nint x = 33;\n```", &danger),
"<div></div>\n``` c\nint x = 33;\n```",
"should include everything ’till a blank line"
);
assert_eq!(
- micromark_with_options("> <div>\n> foo\n\nbar", DANGER),
+ micromark_with_options("> <div>\n> foo\n\nbar", &danger),
"<blockquote>\n<div>\nfoo\n</blockquote>\n<p>bar</p>",
"should support basic tags w/o ending in containers (1)"
);
assert_eq!(
- micromark_with_options("- <div>\n- foo", DANGER),
+ micromark_with_options("- <div>\n- foo", &danger),
"<ul>\n<li>\n<div>\n</li>\n<li>foo</li>\n</ul>",
"should support basic tags w/o ending in containers (2)"
);
assert_eq!(
- micromark_with_options(" <div>", DANGER),
+ micromark_with_options(" <div>", &danger),
" <div>",
"should support basic tags w/ indent"
);
assert_eq!(
- micromark_with_options(" <div>", DANGER),
+ micromark_with_options(" <div>", &danger),
"<pre><code>&lt;div&gt;\n</code></pre>",
"should not support basic tags w/ a 4 character indent"
);
assert_eq!(
- micromark_with_options("Foo\n<div>\nbar\n</div>", DANGER),
+ micromark_with_options("Foo\n<div>\nbar\n</div>", &danger),
"<p>Foo</p>\n<div>\nbar\n</div>",
"should support interrupting paragraphs w/ basic tags"
);
assert_eq!(
- micromark_with_options("<div>\nbar\n</div>\n*foo*", DANGER),
+ micromark_with_options("<div>\nbar\n</div>\n*foo*", &danger),
"<div>\nbar\n</div>\n*foo*",
"should require a blank line to end"
);
assert_eq!(
- micromark_with_options("<div>\n\n*Emphasized* text.\n\n</div>", DANGER),
+ micromark_with_options("<div>\n\n*Emphasized* text.\n\n</div>", &danger),
"<div>\n<p><em>Emphasized</em> text.</p>\n</div>",
"should support interleaving w/ blank lines"
);
assert_eq!(
- micromark_with_options("<div>\n*Emphasized* text.\n</div>", DANGER),
+ micromark_with_options("<div>\n*Emphasized* text.\n</div>", &danger),
"<div>\n*Emphasized* text.\n</div>",
"should not support interleaving w/o blank lines"
);
@@ -603,7 +640,7 @@ okay.",
assert_eq!(
micromark_with_options(
"<table>\n\n<tr>\n\n<td>\nHi\n</td>\n\n</tr>\n\n</table>",
- DANGER
+ &danger
),
"<table>\n<tr>\n<td>\nHi\n</td>\n</tr>\n</table>",
"should support blank lines between adjacent html"
@@ -622,7 +659,7 @@ okay.",
</tr>
</table>",
- DANGER
+ &danger
),
"<table>
<tr>
@@ -636,86 +673,86 @@ okay.",
);
assert_eq!(
- micromark_with_options("</1>", DANGER),
+ micromark_with_options("</1>", &danger),
"<p>&lt;/1&gt;</p>",
"should not support basic tags w/ an incorrect name start character"
);
assert_eq!(
- micromark_with_options("<div", DANGER),
+ micromark_with_options("<div", &danger),
"<div",
"should support an eof directly after a basic tag name"
);
assert_eq!(
- micromark_with_options("<div\n", DANGER),
+ micromark_with_options("<div\n", &danger),
"<div\n",
"should support a line ending directly after a tag name"
);
assert_eq!(
- micromark_with_options("<div ", DANGER),
+ micromark_with_options("<div ", &danger),
"<div ",
"should support an eof after a space directly after a tag name"
);
assert_eq!(
- micromark_with_options("<div/", DANGER),
+ micromark_with_options("<div/", &danger),
"<p>&lt;div/</p>",
"should not support an eof directly after a self-closing slash"
);
assert_eq!(
- micromark_with_options("<div/\n*asd*", DANGER),
+ micromark_with_options("<div/\n*asd*", &danger),
"<p>&lt;div/\n<em>asd</em></p>",
"should not support a line ending after a self-closing slash"
);
assert_eq!(
- micromark_with_options("<div/>", DANGER),
+ micromark_with_options("<div/>", &danger),
"<div/>",
"should support an eof after a self-closing tag"
);
assert_eq!(
- micromark_with_options("<div/>\na", DANGER),
+ micromark_with_options("<div/>\na", &danger),
"<div/>\na",
"should support a line ending after a self-closing tag"
);
assert_eq!(
- micromark_with_options("<div/>a", DANGER),
+ micromark_with_options("<div/>a", &danger),
"<div/>a",
"should support another character after a self-closing tag"
);
assert_eq!(
- micromark_with_options("<div>a", DANGER),
+ micromark_with_options("<div>a", &danger),
"<div>a",
"should support another character after a basic opening tag"
);
// Extra.
assert_eq!(
- micromark_with_options("Foo\n<div/>", DANGER),
+ micromark_with_options("Foo\n<div/>", &danger),
"<p>Foo</p>\n<div/>",
"should support interrupting paragraphs w/ self-closing basic tags"
);
assert_eq!(
- micromark_with_options("<div\n \n \n>", DANGER),
+ micromark_with_options("<div\n \n \n>", &danger),
"<div\n<blockquote>\n</blockquote>",
"should not support blank lines in basic"
);
assert_eq!(
- micromark_with_options("> <div\na", DANGER),
+ micromark_with_options("> <div\na", &danger),
"<blockquote>\n<div\n</blockquote>\n<p>a</p>",
"should not support lazyness (1)"
);
assert_eq!(
- micromark_with_options("> a\n<div", DANGER),
+ micromark_with_options("> a\n<div", &danger),
"<blockquote>\n<p>a</p>\n</blockquote>\n<div",
"should not support lazyness (2)"
);
@@ -723,302 +760,307 @@ okay.",
#[test]
fn html_flow_7_complete() {
+ let danger = Options {
+ allow_dangerous_html: true,
+ ..Options::default()
+ };
+
assert_eq!(
- micromark_with_options("<a href=\"foo\">\n*bar*\n</a>", DANGER),
+ micromark_with_options("<a href=\"foo\">\n*bar*\n</a>", &danger),
"<a href=\"foo\">\n*bar*\n</a>",
"should support complete tags (type 7)"
);
assert_eq!(
- micromark_with_options("<Warning>\n*bar*\n</Warning>", DANGER),
+ micromark_with_options("<Warning>\n*bar*\n</Warning>", &danger),
"<Warning>\n*bar*\n</Warning>",
"should support non-html tag names"
);
assert_eq!(
- micromark_with_options("<i class=\"foo\">\n*bar*\n</i>", DANGER),
+ micromark_with_options("<i class=\"foo\">\n*bar*\n</i>", &danger),
"<i class=\"foo\">\n*bar*\n</i>",
"should support non-“block” html tag names (1)"
);
assert_eq!(
- micromark_with_options("<del>\n*foo*\n</del>", DANGER),
+ micromark_with_options("<del>\n*foo*\n</del>", &danger),
"<del>\n*foo*\n</del>",
"should support non-“block” html tag names (2)"
);
assert_eq!(
- micromark_with_options("</ins>\n*bar*", DANGER),
+ micromark_with_options("</ins>\n*bar*", &danger),
"</ins>\n*bar*",
"should support closing tags"
);
assert_eq!(
- micromark_with_options("<del>\n\n*foo*\n\n</del>", DANGER),
+ micromark_with_options("<del>\n\n*foo*\n\n</del>", &danger),
"<del>\n<p><em>foo</em></p>\n</del>",
"should support interleaving"
);
assert_eq!(
- micromark_with_options("<del>*foo*</del>", DANGER),
+ micromark_with_options("<del>*foo*</del>", &danger),
"<p><del><em>foo</em></del></p>",
"should not support interleaving w/o blank lines"
);
assert_eq!(
- micromark_with_options("<div>\n \nasd", DANGER),
+ micromark_with_options("<div>\n \nasd", &danger),
"<div>\n<p>asd</p>",
"should support interleaving w/ whitespace-only blank lines"
);
assert_eq!(
- micromark_with_options("Foo\n<a href=\"bar\">\nbaz", DANGER),
+ micromark_with_options("Foo\n<a href=\"bar\">\nbaz", &danger),
"<p>Foo\n<a href=\"bar\">\nbaz</p>",
"should not support interrupting paragraphs w/ complete tags"
);
assert_eq!(
- micromark_with_options("<x", DANGER),
+ micromark_with_options("<x", &danger),
"<p>&lt;x</p>",
"should not support an eof directly after a tag name"
);
assert_eq!(
- micromark_with_options("<x/", DANGER),
+ micromark_with_options("<x/", &danger),
"<p>&lt;x/</p>",
"should not support an eof directly after a self-closing slash"
);
assert_eq!(
- micromark_with_options("<x\n", DANGER),
+ micromark_with_options("<x\n", &danger),
"<p>&lt;x</p>\n",
"should not support a line ending directly after a tag name"
);
assert_eq!(
- micromark_with_options("<x ", DANGER),
+ micromark_with_options("<x ", &danger),
"<p>&lt;x</p>",
"should not support an eof after a space directly after a tag name"
);
assert_eq!(
- micromark_with_options("<x/", DANGER),
+ micromark_with_options("<x/", &danger),
"<p>&lt;x/</p>",
"should not support an eof directly after a self-closing slash"
);
assert_eq!(
- micromark_with_options("<x/\n*asd*", DANGER),
+ micromark_with_options("<x/\n*asd*", &danger),
"<p>&lt;x/\n<em>asd</em></p>",
"should not support a line ending after a self-closing slash"
);
assert_eq!(
- micromark_with_options("<x/>", DANGER),
+ micromark_with_options("<x/>", &danger),
"<x/>",
"should support an eof after a self-closing tag"
);
assert_eq!(
- micromark_with_options("<x/>\na", DANGER),
+ micromark_with_options("<x/>\na", &danger),
"<x/>\na",
"should support a line ending after a self-closing tag"
);
assert_eq!(
- micromark_with_options("<x/>a", DANGER),
+ micromark_with_options("<x/>a", &danger),
"<p><x/>a</p>",
"should not support another character after a self-closing tag"
);
assert_eq!(
- micromark_with_options("<x>a", DANGER),
+ micromark_with_options("<x>a", &danger),
"<p><x>a</p>",
"should not support another character after an opening tag"
);
assert_eq!(
- micromark_with_options("<x y>", DANGER),
+ micromark_with_options("<x y>", &danger),
"<x y>",
"should support boolean attributes in a complete tag"
);
assert_eq!(
- micromark_with_options("<x\ny>", DANGER),
+ micromark_with_options("<x\ny>", &danger),
"<p><x\ny></p>",
"should not support a line ending before an attribute name"
);
assert_eq!(
- micromark_with_options("<x\n y>", DANGER),
+ micromark_with_options("<x\n y>", &danger),
"<p><x\ny></p>",
"should not support a line ending w/ whitespace before an attribute name"
);
assert_eq!(
- micromark_with_options("<x\n \ny>", DANGER),
+ micromark_with_options("<x\n \ny>", &danger),
"<p>&lt;x</p>\n<p>y&gt;</p>",
"should not support a line ending w/ whitespace and another line ending before an attribute name"
);
assert_eq!(
- micromark_with_options("<x y\nz>", DANGER),
+ micromark_with_options("<x y\nz>", &danger),
"<p><x y\nz></p>",
"should not support a line ending between attribute names"
);
assert_eq!(
- micromark_with_options("<x y z>", DANGER),
+ micromark_with_options("<x y z>", &danger),
"<x y z>",
"should support whitespace between attribute names"
);
assert_eq!(
- micromark_with_options("<x:y>", DANGER),
+ micromark_with_options("<x:y>", &danger),
"<p>&lt;x:y&gt;</p>",
"should not support a colon in a tag name"
);
assert_eq!(
- micromark_with_options("<x_y>", DANGER),
+ micromark_with_options("<x_y>", &danger),
"<p>&lt;x_y&gt;</p>",
"should not support an underscore in a tag name"
);
assert_eq!(
- micromark_with_options("<x.y>", DANGER),
+ micromark_with_options("<x.y>", &danger),
"<p>&lt;x.y&gt;</p>",
"should not support a dot in a tag name"
);
assert_eq!(
- micromark_with_options("<x :y>", DANGER),
+ micromark_with_options("<x :y>", &danger),
"<x :y>",
"should support a colon to start an attribute name"
);
assert_eq!(
- micromark_with_options("<x _y>", DANGER),
+ micromark_with_options("<x _y>", &danger),
"<x _y>",
"should support an underscore to start an attribute name"
);
assert_eq!(
- micromark_with_options("<x .y>", DANGER),
+ micromark_with_options("<x .y>", &danger),
"<p>&lt;x .y&gt;</p>",
"should not support a dot to start an attribute name"
);
assert_eq!(
- micromark_with_options("<x y:>", DANGER),
+ micromark_with_options("<x y:>", &danger),
"<x y:>",
"should support a colon to end an attribute name"
);
assert_eq!(
- micromark_with_options("<x y_>", DANGER),
+ micromark_with_options("<x y_>", &danger),
"<x y_>",
"should support an underscore to end an attribute name"
);
assert_eq!(
- micromark_with_options("<x y.>", DANGER),
+ micromark_with_options("<x y.>", &danger),
"<x y.>",
"should support a dot to end an attribute name"
);
assert_eq!(
- micromark_with_options("<x y123>", DANGER),
+ micromark_with_options("<x y123>", &danger),
"<x y123>",
"should support numbers to end an attribute name"
);
assert_eq!(
- micromark_with_options("<x data->", DANGER),
+ micromark_with_options("<x data->", &danger),
"<x data->",
"should support a dash to end an attribute name"
);
assert_eq!(
- micromark_with_options("<x y=>", DANGER),
+ micromark_with_options("<x y=>", &danger),
"<p>&lt;x y=&gt;</p>",
"should not upport an initializer w/o a value"
);
assert_eq!(
- micromark_with_options("<x y==>", DANGER),
+ micromark_with_options("<x y==>", &danger),
"<p>&lt;x y==&gt;</p>",
"should not support an equals to as an initializer"
);
assert_eq!(
- micromark_with_options("<x y=z>", DANGER),
+ micromark_with_options("<x y=z>", &danger),
"<x y=z>",
"should support a single character as an unquoted attribute value"
);
assert_eq!(
- micromark_with_options("<x y=\"\">", DANGER),
+ micromark_with_options("<x y=\"\">", &danger),
"<x y=\"\">",
"should support an empty double quoted attribute value"
);
assert_eq!(
- micromark_with_options("<x y=\"\">", DANGER),
+ micromark_with_options("<x y=\"\">", &danger),
"<x y=\"\">",
"should support an empty single quoted attribute value"
);
assert_eq!(
- micromark_with_options("<x y=\"\n\">", DANGER),
+ micromark_with_options("<x y=\"\n\">", &danger),
"<p><x y=\"\n\"></p>",
"should not support a line ending in a double quoted attribute value"
);
assert_eq!(
- micromark_with_options("<x y=\"\n\">", DANGER),
+ micromark_with_options("<x y=\"\n\">", &danger),
"<p><x y=\"\n\"></p>",
"should not support a line ending in a single quoted attribute value"
);
assert_eq!(
- micromark_with_options("<w x=y\nz>", DANGER),
+ micromark_with_options("<w x=y\nz>", &danger),
"<p><w x=y\nz></p>",
"should not support a line ending in/after an unquoted attribute value"
);
assert_eq!(
- micromark_with_options("<w x=y\"z>", DANGER),
+ micromark_with_options("<w x=y\"z>", &danger),
"<p>&lt;w x=y&quot;z&gt;</p>",
"should not support a double quote in/after an unquoted attribute value"
);
assert_eq!(
- micromark_with_options("<w x=y'z>", DANGER),
+ micromark_with_options("<w x=y'z>", &danger),
"<p>&lt;w x=y'z&gt;</p>",
"should not support a single quote in/after an unquoted attribute value"
);
assert_eq!(
- micromark_with_options("<x y=\"\"z>", DANGER),
+ micromark_with_options("<x y=\"\"z>", &danger),
"<p>&lt;x y=&quot;&quot;z&gt;</p>",
"should not support an attribute after a double quoted attribute value"
);
assert_eq!(
- micromark_with_options("<x>\n \n \n>", DANGER),
+ micromark_with_options("<x>\n \n \n>", &danger),
"<x>\n<blockquote>\n</blockquote>",
"should not support blank lines in complete"
);
assert_eq!(
- micromark_with_options("> <a>\n*bar*", DANGER),
+ micromark_with_options("> <a>\n*bar*", &danger),
"<blockquote>\n<a>\n</blockquote>\n<p><em>bar</em></p>",
"should not support lazyness (1)"
);
assert_eq!(
- micromark_with_options("> a\n<a>", DANGER),
+ micromark_with_options("> a\n<a>", &danger),
"<blockquote>\n<p>a</p>\n</blockquote>\n<a>",
"should not support lazyness (2)"
);