Skip to content

Commit 054da77

Browse files
committed
Add test for unbalanced html in a header
This is unexpectedly panicking.
1 parent bc7ca45 commit 054da77

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/testsuite/rendering.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,25 @@ Check that the HTML tags are properly balanced.
283283
})
284284
.check_main_file("book/chapter_1.html", str!["<div>x<span>foo</span></div>"]);
285285
}
286+
287+
// Test for bug with unbalanced HTML handling in the heading.
288+
#[test]
289+
fn heading_with_unbalanced_html() {
290+
BookTest::init(|_| {})
291+
.change_file("src/chapter_1.md", "### Option<T>")
292+
.run("build", |cmd| {
293+
cmd.expect_failure().expect_stderr(str![[r#"
294+
INFO Book building has started
295+
INFO Running the html backend
296+
297+
thread 'main' ([..]) panicked at crates/mdbook-html/src/html/tree.rs:[..]
298+
internal error: expected empty tag stack.
299+
300+
path: `chapter_1.md`
301+
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 }
302+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
303+
304+
"#]]);
305+
});
306+
// .check_main_file("book/chapter_1.html", str![[""]]);
307+
}

0 commit comments

Comments
 (0)