From ef644f4def7d5cad3fb5307ec5e00fc7b0b025ff Mon Sep 17 00:00:00 2001
From: Titus Wormer 
Date: Mon, 13 Jun 2022 18:42:36 +0200
Subject: Add basic html (text)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
*   Add all states for html (text)
*   Fix to link paragraph tokens together
*   Add note about uncovered bug where linking paragraph tokens together
    doesn’t work 😅
---
 tests/html_text.rs | 434 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 434 insertions(+)
 create mode 100644 tests/html_text.rs
(limited to 'tests/html_text.rs')
diff --git a/tests/html_text.rs b/tests/html_text.rs
new file mode 100644
index 0000000..6ec387b
--- /dev/null
+++ b/tests/html_text.rs
@@ -0,0 +1,434 @@
+extern crate micromark;
+use micromark::{micromark, micromark_with_options, CompileOptions};
+
+const DANGER: &CompileOptions = &CompileOptions {
+    allow_dangerous_html: true,
+    allow_dangerous_protocol: false,
+};
+
+#[test]
+fn html_text() {
+    assert_eq!(
+        micromark("a  c"),
+        "a <b> c
",
+        "should encode dangerous html by default"
+    );
+
+    assert_eq!(
+        micromark_with_options("", DANGER),
+        "
",
+        "should support opening tags"
+    );
+
+    assert_eq!(
+        micromark_with_options("", DANGER),
+        "
",
+        "should support self-closing tags"
+    );
+
+    // To do: line endings.
+    // assert_eq!(
+    //     micromark_with_options("", DANGER),
+    //     "
",
+    //     "should support whitespace in tags"
+    // );
+
+    // To do: line endings.
+    // assert_eq!(
+    //     micromark_with_options(
+    //         "\"\"\n_boolean zoop:33=zoop:33 />",
+    //         DANGER
+    //     ),
+    //     "\"\"\n_boolean zoop:33=zoop:33 />
",
+    //     "should support attributes on tags"
+    // );
+
+    assert_eq!(
+        micromark_with_options("Foo ", DANGER),
+        "Foo 
",
+        "should support non-html tags"
+    );
+
+    assert_eq!(
+        micromark_with_options("<33> <__>", DANGER),
+        "<33> <__>
",
+        "should not support nonconforming tag names"
+    );
+
+    assert_eq!(
+        micromark_with_options("", DANGER),
+        "<a h*#ref="hi">
",
+        "should not support nonconforming attribute names"
+    );
+
+    assert_eq!(
+        micromark_with_options(" ", DANGER),
+        "<a href="hi'> <a href=hi'>
",
+        "should not support nonconforming attribute values"
+    );
+
+    // To do: line endings.
+    // assert_eq!(
+    //     micromark_with_options("< a><\nfoo>\n", DANGER),
+    //     "< a><\nfoo><bar/ >\n<foo bar=baz\nbim!bop />
",
+    //     "should not support nonconforming whitespace"
+    // );
+
+    assert_eq!(
+        micromark_with_options("", DANGER),
+        "<a href='bar'title=title>
",
+        "should not support missing whitespace"
+    );
+
+    assert_eq!(
+        micromark_with_options("", DANGER),
+        "
",
+        "should support closing tags"
+    );
+
+    assert_eq!(
+        micromark_with_options("", DANGER),
+        "</a href="foo">
",
+        "should not support closing tags w/ attributes"
+    );
+
+    // To do: line endings.
+    //     assert_eq!(
+    //         micromark_with_options("foo ", DANGER),
+    //         "foo 
",
+    //         "should support comments"
+    //     );
+
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo <!-- not a comment -- two hyphens -->
",
+        "should not support comments w/ two dashes inside"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo  foo -->", DANGER),
+        "foo <!--> foo -->
",
+        "should not support nonconforming comments (1)"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo <!-- foo--->
",
+        "should not support nonconforming comments (2)"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo 
",
+        "should support instructions"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo 
",
+        "should support declarations"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo &<]]>", DANGER),
+        "foo &<]]>
",
+        "should support cdata"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo 
",
+        "should support (ignore) character references"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo 
",
+        "should not support character escapes (1)"
+    );
+
+    assert_eq!(
+        micromark_with_options("", DANGER),
+        "<a href=""">
",
+        "should not support character escapes (2)"
+    );
+
+    // Extra:
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo <!1>
",
+        "should not support non-comment, non-cdata, and non-named declaration"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo <!-not enough!-->
",
+        "should not support comments w/ not enough dashes"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo 
",
+        "should support comments that start w/ a dash, if it’s not followed by a greater than"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo <!--->
",
+        "should not support comments that start w/ `->`"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo ", DANGER),
+        "foo 
",
+        "should support `->` in a comment"
+    );
+
+    assert_eq!(
+        micromark_with_options("foo