From 1646e4923ae7798538077fb7d62847ca44b442c2 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 5 Nov 2025 11:17:48 -0800 Subject: [PATCH] Add a test for HTML tags out of sync --- tests/testsuite/rendering.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/testsuite/rendering.rs b/tests/testsuite/rendering.rs index f77f0840..13c157cf 100644 --- a/tests/testsuite/rendering.rs +++ b/tests/testsuite/rendering.rs @@ -264,3 +264,28 @@ fn unclosed_html_tags() { str!["
xfooxyz
"], ); } + +// Test for HTML tags out of sync. +#[test] +fn unbalanced_html_tags() { + BookTest::init(|_| {}) + .change_file("src/chapter_1.md", "
xfoo
") + .run("build", |cmd| { + cmd.expect_stderr(str![[r#" + INFO Book building has started + INFO Running the html backend +ERROR internal error: HTML tag stack out of sync. + + path: `chapter_1.md` +current=Element(Element { name: QualName { prefix: None, ns: Atom('http://www.w3.org/1999/xhtml' type=static), local: Atom('span' type=inline) }, attrs: {}, self_closing: false, was_raw: true }) +pop name: div + WARN unclosed HTML tag `
` found in `chapter_1.md` + INFO HTML book written to `[ROOT]/book` + +"#]]); + }) + .check_main_file( + "book/chapter_1.html", + str!["
xfoo
"], + ); +}