summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorSharzy <me@sharzy.in>2025-02-25 00:35:13 +0800
committerLaurenz <laurmaedje@gmail.com>2025-02-25 15:28:14 +0100
commit4893eb501ecb6d27606460cbb0962742378c394d (patch)
tree59f75c9b7c64f88fd02e2ffa130038c64e7e145a /crates
parent20d4f8135abe580f99d5061680ba606d1b68f5e0 (diff)
HTML export: fix elem counting on classify_output (#5910)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/typst-html/src/lib.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/typst-html/src/lib.rs b/crates/typst-html/src/lib.rs
index 25d0cd5d..236a3254 100644
--- a/crates/typst-html/src/lib.rs
+++ b/crates/typst-html/src/lib.rs
@@ -307,18 +307,18 @@ fn head_element(info: &DocumentInfo) -> HtmlElement {
/// Determine which kind of output the user generated.
fn classify_output(mut output: Vec<HtmlNode>) -> SourceResult<OutputKind> {
- let len = output.len();
+ let count = output.iter().filter(|node| !matches!(node, HtmlNode::Tag(_))).count();
for node in &mut output {
let HtmlNode::Element(elem) = node else { continue };
let tag = elem.tag;
let mut take = || std::mem::replace(elem, HtmlElement::new(tag::html));
- match (tag, len) {
+ match (tag, count) {
(tag::html, 1) => return Ok(OutputKind::Html(take())),
(tag::body, 1) => return Ok(OutputKind::Body(take())),
(tag::html | tag::body, _) => bail!(
elem.span,
"`{}` element must be the only element in the document",
- elem.tag
+ elem.tag,
),
_ => {}
}