mirror of
https://github.com/typst/typst
synced 2025-06-25 06:42:53 +08:00
Turn non-empty void element into export error
This commit is contained in:
parent
c1b2aee1a9
commit
9050ee1639
@ -89,6 +89,9 @@ fn write_element(w: &mut Writer, element: &HtmlElement) -> SourceResult<()> {
|
||||
w.buf.push('>');
|
||||
|
||||
if tag::is_void(element.tag) {
|
||||
if !element.children.is_empty() {
|
||||
bail!(element.span, "HTML void elements must not have children");
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
@ -180,9 +180,6 @@ fn handle(
|
||||
if let Some(body) = elem.body(styles) {
|
||||
children = html_fragment(engine, body, locator.next(&elem.span()), styles)?;
|
||||
}
|
||||
if tag::is_void(elem.tag) && !children.is_empty() {
|
||||
bail!(elem.span(), "HTML void elements may not have children");
|
||||
}
|
||||
let element = HtmlElement {
|
||||
tag: elem.tag,
|
||||
attrs: elem.attrs(styles).clone(),
|
||||
|
@ -1,3 +1,7 @@
|
||||
--- html-non-char html ---
|
||||
// Error: 1-9 the character `"\u{fdd0}"` cannot be encoded in HTML
|
||||
\u{fdd0}
|
||||
|
||||
--- html-void-element-with-children html ---
|
||||
// Error: 2-27 HTML void elements must not have children
|
||||
#html.elem("img", [Hello])
|
||||
|
Loading…
x
Reference in New Issue
Block a user