Skip to content

Commit 1646e49

Browse files
committed
Add a test for HTML tags out of sync
1 parent 1e19013 commit 1646e49

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/testsuite/rendering.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,28 @@ fn unclosed_html_tags() {
264264
str!["<div>x<span>foo<i>xyz</i></span></div>"],
265265
);
266266
}
267+
268+
// Test for HTML tags out of sync.
269+
#[test]
270+
fn unbalanced_html_tags() {
271+
BookTest::init(|_| {})
272+
.change_file("src/chapter_1.md", "<div>x<span>foo</div></span>")
273+
.run("build", |cmd| {
274+
cmd.expect_stderr(str![[r#"
275+
INFO Book building has started
276+
INFO Running the html backend
277+
ERROR internal error: HTML tag stack out of sync.
278+
279+
path: `chapter_1.md`
280+
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 })
281+
pop name: div
282+
WARN unclosed HTML tag `<div>` found in `chapter_1.md`
283+
INFO HTML book written to `[ROOT]/book`
284+
285+
"#]]);
286+
})
287+
.check_main_file(
288+
"book/chapter_1.html",
289+
str!["<div>x<span>foo</span></div>"],
290+
);
291+
}

0 commit comments

Comments
 (0)