aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-06-08 15:52:16 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-06-08 15:52:16 +0200
commit4c06c8554c35887f8f5147783953b2b7e7c2327f (patch)
tree1b2463848a3ae4c645f7f1a325877ee829ab65c5 /tests
downloadmarkdown-rs-4c06c8554c35887f8f5147783953b2b7e7c2327f.tar.gz
markdown-rs-4c06c8554c35887f8f5147783953b2b7e7c2327f.tar.bz2
markdown-rs-4c06c8554c35887f8f5147783953b2b7e7c2327f.zip
.
Diffstat (limited to 'tests')
-rw-r--r--tests/code_fenced.rs266
-rw-r--r--tests/code_indented.rs196
-rw-r--r--tests/heading_atx.rs208
-rw-r--r--tests/html_flow.rs1058
-rw-r--r--tests/lib.rs8
-rw-r--r--tests/thematic_break.rs181
6 files changed, 1917 insertions, 0 deletions
diff --git a/tests/code_fenced.rs b/tests/code_fenced.rs
new file mode 100644
index 0000000..46fa9cb
--- /dev/null
+++ b/tests/code_fenced.rs
@@ -0,0 +1,266 @@
+extern crate micromark;
+use micromark::micromark;
+
+#[test]
+fn code_fenced() {
+ assert_eq!(
+ micromark("```\n<\n >\n```"),
+ "<pre><code>&lt;\n &gt;\n</code></pre>",
+ "should support fenced code w/ grave accents"
+ );
+
+ assert_eq!(
+ micromark("~~~\n<\n >\n~~~"),
+ "<pre><code>&lt;\n &gt;\n</code></pre>",
+ "should support fenced code w/ tildes"
+ );
+
+ // To do: code (text).
+ // assert_eq!(
+ // micromark("``\nfoo\n``"),
+ // "<p><code>foo</code></p>",
+ // "should not support fenced code w/ less than three markers"
+ // );
+
+ assert_eq!(
+ micromark("```\naaa\n~~~\n```"),
+ "<pre><code>aaa\n~~~\n</code></pre>",
+ "should not support a tilde closing sequence for a grave accent opening sequence"
+ );
+
+ assert_eq!(
+ micromark("~~~\naaa\n```\n~~~"),
+ "<pre><code>aaa\n```\n</code></pre>",
+ "should not support a grave accent closing sequence for a tilde opening sequence"
+ );
+
+ assert_eq!(
+ micromark("````\naaa\n```\n``````"),
+ "<pre><code>aaa\n```\n</code></pre>",
+ "should support a closing sequence longer, but not shorter than, the opening"
+ );
+
+ assert_eq!(
+ micromark("~~~~\naaa\n~~~\n~~~~"),
+ "<pre><code>aaa\n~~~\n</code></pre>",
+ "should support a closing sequence equal to, but not shorter than, the opening"
+ );
+
+ assert_eq!(
+ micromark("```"),
+ "<pre><code></code></pre>\n",
+ "should support an eof right after an opening sequence"
+ );
+
+ assert_eq!(
+ micromark("`````\n\n```\naaa\n"),
+ "<pre><code>\n```\naaa\n</code></pre>\n",
+ "should support an eof somewhere in content"
+ );
+
+ // To do: blockquote.
+ // assert_eq!(
+ // micromark("> ```\n> aaa\n\nbbb"),
+ // "<blockquote>\n<pre><code>aaa\n</code></pre>\n</blockquote>\n<p>bbb</p>",
+ // "should support no closing sequence in a block quote"
+ // );
+
+ assert_eq!(
+ micromark("```\n\n \n```"),
+ "<pre><code>\n \n</code></pre>",
+ "should support blank lines in fenced code"
+ );
+
+ assert_eq!(
+ micromark("```\n```"),
+ "<pre><code></code></pre>",
+ "should support empty fenced code"
+ );
+
+ assert_eq!(
+ micromark(" ```\n aaa\naaa\n```"),
+ "<pre><code>aaa\naaa\n</code></pre>",
+ "should remove up to one space from the content if the opening sequence is indented w/ 1 space"
+ );
+
+ assert_eq!(
+ micromark(" ```\naaa\n aaa\naaa\n ```"),
+ "<pre><code>aaa\naaa\naaa\n</code></pre>",
+ "should remove up to two space from the content if the opening sequence is indented w/ 2 spaces"
+ );
+
+ assert_eq!(
+ micromark(" ```\n aaa\n aaa\n aaa\n ```"),
+ "<pre><code>aaa\n aaa\naaa\n</code></pre>",
+ "should remove up to three space from the content if the opening sequence is indented w/ 3 spaces"
+ );
+
+ assert_eq!(
+ micromark(" ```\n aaa\n ```"),
+ "<pre><code>```\naaa\n```\n</code></pre>",
+ "should not support indenteding the opening sequence w/ 4 spaces"
+ );
+
+ assert_eq!(
+ micromark("```\naaa\n ```"),
+ "<pre><code>aaa\n</code></pre>",
+ "should support an indented closing sequence"
+ );
+
+ assert_eq!(
+ micromark(" ```\naaa\n ```"),
+ "<pre><code>aaa\n</code></pre>",
+ "should support a differently indented closing sequence than the opening sequence"
+ );
+
+ assert_eq!(
+ micromark("```\naaa\n ```\n"),
+ "<pre><code>aaa\n ```\n</code></pre>\n",
+ "should not support an indented closing sequence w/ 4 spaces"
+ );
+
+ // To do: code (text).
+ // assert_eq!(
+ // micromark("``` ```\naaa"),
+ // "<p><code> </code>\naaa</p>",
+ // "should not support grave accents in the opening fence after the opening sequence"
+ // );
+
+ assert_eq!(
+ micromark("~~~~~~\naaa\n~~~ ~~\n"),
+ "<pre><code>aaa\n~~~ ~~\n</code></pre>\n",
+ "should not support spaces in the closing sequence"
+ );
+
+ assert_eq!(
+ micromark("foo\n```\nbar\n```\nbaz"),
+ "<p>foo</p>\n<pre><code>bar\n</code></pre>\n<p>baz</p>",
+ "should support interrupting paragraphs"
+ );
+
+ // To do: setext.
+ // assert_eq!(
+ // micromark("foo\n---\n~~~\nbar\n~~~\n# baz"),
+ // "<h2>foo</h2>\n<pre><code>bar\n</code></pre>\n<h1>baz</h1>",
+ // "should support interrupting other content"
+ // );
+
+ assert_eq!(
+ micromark("```ruby\ndef foo(x)\n return 3\nend\n```"),
+ "<pre><code class=\"language-ruby\">def foo(x)\n return 3\nend\n</code></pre>",
+ "should support the info string as a `language-` class (1)"
+ );
+
+ assert_eq!(
+ micromark("````;\n````"),
+ "<pre><code class=\"language-;\"></code></pre>",
+ "should support the info string as a `language-` class (2)"
+ );
+
+ assert_eq!(
+ micromark("~~~~ ruby startline=3 $%@#$\ndef foo(x)\n return 3\nend\n~~~~~~~"),
+ "<pre><code class=\"language-ruby\">def foo(x)\n return 3\nend\n</code></pre>",
+ "should support the info string as a `language-` class, but not the meta string"
+ );
+
+ // To do: code (text).
+ // assert_eq!(
+ // micromark("``` aa ```\nfoo"),
+ // "<p><code>aa</code>\nfoo</p>",
+ // "should not support grave accents in the meta string"
+ // );
+
+ assert_eq!(
+ micromark("~~~ aa ``` ~~~\nfoo\n~~~"),
+ "<pre><code class=\"language-aa\">foo\n</code></pre>",
+ "should support grave accents and tildes in the meta string of tilde fenced code"
+ );
+
+ assert_eq!(
+ micromark("```\n``` aaa\n```"),
+ "<pre><code>``` aaa\n</code></pre>",
+ "should not support info string on closing sequences"
+ );
+
+ // Our own:
+ assert_eq!(
+ micromark("``` "),
+ "<pre><code></code></pre>\n",
+ "should support an eof after whitespace, after the start fence sequence"
+ );
+
+ assert_eq!(
+ micromark("``` js\nalert(1)\n```"),
+ "<pre><code class=\"language-js\">alert(1)\n</code></pre>",
+ "should support whitespace between the sequence and the info string"
+ );
+
+ assert_eq!(
+ micromark("```js"),
+ "<pre><code class=\"language-js\"></code></pre>\n",
+ "should support an eof after the info string"
+ );
+
+ assert_eq!(
+ micromark("``` js \nalert(1)\n```"),
+ "<pre><code class=\"language-js\">alert(1)\n</code></pre>",
+ "should support whitespace after the info string"
+ );
+
+ assert_eq!(
+ micromark("```\n "),
+ "<pre><code> \n</code></pre>\n",
+ "should support an eof after whitespace in content"
+ );
+
+ assert_eq!(
+ micromark(" ```\n "),
+ "<pre><code></code></pre>\n",
+ "should support an eof in the prefix, in content"
+ );
+
+ // To do: strings.
+ // assert_eq!(
+ // micromark("```j\\+s&copy;"),
+ // "<pre><code class=\"language-j+s©\"></code></pre>\n",
+ // "should support character escapes and character references in info strings"
+ // );
+
+ assert_eq!(
+ micromark(" ```\naaa\n ```"),
+ "<pre><code>aaa\n ```\n</code></pre>\n",
+ "should not support a closing sequence w/ too much indent, regardless of opening sequence (1)"
+ );
+
+ // To do: blockquote.
+ // assert_eq!(
+ // micromark("> ```\n>\n>\n>\n\na"),
+ // "<blockquote>\n<pre><code>\n\n\n</code></pre>\n</blockquote>\n<p>a</p>",
+ // "should not support a closing sequence w/ too much indent, regardless of opening sequence (2)"
+ // );
+
+ // assert_eq!(
+ // micromark("> ```a\nb"),
+ // "<blockquote>\n<pre><code class=\"language-a\"></code></pre>\n</blockquote>\n<p>b</p>",
+ // "should not support lazyness (1)"
+ // );
+
+ // assert_eq!(
+ // micromark("> a\n```b"),
+ // "<blockquote>\n<p>a</p>\n</blockquote>\n<pre><code class=\"language-b\"></code></pre>\n",
+ // "should not support lazyness (2)"
+ // );
+
+ // assert_eq!(
+ // micromark("> ```a\n```"),
+ // "<blockquote>\n<pre><code class=\"language-a\"></code></pre>\n</blockquote>\n<pre><code></code></pre>\n",
+ // "should not support lazyness (3)"
+ // );
+
+ // To do: extensions.
+ // assert_eq!(
+ // micromark("```", {extensions: [{disable: {null: ["codeFenced"]}}]}),
+ // "<p>```</p>",
+ // "should support turning off code (fenced)"
+ // );
+}
diff --git a/tests/code_indented.rs b/tests/code_indented.rs
new file mode 100644
index 0000000..f5926c0
--- /dev/null
+++ b/tests/code_indented.rs
@@ -0,0 +1,196 @@
+extern crate micromark;
+use micromark::micromark;
+
+#[test]
+fn code_indented() {
+ assert_eq!(
+ micromark(" a simple\n indented code block"),
+ "<pre><code>a simple\n indented code block\n</code></pre>",
+ "should support indented code"
+ );
+
+ // To do: list.
+ // assert_eq!(
+ // micromark(" - foo\n\n bar"),
+ // "<ul>\n<li>\n<p>foo</p>\n<p>bar</p>\n</li>\n</ul>",
+ // "should prefer list item content over indented code (1)"
+ // );
+
+ // assert_eq!(
+ // micromark("1. foo\n\n - bar"),
+ // "<ol>\n<li>\n<p>foo</p>\n<ul>\n<li>bar</li>\n</ul>\n</li>\n</ol>",
+ // "should prefer list item content over indented code (2)"
+ // );
+
+ assert_eq!(
+ micromark(" <a/>\n *hi*\n\n - one"),
+ "<pre><code>&lt;a/&gt;\n*hi*\n\n- one\n</code></pre>",
+ "should support blank lines in indented code (1)"
+ );
+
+ assert_eq!(
+ micromark(" chunk1\n\n chunk2\n \n \n \n chunk3"),
+ "<pre><code>chunk1\n\nchunk2\n\n\n\nchunk3\n</code></pre>",
+ "should support blank lines in indented code (2)"
+ );
+
+ assert_eq!(
+ micromark(" chunk1\n \n chunk2"),
+ "<pre><code>chunk1\n \n chunk2\n</code></pre>",
+ "should support blank lines in indented code (3)"
+ );
+
+ // To do: paragraphs.
+ // assert_eq!(
+ // micromark("Foo\n bar"),
+ // "<p>Foo\nbar</p>",
+ // "should not support interrupting paragraphs"
+ // );
+
+ // To do: paragraphs.
+ // assert_eq!(
+ // micromark(" foo\nbar"),
+ // "<pre><code>foo\n</code></pre>\n<p>bar</p>",
+ // "should support paragraphs directly after indented code"
+ // );
+
+ // To do: setext.
+ // assert_eq!(
+ // micromark("# Heading\n foo\nHeading\n------\n foo\n----"),
+ // "<h1>Heading</h1>\n<pre><code>foo\n</code></pre>\n<h2>Heading</h2>\n<pre><code>foo\n</code></pre>\n<hr />",
+ // "should mix w/ other content"
+ // );
+
+ assert_eq!(
+ micromark(" foo\n bar"),
+ "<pre><code> foo\nbar\n</code></pre>",
+ "should support extra whitespace on the first line"
+ );
+
+ assert_eq!(
+ micromark("\n \n foo\n "),
+ "<pre><code>foo\n</code></pre>",
+ "should not support initial blank lines"
+ );
+
+ assert_eq!(
+ micromark(" foo "),
+ "<pre><code>foo \n</code></pre>",
+ "should support trailing whitespace"
+ );
+
+ // To do: blockquote.
+ // assert_eq!(
+ // micromark("> a\nb"),
+ // "<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<p>b</p>",
+ // "should not support lazyness (1)"
+ // );
+
+ // assert_eq!(
+ // micromark("> a\n b"),
+ // "<blockquote>\n<p>a\nb</p>\n</blockquote>",
+ // "should not support lazyness (2)"
+ // );
+
+ // assert_eq!(
+ // micromark("> a\n b"),
+ // "<blockquote>\n<p>a\nb</p>\n</blockquote>",
+ // "should not support lazyness (3)"
+ // );
+
+ // assert_eq!(
+ // micromark("> a\n b"),
+ // "<blockquote>\n<p>a\nb</p>\n</blockquote>",
+ // "should not support lazyness (4)"
+ // );
+
+ // assert_eq!(
+ // micromark("> a\n b"),
+ // "<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<pre><code>b\n</code></pre>",
+ // "should not support lazyness (5)"
+ // );
+
+ // assert_eq!(
+ // micromark("> a\n b"),
+ // "<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<pre><code> b\n</code></pre>",
+ // "should not support lazyness (6)"
+ // );
+
+ // assert_eq!(
+ // micromark("> a\n b"),
+ // "<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<pre><code> b\n</code></pre>",
+ // "should not support lazyness (7)"
+ // );
+
+ // To do: extensions.
+ // assert_eq!(
+ // micromark(" a", {extensions: [{disable: {null: ["codeIndented"]}}]}),
+ // "<p>a</p>",
+ // "should support turning off code (indented, 1)"
+ // );
+
+ // assert_eq!(
+ // micromark("> a\n b", {
+ // extensions: [{disable: {null: ["codeIndented"]}}]
+ // }),
+ // "<blockquote>\n<p>a\nb</p>\n</blockquote>",
+ // "should support turning off code (indented, 2)"
+ // );
+
+ // assert_eq!(
+ // micromark("- a\n b", {
+ // extensions: [{disable: {null: ["codeIndented"]}}]
+ // }),
+ // "<ul>\n<li>a\nb</li>\n</ul>",
+ // "should support turning off code (indented, 3)"
+ // );
+
+ // assert_eq!(
+ // micromark("- a\n - b", {
+ // extensions: [{disable: {null: ["codeIndented"]}}]
+ // }),
+ // "<ul>\n<li>a\n<ul>\n<li>b</li>\n</ul>\n</li>\n</ul>",
+ // "should support turning off code (indented, 4)"
+ // );
+
+ // assert_eq!(
+ // micromark("- a\n - b", {
+ // extensions: [{disable: {null: ["codeIndented"]}}]
+ // }),
+ // "<ul>\n<li>a\n<ul>\n<li>b</li>\n</ul>\n</li>\n</ul>",
+ // "should support turning off code (indented, 5)"
+ // );
+
+ // assert_eq!(
+ // micromark("```\na\n ```", {
+ // extensions: [{disable: {null: ["codeIndented"]}}]
+ // }),
+ // "<pre><code>a\n</code></pre>",
+ // "should support turning off code (indented, 6)"
+ // );
+
+ // assert_eq!(
+ // micromark("a <?\n ?>", {
+ // allowDangerousHtml: true,
+ // extensions: [{disable: {null: ["codeIndented"]}}]
+ // }),
+ // "<p>a <?\n?></p>",
+ // "should support turning off code (indented, 7)"
+ // );
+
+ // assert_eq!(
+ // micromark("- Foo\n---", {
+ // extensions: [{disable: {null: ["codeIndented"]}}]
+ // }),
+ // "<ul>\n<li>Foo</li>\n</ul>\n<hr />",
+ // "should support turning off code (indented, 8)"
+ // );
+
+ // assert_eq!(
+ // micromark("- Foo\n ---", {
+ // extensions: [{disable: {null: ["codeIndented"]}}]
+ // }),
+ // "<ul>\n<li>\n<h2>Foo</h2>\n</li>\n</ul>",
+ // "should support turning off code (indented, 9)"
+ // );
+}
diff --git a/tests/heading_atx.rs b/tests/heading_atx.rs
new file mode 100644
index 0000000..b75d058
--- /dev/null
+++ b/tests/heading_atx.rs
@@ -0,0 +1,208 @@
+extern crate micromark;
+use micromark::micromark;
+#[test]
+fn heading_atx() {
+ assert_eq!(
+ micromark("# foo"),
+ "<h1>foo</h1>",
+ "should support a heading w/ rank 1"
+ );
+
+ assert_eq!(
+ micromark("## foo"),
+ "<h2>foo</h2>",
+ "should support a heading w/ rank 2"
+ );
+
+ assert_eq!(
+ micromark("### foo"),
+ "<h3>foo</h3>",
+ "should support a heading w/ rank 3"
+ );
+
+ assert_eq!(
+ micromark("#### foo"),
+ "<h4>foo</h4>",
+ "should support a heading w/ rank 4"
+ );
+
+ assert_eq!(
+ micromark("##### foo"),
+ "<h5>foo</h5>",
+ "should support a heading w/ rank 5"
+ );
+
+ assert_eq!(
+ micromark("###### foo"),
+ "<h6>foo</h6>",
+ "should support a heading w/ rank 6"
+ );
+
+ assert_eq!(
+ micromark("####### foo"),
+ "<p>####### foo</p>",
+ "should not support a heading w/ rank 7"
+ );
+
+ assert_eq!(
+ micromark("#5 bolt"),
+ "<p>#5 bolt</p>",
+ "should not support a heading for a number sign not followed by whitespace (1)"
+ );
+
+ assert_eq!(
+ micromark("#hashtag"),
+ "<p>#hashtag</p>",
+ "should not support a heading for a number sign not followed by whitespace (2)"
+ );
+
+ // To do: phrasing.
+ // assert_eq!(
+ // micromark("\\## foo"),
+ // "<p>## foo</p>",
+ // "should not support a heading for an escaped number sign"
+ // );
+
+ // assert_eq!(
+ // micromark("# foo *bar* \\*baz\\*"),
+ // "<h1>foo <em>bar</em> *baz*</h1>",
+ // "should support text content in headings"
+ // );
+
+ assert_eq!(
+ micromark("# foo "),
+ "<h1>foo</h1>",
+ "should support arbitrary initial and final whitespace"
+ );
+
+ assert_eq!(
+ micromark(" ### foo"),
+ "<h3>foo</h3>",
+ "should support an initial space"
+ );
+
+ assert_eq!(
+ micromark(" ## foo"),
+ "<h2>foo</h2>",
+ "should support two initial spaces"
+ );
+
+ assert_eq!(
+ micromark(" # foo"),
+ "<h1>foo</h1>",
+ "should support three initial spaces"
+ );
+
+ assert_eq!(
+ micromark(" # foo"),
+ "<pre><code># foo\n</code></pre>",
+ "should not support four initial spaces"
+ );
+
+ // To do: lazy.
+ // assert_eq!(
+ // micromark("foo\n # bar"),
+ // "<p>foo\n# bar</p>",
+ // "should not support four initial spaces when interrupting"
+ // );
+
+ assert_eq!(
+ micromark("## foo ##"),
+ "<h2>foo</h2>",
+ "should support a closing sequence (1)"
+ );
+
+ assert_eq!(
+ micromark(" ### bar ###"),
+ "<h3>bar</h3>",
+ "should support a closing sequence (2)"
+ );
+
+ assert_eq!(
+ micromark("# foo ##################################"),
+ "<h1>foo</h1>",
+ "should support a closing sequence w/ an arbitrary number of number signs (1)"
+ );
+
+ assert_eq!(
+ micromark("##### foo ##"),
+ "<h5>foo</h5>",
+ "should support a closing sequence w/ an arbitrary number of number signs (2)"
+ );
+
+ assert_eq!(
+ micromark("### foo ### "),
+ "<h3>foo</h3>",
+ "should support trailing whitespace after a closing sequence"
+ );
+
+ assert_eq!(
+ micromark("### foo ### b"),
+ "<h3>foo ### b</h3>",
+ "should not support other content after a closing sequence"
+ );
+
+ assert_eq!(
+ micromark("# foo#"),
+ "<h1>foo#</h1>",
+ "should not support a closing sequence w/o whitespace before it"
+ );
+
+ // Phrasing.
+ // assert_eq!(
+ // micromark("### foo \\###"),
+ // "<h3>foo ###</h3>",
+ // "should not support an “escaped” closing sequence (1)"
+ // );
+
+ // assert_eq!(
+ // micromark("## foo #\\##"),
+ // "<h2>foo ###</h2>",
+ // "should not support an “escaped” closing sequence (2)"
+ // );
+
+ // assert_eq!(
+ // micromark("# foo \\#"),
+ // "<h1>foo #</h1>",
+ // "should not support an “escaped” closing sequence (3)"
+ // );
+
+ assert_eq!(
+ micromark("****\n## foo\n****"),
+ "<hr />\n<h2>foo</h2>\n<hr />",
+ "should support atx headings when not surrounded by blank lines"
+ );
+
+ assert_eq!(
+ micromark("Foo bar\n# baz\nBar foo"),
+ "<p>Foo bar</p>\n<h1>baz</h1>\n<p>Bar foo</p>",
+ "should support atx headings interrupting paragraphs"
+ );
+
+ // Line endings.
+ assert_eq!(
+ micromark("## \n#\n### ###"),
+ "<h2></h2>\n<h1></h1>\n<h3></h3>",
+ "should support empty atx headings"
+ );
+
+ // To do: block quote.
+ // assert_eq!(
+ // micromark("> #\na"),
+ // "<blockquote>\n<h1></h1>\n</blockquote>\n<p>a</p>",
+ // "should not support lazyness (1)"
+ // );
+
+ // assert_eq!(
+ // micromark("> a\n#"),
+ // "<blockquote>\n<p>a</p>\n</blockquote>\n<h1></h1>",
+ // "should not support lazyness (2)"
+ // );
+
+ // Extensions:
+ // assert_eq!(
+ // micromark("# a", {extensions: [{disable: {null: ["headingAtx"]}}]}),
+ // "<p># a</p>",
+ // "should support turning off heading (atx)"
+ // );
+}
diff --git a/tests/html_flow.rs b/tests/html_flow.rs
new file mode 100644
index 0000000..51d1a2a
--- /dev/null
+++ b/tests/html_flow.rs
@@ -0,0 +1,1058 @@
+extern crate micromark;
+use micromark::{micromark, micromark_with_options, CompileOptions};
+
+const DANGER: &CompileOptions = &CompileOptions {
+ allow_dangerous_html: true,
+};
+
+#[test]
+fn html_flow() {
+ assert_eq!(
+ micromark("<!-- asd -->"),
+ "&lt;!-- asd --&gt;",
+ "should support a heading w/ rank 1"
+ );
+
+ assert_eq!(
+ micromark_with_options("<!-- asd -->", DANGER),
+ "<!-- asd -->",
+ "should support a heading w/ rank 1"
+ );
+
+ // To do: extensions.
+ // assert_eq!(
+ // micromark_with_options("<x>", {extensions: [{disable: {null: ["htmlFlow"]}}]}),
+ // "<p>&lt;x&gt;</p>",
+ // "should support turning off html (flow)"
+ // );
+}
+
+#[test]
+fn html_flow_1_raw() {
+ assert_eq!(
+ micromark_with_options(
+ "<pre language=\"haskell\"><code>
+import Text.HTML.TagSoup
+
+main :: IO ()
+main = print $ parseTags tags
+</code></pre>
+okay",
+ DANGER
+ ),
+ "<pre language=\"haskell\"><code>
+import Text.HTML.TagSoup
+
+main :: IO ()
+main = print $ parseTags tags
+</code></pre>
+<p>okay</p>",
+ "should support raw pre tags (type 1)"
+ );
+
+ assert_eq!(
+ micromark_with_options(
+ "<script type=\"text/javascript\">
+// JavaScript example
+
+document.getElementById(\"demo\").innerHTML = \"Hello JavaScript!\";
+</script>
+okay",
+ DANGER
+ ),
+ "<script type=\"text/javascript\">
+// JavaScript example
+
+document.getElementById(\"demo\").innerHTML = \"Hello JavaScript!\";
+</script>
+<p>okay</p>",
+ "should support raw script tags"
+ );
+
+ assert_eq!(
+ micromark_with_options(
+ "<style
+ type=\"text/css\">
+h1 {color:red;}
+
+p {color:blue;}
+</style>
+okay",
+ DANGER
+ ),
+ "<style
+ type=\"text/css\">
+h1 {color:red;}
+
+p {color:blue;}
+</style>
+<p>okay</p>",
+ "should support raw style tags"
+ );
+
+ assert_eq!(
+ 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"
+ );
+
+ // To do: phrasing.
+ // assert_eq!(
+ // 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),
+ "<script>\nfoo\n</script>1. *bar*",
+ "should support raw tags w/ more data on ending line"
+ );
+
+ assert_eq!(
+ micromark_with_options("<script", DANGER),
+ "<script",
+ "should support an eof directly after a raw tag name"
+ );
+
+ // To do: paragraphs.
+ // assert_eq!(
+ // 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),
+ "<p>&lt;script/</p>",
+ "should not support an eof after a self-closing slash"
+ );
+
+ // To do: phrasing.
+ // assert_eq!(
+ // 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),
+ "<script/>",
+ "should support an eof after a self-closing tag"
+ );
+
+ assert_eq!(
+ micromark_with_options("<script/>\na", DANGER),
+ "<script/>\na",
+ "should support a line ending after a self-closing tag"
+ );
+
+ // To do: html (text).
+ // assert_eq!(
+ // 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),
+ "<script>a",
+ "should support other characters after a raw opening tag"
+ );
+
+ // Extra.
+ assert_eq!(
+ 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),
+ "<script>\n \n \n</script>",
+ "should support blank lines in raw"
+ );
+
+ // To do: block quote.
+ // assert_eq!(
+ // 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),
+ // "<blockquote>\n<p>a</p>\n</blockquote>\n<script>",
+ // "should not support lazyness (2)"
+ // );
+}
+
+#[test]
+fn html_flow_2_comment() {
+ assert_eq!(
+ micromark_with_options("<!-- Foo\n\nbar\n baz -->\nokay", DANGER),
+ "<!-- Foo\n\nbar\n baz -->\n<p>okay</p>",
+ "should support comments (type 2)"
+ );
+
+ // To do: phrasing.
+ // assert_eq!(
+ // 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),
+ "<p>&lt;!-asd--&gt;</p>",
+ "should not support a single dash to start comments"
+ );
+
+ assert_eq!(
+ micromark_with_options("<!-->", DANGER),
+ "<!-->",
+ "should support comments where the start dashes are the end dashes (1)"
+ );
+
+ assert_eq!(
+ micromark_with_options("<!--->", DANGER),
+ "<!--->",
+ "should support comments where the start dashes are the end dashes (2)"
+ );
+
+ assert_eq!(
+ 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),
+ "<!--\n->\n\"",
+ "should not end a comment at one dash (`->`)"
+ );
+ assert_eq!(
+ 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),
+ "<!--\n--->\n<p>&quot;</p>",
+ "should end a comment at three dashes (`--->`)"
+ );
+ assert_eq!(
+ 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),
+ " <!-- foo -->",
+ "should support comments w/ indent"
+ );
+
+ assert_eq!(
+ 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),
+ "<p>Foo</p>\n<!--",
+ "should support interrupting paragraphs w/ comments"
+ );
+
+ assert_eq!(
+ micromark_with_options("<!--\n \n \n-->", DANGER),
+ "<!--\n \n \n-->",
+ "should support blank lines in comments"
+ );
+
+ // To do: blockquote.
+ // assert_eq!(
+ // 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),
+ // "<blockquote>\n<p>a</p>\n</blockquote>\n<!--",
+ // "should not support lazyness (2)"
+ // );
+}
+
+#[test]
+fn html_flow_3_instruction() {
+ assert_eq!(
+ 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),
+ "<?>",
+ "should support empty instructions where the `?` is part of both the start and the end"
+ );
+
+ assert_eq!(
+ micromark_with_options("<??>", DANGER),
+ "<??>",
+ "should support empty instructions"
+ );
+
+ // Extra.
+ assert_eq!(
+ 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),
+ "<?\n \n \n?>",
+ "should support blank lines in instructions"
+ );
+
+ // To do: blockquote.
+ // assert_eq!(
+ // 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),
+ // "<blockquote>\n<p>a</p>\n</blockquote>\n<?",
+ // "should not support lazyness (2)"
+ // );
+}
+
+#[test]
+fn html_flow_4_declaration() {
+ assert_eq!(
+ micromark_with_options("<!DOCTYPE html>", DANGER),
+ "<!DOCTYPE html>",
+ "should support declarations (type 4)"
+ );
+
+ assert_eq!(
+ 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),
+ "<p>&lt;!&gt;</p>",
+ "should not support declarations w/o an identifier"
+ );
+
+ assert_eq!(
+ 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),
+ "<p>Foo</p>\n<!d",
+ "should support interrupting paragraphs w/ declarations"
+ );
+
+ // Note about the lower letter:
+ // <https://github.com/commonmark/commonmark-spec/pull/621>
+ assert_eq!(
+ micromark_with_options("<!a\n \n \n>", DANGER),
+ "<!a\n \n \n>",
+ "should support blank lines in declarations"
+ );
+
+ // To do: blockquote.
+ // assert_eq!(
+ // 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),
+ // "<blockquote>\n<p>a</p>\n</blockquote>\n<!b",
+ // "should not support lazyness (2)"
+ // );
+}
+
+#[test]
+fn html_flow_5_cdata() {
+ 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
+ ),
+ "<![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),
+ "<![CDATA[]]>",
+ "should support empty cdata"
+ );
+
+ assert_eq!(
+ micromark_with_options("<![CDATA]]>", DANGER),
+ "<p>&lt;![CDATA]]&gt;</p>",
+ "should not support cdata w/ a missing `[`"
+ );
+
+ assert_eq!(
+ micromark_with_options("<![CDATA[]]]>", DANGER),
+ "<![CDATA[]]]>",
+ "should support cdata w/ a single `]` as content"
+ );
+
+ // Extra.
+ assert_eq!(
+ micromark_with_options("Foo\n<![CDATA[", DANGER),
+ "<p>Foo</p>\n<![CDATA[",
+ "should support interrupting paragraphs w/ cdata"
+ );
+
+ // Note: cmjs parses this differently.
+ // See: <https://github.com/commonmark/commonmark.js/issues/193>
+ assert_eq!(
+ 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),
+ "<![CDATA[\n \n \n]]>",
+ "should support blank lines in cdata"
+ );
+
+ // To do: blockquote.
+ // assert_eq!(
+ // 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),
+ // "<blockquote>\n<p>a</p>\n</blockquote>\n<![CDATA[",
+ // "should not support lazyness (2)"
+ // );
+}
+
+#[test]
+fn html_flow_6_basic() {
+ // To do: phrasing, paragraphs, etc.
+ // assert_eq!(
+ // micromark_with_options(
+ // "<table><tr><td>\n<pre>\n**Hello**,\n\n_world_.\n</pre>\n</td></tr></table>",
+ // DANGER
+ // ),
+ // "<table><tr><td>\n<pre>\n**Hello**,\n<p><em>world</em>.\n</pre></p>\n</td></tr></table>",
+ // "should support html (basic)"
+ // );
+
+ // To do: paragraphs.
+ // assert_eq!(
+ // micromark_with_options(
+ // "<table>
+ // <tr>
+ // <td>
+ // hi
+ // </td>
+ // </tr>
+ // </table>
+
+ // okay.",
+ // DANGER
+ // ),
+ // "<table>
+ // <tr>
+ // <td>
+ // hi
+ // </td>
+ // </tr>
+ // </table>
+ // <p>okay.</p>",
+ // "should support html of type 6 (1)"
+ // );
+
+ assert_eq!(
+ 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),
+ "</div>\n*foo*",
+ "should support html starting w/ a closing tag"
+ );
+
+ // To do: phrasing
+ // assert_eq!(
+ // 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),
+ "<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),
+ "<div id=\"foo\" class=\"bar\n baz\">\n</div>",
+ "should support html w/ line endings (2)"
+ );
+
+ // To do: phrasing.
+ // assert_eq!(
+ // 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),
+ "<div id=\"foo\"\n*hi*",
+ "should support garbage html (1)"
+ );
+
+ assert_eq!(
+ micromark_with_options("<div class\nfoo", DANGER),
+ "<div class\nfoo",
+ "should support garbage html (2)"
+ );
+
+ assert_eq!(
+ 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),
+ "<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),
+ "<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),
+ "<div></div>\n``` c\nint x = 33;\n```",
+ "should include everything ’till a blank line"
+ );
+
+ // To do: blockquote.
+ // assert_eq!(
+ // 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)"
+ // );
+
+ // To do: list.
+ // assert_eq!(
+ // 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),
+ " <div>",
+ "should support basic tags w/ indent"
+ );
+
+ assert_eq!(
+ 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),
+ "<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),
+ "<div>\nbar\n</div>\n*foo*",
+ "should require a blank line to end"
+ );
+
+ // To do: phrasing.
+ // assert_eq!(
+ // 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),
+ "<div>\n*Emphasized* text.\n</div>",
+ "should not support interleaving w/o blank lines"
+ );
+
+ assert_eq!(
+ micromark_with_options(
+ "<table>\n\n<tr>\n\n<td>\nHi\n</td>\n\n</tr>\n\n</table>",
+ DANGER
+ ),
+ "<table>\n<tr>\n<td>\nHi\n</td>\n</tr>\n</table>",
+ "should support blank lines between adjacent html"
+ );
+
+ assert_eq!(
+ micromark_with_options(
+ "<table>
+
+ <tr>
+
+ <td>
+ Hi
+ </td>
+
+ </tr>
+
+</table>",
+ DANGER
+ ),
+ "<table>
+ <tr>
+<pre><code>&lt;td&gt;
+ Hi
+&lt;/td&gt;
+</code></pre>
+ </tr>
+</table>",
+ "should not support indented, blank-line delimited, adjacent html"
+ );
+
+ assert_eq!(
+ 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),
+ "<div",
+ "should support an eof directly after a basic tag name"
+ );
+
+ assert_eq!(
+ 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),
+ "<div ",
+ "should support an eof after a space directly after a tag name"
+ );
+
+ assert_eq!(
+ micromark_with_options("<div/", DANGER),
+ "<p>&lt;div/</p>",
+ "should not support an eof directly after a self-closing slash"
+ );
+
+ // To do: phrasing.
+ // assert_eq!(
+ // 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),
+ "<div/>",
+ "should support an eof after a self-closing tag"
+ );
+
+ assert_eq!(
+ 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),
+ "<div/>a",
+ "should support another character after a self-closing tag"
+ );
+
+ assert_eq!(
+ 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),
+ "<p>Foo</p>\n<div/>",
+ "should support interrupting paragraphs w/ self-closing basic tags"
+ );
+
+ // To do: block quote.
+ // assert_eq!(
+ // 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),
+ // "<blockquote>\n<div\n</blockquote>\n<p>a</p>",
+ // "should not support lazyness (1)"
+ // );
+
+ // assert_eq!(
+ // micromark_with_options("> a\n<div", DANGER),
+ // "<blockquote>\n<p>a</p>\n</blockquote>\n<div",
+ // "should not support lazyness (2)"
+ // );
+}
+
+#[test]
+fn html_flow_7_complete() {
+ // To do: phrasing.
+ // assert_eq!(
+ // 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),
+ "<Warning>\n*bar*\n</Warning>",
+ "should support non-html tag names"
+ );
+
+ assert_eq!(
+ 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),
+ "<del>\n*foo*\n</del>",
+ "should support non-“block” html tag names (2)"
+ );
+
+ assert_eq!(
+ micromark_with_options("</ins>\n*bar*", DANGER),
+ "</ins>\n*bar*",
+ "should support closing tags"
+ );
+
+ // To do: phrasing.
+ // assert_eq!(
+ // micromark_with_options("<del>\n\n*foo*\n\n</del>", DANGER),
+ // "<del>\n<p><em>foo</em></p>\n</del>",
+ // "should support interleaving"
+ // );
+
+ // To do: html (text).
+ // assert_eq!(
+ // 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),
+ "<div>\n<p>asd</p>",
+ "should support interleaving w/ whitespace-only blank lines"
+ );
+
+ // To do: interrupting.
+ // assert_eq!(
+ // 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),
+ "<p>&lt;x</p>",
+ "should not support an eof directly after a tag name"
+ );
+
+ assert_eq!(
+ 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),
+ "<p>&lt;x</p>\n",
+ "should not support a line ending directly after a tag name"
+ );
+
+ // To do: paragraphs (trailing whitespace).
+ // assert_eq!(
+ // 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),
+ "<p>&lt;x/</p>",
+ "should not support an eof directly after a self-closing slash"
+ );
+
+ // To do: phrasing.
+ // assert_eq!(
+ // 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),
+ "<x/>",
+ "should support an eof after a self-closing tag"
+ );
+
+ assert_eq!(
+ micromark_with_options("<x/>\na", DANGER),
+ "<x/>\na",
+ "should support a line ending after a self-closing tag"
+ );
+
+ // To do: html (text).
+ // assert_eq!(
+ // micromark_with_options("<x/>a", DANGER),
+ // "<p><x/>a</p>",
+ // "should not support another character after a self-closing tag"
+ // );
+
+ // To do: html (text).
+ // assert_eq!(
+ // 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),
+ "<x y>",
+ "should support boolean attributes in a complete tag"
+ );
+
+ // To do: html (text).
+ // assert_eq!(
+ // micromark_with_options("<x\ny>", DANGER),
+ // "<p><x\ny></p>",
+ // "should not support a line ending before an attribute name"
+ // );
+
+ // To do: html (text).
+ // assert_eq!(
+ // 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),
+ "<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"
+ );
+
+ // To do: html (text).
+ // assert_eq!(
+ // 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),
+ "<x y z>",
+ "should support whitespace between attribute names"
+ );
+
+ assert_eq!(
+ 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),
+ "<p>&lt;x_y&gt;</p>",
+ "should not support an underscore in a tag name"
+ );
+
+ assert_eq!(
+ 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),
+ "<x :y>",
+ "should support a colon to start an attribute name"
+ );
+
+ assert_eq!(
+ 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),
+ "<p>&lt;x .y&gt;</p>",
+ "should not support a dot to start an attribute name"
+ );
+
+ assert_eq!(
+ 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),
+ "<x y_>",
+ "should support an underscore to end an attribute name"
+ );
+
+ assert_eq!(
+ 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),
+ "<x y123>",
+ "should support numbers to end an attribute name"
+ );
+
+ assert_eq!(
+ 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),
+ "<p>&lt;x y=&gt;</p>",
+ "should not upport an initializer w/o a value"
+ );
+
+ assert_eq!(
+ 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),
+ "<x y=z>",
+ "should support a single character as an unquoted attribute value"
+ );
+
+ assert_eq!(
+ micromark_with_options("<x y=\"\">", DANGER),
+ "<x y=\"\">",
+ "should support an empty double quoted attribute value"
+ );
+
+ assert_eq!(
+ micromark_with_options("<x y=\"\">", DANGER),
+ "<x y=\"\">",
+ "should support an empty single quoted attribute value"
+ );
+
+ // To do: html (text).
+ // assert_eq!(
+ // micromark_with_options("<x y=\"\n\">", DANGER),
+ // "<p><x y=\"\n\"></p>",
+ // "should not support a line ending in a double quoted attribute value"
+ // );
+
+ // To do: html (text).
+ // assert_eq!(
+ // micromark_with_options("<x y=\"\n\">", DANGER),
+ // "<p><x y=\"\n\"></p>",
+ // "should not support a line ending in a single quoted attribute value"
+ // );
+
+ // To do: html (text).
+ // assert_eq!(
+ // 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),
+ "<p>&lt;w x=y&quot;z&gt;</p>",
+ "should not support a double quote in/after an unquoted attribute value"
+ );
+
+ // To do: html (text).
+ // assert_eq!(
+ // 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),
+ "<p>&lt;x y=&quot;&quot;z&gt;</p>",
+ "should not support an attribute after a double quoted attribute value"
+ );
+
+ // To do: blockquote.
+ // assert_eq!(
+ // 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),
+ // "<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),
+ // "<blockquote>\n<p>a</p>\n</blockquote>\n<a>",
+ // "should not support lazyness (2)"
+ // );
+}
diff --git a/tests/lib.rs b/tests/lib.rs
new file mode 100644
index 0000000..18fcef2
--- /dev/null
+++ b/tests/lib.rs
@@ -0,0 +1,8 @@
+extern crate micromark;
+use micromark::micromark;
+
+#[test]
+fn basic() {
+ assert_eq!(micromark("asd"), "<p>asd</p>", "should work");
+ assert_eq!(micromark("1 < 3"), "<p>1 &lt; 3</p>", "should encode");
+}
diff --git a/tests/thematic_break.rs b/tests/thematic_break.rs
new file mode 100644
index 0000000..833fa6f
--- /dev/null
+++ b/tests/thematic_break.rs
@@ -0,0 +1,181 @@
+extern crate micromark;
+use micromark::micromark;
+
+#[test]
+fn thematic_break() {
+ assert_eq!(
+ micromark("***\n---\n___"),
+ "<hr />\n<hr />\n<hr />",
+ "should support thematic breaks w/ asterisks, dashes, and underscores"
+ );
+
+ assert_eq!(
+ micromark("+++"),
+ "<p>+++</p>",
+ "should not support thematic breaks w/ plusses"
+ );
+
+ assert_eq!(
+ micromark("==="),
+ "<p>===</p>",
+ "should not support thematic breaks w/ equals"
+ );
+
+ assert_eq!(
+ micromark("--"),
+ "<p>--</p>",
+ "should not support thematic breaks w/ two dashes"
+ );
+
+ assert_eq!(
+ micromark("**"),
+ "<p>**</p>",
+ "should not support thematic breaks w/ two asterisks"
+ );
+
+ assert_eq!(
+ micromark("__"),
+ "<p>__</p>",
+ "should not support thematic breaks w/ two underscores"
+ );
+
+ assert_eq!(
+ micromark(" ***"),
+ "<hr />",
+ "should support thematic breaks w/ 1 space"
+ );
+
+ assert_eq!(
+ micromark(" ***"),
+ "<hr />",
+ "should support thematic breaks w/ 2 spaces"
+ );
+
+ assert_eq!(
+ micromark(" ***"),
+ "<hr />",
+ "should support thematic breaks w/ 3 spaces"
+ );
+
+ assert_eq!(
+ micromark(" ***"),
+ "<pre><code>***\n</code></pre>",
+ "should not support thematic breaks w/ 4 spaces"
+ );
+
+ // To do: paragraphs.
+ // assert_eq!(
+ // micromark("Foo\n ***"),
+ // "<p>Foo\n***</p>",
+ // "should not support thematic breaks w/ 4 spaces as paragraph continuation"
+ // );
+
+ assert_eq!(
+ micromark("_____________________________________"),
+ "<hr />",
+ "should support thematic breaks w/ many markers"
+ );
+
+ assert_eq!(
+ micromark(" - - -"),
+ "<hr />",
+ "should support thematic breaks w/ spaces (1)"
+ );
+
+ assert_eq!(
+ micromark(" ** * ** * ** * **"),
+ "<hr />",
+ "should support thematic breaks w/ spaces (2)"
+ );
+
+ assert_eq!(
+ micromark("- - - -"),
+ "<hr />",
+ "should support thematic breaks w/ spaces (3)"
+ );
+
+ assert_eq!(
+ micromark("- - - - "),
+ "<hr />",
+ "should support thematic breaks w/ trailing spaces"
+ );
+
+ assert_eq!(
+ micromark("_ _ _ _ a"),
+ "<p>_ _ _ _ a</p>",
+ "should not support thematic breaks w/ other characters (1)"
+ );
+
+ assert_eq!(
+ micromark("a------"),
+ "<p>a------</p>",
+ "should not support thematic breaks w/ other characters (2)"
+ );
+
+ assert_eq!(
+ micromark("---a---"),
+ "<p>---a---</p>",
+ "should not support thematic breaks w/ other characters (3)"
+ );
+
+ // To do: phrasing.
+ // assert_eq!(
+ // micromark(" *-*"),
+ // "<p><em>-</em></p>",
+ // "should not support thematic breaks w/ mixed markers"
+ // );
+
+ // To do: lists.
+ // assert_eq!(
+ // micromark("- foo\n***\n- bar"),
+ // "<ul>\n<li>foo</li>\n</ul>\n<hr />\n<ul>\n<li>bar</li>\n</ul>",
+ // "should support thematic breaks mixed w/ lists (1)"
+ // );
+
+ // assert_eq!(
+ // micromark("* Foo\n* * *\n* Bar"),
+ // "<ul>\n<li>Foo</li>\n</ul>\n<hr />\n<ul>\n<li>Bar</li>\n</ul>",
+ // "should support thematic breaks mixed w/ lists (2)"
+ // );
+
+ // To do: paragraph.
+ // assert_eq!(
+ // micromark("Foo\n***\nbar"),
+ // "<p>Foo</p>\n<hr />\n<p>bar</p>",
+ // "should support thematic breaks interrupting paragraphs"
+ // );
+
+ // To do: setext.
+ // assert_eq!(
+ // micromark("Foo\n---\nbar"),
+ // "<h2>Foo</h2>\n<p>bar</p>",
+ // "should not support thematic breaks w/ dashes interrupting paragraphs (setext heading)"
+ // );
+
+ // To do: list.
+ // assert_eq!(
+ // micromark("- Foo\n- * * *"),
+ // "<ul>\n<li>Foo</li>\n<li>\n<hr />\n</li>\n</ul>",
+ // "should support thematic breaks in lists"
+ // );
+
+ // To do: blockquote.
+ // assert_eq!(
+ // micromark("> ---\na"),
+ // "<blockquote>\n<hr />\n</blockquote>\n<p>a</p>",
+ // "should not support lazyness (1)"
+ // );
+
+ // assert_eq!(
+ // micromark("> a\n---"),
+ // "<blockquote>\n<p>a</p>\n</blockquote>\n<hr />",
+ // "should not support lazyness (2)"
+ // );
+
+ // To do: extensions.
+ // assert_eq!(
+ // micromark("***", {extensions: [{disable: {null: ["thematicBreak"]}}]}),
+ // "<p>***</p>",
+ // "should support turning off thematic breaks"
+ // );
+}