Repository: pulldown-cmark/pulldown-cmark (Rust)

Issue:
Using `<details>` element results in extraneous and unbalanced paragraph elements
v0.2.0 via cargo

For this input:

```markdown
<details><summary>Testing 1..2..3..</summary>

This is a test of the details element.

</details>
```

I receive the following output from pulldown-cmark with unexpected extraneous paragraph tags that cause HTML5 validation to fail on the first and last `</p>` closing tags, as they're separated by nesting from their opening `<p>` tag and so are considered unbalanced:

```html
<p><details><summary>Testing 1..2..3..</summary></p>
<p>This is a test of the details element.</p>
<p></details></p>
```

Compare this to the expected output that I indeed receive from jgm cmark:

```html
<details><summary>Testing 1..2..3..</summary>
<p>This is a test of the details element.</p>
</details>
```


Discussion:
This is still an issue. On the current master branch it produces
```html
<p><details><summary>Testing 1..2..3..</summary></p>
<p>This is a test of the details element.</p>
</details>
```
which isn't even valid HTML. I will look into this.



Patch:
diff --git a/specs/regression.txt b/specs/regression.txt
index dad4bbed..ca93c550 100644
--- a/specs/regression.txt
+++ b/specs/regression.txt
@@ -2,6 +2,20 @@ Run this with `cargo run -- -T -F -s specs/regression.txt`.
 
 Regression tests for issues on the github issue tracker.
 
+ISSUE #162
+
+```````````````````````````````` example
+<details><summary>Testing 1..2..3..</summary>
+
+This is a test of the details element.
+
+</details>
+.
+<details><summary>Testing 1..2..3..</summary>
+<p>This is a test of the details element.</p>
+</details>
+````````````````````````````````
+
 ISSUE #133
 
 ```````````````````````````````` example
diff --git a/src/scanners.rs b/src/scanners.rs
index a2d1f1cf..70a1cd1a 100644
--- a/src/scanners.rs
+++ b/src/scanners.rs
@@ -29,12 +29,15 @@ use crate::strings::CowStr;
 pub use crate::puncttable::{is_ascii_punctuation, is_punctuation};
 
 // sorted for binary search
-const HTML_TAGS: [&'static str; 47] = ["article", "aside", "blockquote",
-    "body", "button", "canvas", "caption", "col", "colgroup", "dd", "div",
-    "dl", "dt", "embed", "fieldset", "figcaption", "figure", "footer", "form",
-    "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "iframe",
-    "li", "map", "object", "ol", "output", "p", "progress","section", "table",
-    "tbody", "td", "textarea", "tfoot", "th", "thead", "tr", "ul", "video"];
+const HTML_TAGS: [&'static str; 62] = ["address", "article", "aside", "base",
+    "basefont", "blockquote", "body", "caption", "center", "col", "colgroup",
+    "dd", "details", "dialog", "dir", "div", "dl", "dt", "fieldset",
+    "figcaption", "figure", "footer", "form", "frame", "frameset", "h1",
+    "h2", "h3", "h4", "h5", "h6", "head", "header", "hr", "html", "iframe",
+    "legend", "li", "link", "main", "menu", "menuitem", "nav", "noframes",
+    "ol", "optgroup", "option", "p", "param", "section", "source", "summary",
+    "table", "tbody", "td", "tfoot", "th", "thead", "title", "tr", "track",
+    "ul"];
 
 /// Analysis of the beginning of a line, including indentation and container
 /// markers.


Test patch:
diff --git a/tests/regression.rs b/tests/regression.rs
index a5740e22..563d4570 100644
--- a/tests/regression.rs
+++ b/tests/regression.rs
@@ -8,6 +8,33 @@ include!("normalize_html.rs.inc");
 
     #[test]
     fn regression_test_1() {
+        let original = r##"<details><summary>Testing 1..2..3..</summary>
+
+This is a test of the details element.
+
+</details>
+"##;
+        let expected = r##"<details><summary>Testing 1..2..3..</summary>
+<p>This is a test of the details element.</p>
+</details>
+"##;
+
+        use pulldown_cmark::{Parser, html, Options};
+
+        let mut s = String::new();
+
+        let mut opts = Options::empty();
+        opts.insert(Options::ENABLE_TABLES);
+        opts.insert(Options::ENABLE_FOOTNOTES);
+
+        let p = Parser::new_ext(&original, opts);
+        html::push_html(&mut s, p);
+
+        assert_eq!(normalize_html(&expected), normalize_html(&s));
+    }
+
+    #[test]
+    fn regression_test_2() {
         let original = r##"see the [many] [articles] [on] [QuickCheck].
 
 [many]: https://medium.com/@jlouis666/quickcheck-advice-c357efb4e7e6
@@ -38,7 +65,7 @@ include!("normalize_html.rs.inc");
     }
 
     #[test]
-    fn regression_test_2() {
+    fn regression_test_3() {
         let original = r##"[![debug-stub-derive on crates.io][cratesio-image]][cratesio]
 [![debug-stub-derive on docs.rs][docsrs-image]][docsrs]
 
@@ -66,7 +93,7 @@ include!("normalize_html.rs.inc");
     }
 
     #[test]
-    fn regression_test_3() {
+    fn regression_test_4() {
         let original = r##"|  Title A  |  Title B  |
 | --------- | --------- |
 | Content   | Content   |
@@ -98,7 +125,7 @@ include!("normalize_html.rs.inc");
     }
 
     #[test]
-    fn regression_test_4() {
+    fn regression_test_5() {
         let original = r##"foo§__(bar)__
 "##;
         let expected = r##"<p>foo§<strong>(bar)</strong></p>