diff --git a/tests/testsuite/rendering.rs b/tests/testsuite/rendering.rs
index e0e77039..ea75fbd0 100644
--- a/tests/testsuite/rendering.rs
+++ b/tests/testsuite/rendering.rs
@@ -283,3 +283,25 @@ Check that the HTML tags are properly balanced.
})
.check_main_file("book/chapter_1.html", str!["
xfoo
"]);
}
+
+// Test for bug with unbalanced HTML handling in the heading.
+#[test]
+fn heading_with_unbalanced_html() {
+ BookTest::init(|_| {})
+ .change_file("src/chapter_1.md", "### Option")
+ .run("build", |cmd| {
+ cmd.expect_failure().expect_stderr(str![[r#"
+ INFO Book building has started
+ INFO Running the html backend
+
+thread 'main' ([..]) panicked at crates/mdbook-html/src/html/tree.rs:[..]
+internal error: expected empty tag stack.
+
+ path: `chapter_1.md`
+element=Element { name: QualName { prefix: None, ns: Atom('http://www.w3.org/1999/xhtml' type=static), local: Atom('h3' type=inline) }, attrs: {}, self_closing: false, was_raw: false }
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
+
+"#]]);
+ });
+ // .check_main_file("book/chapter_1.html", str![[""]]);
+}