summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorSharzy <me@sharzy.in>2025-02-25 00:35:13 +0800
committerGitHub <noreply@github.com>2025-02-24 16:35:13 +0000
commit36d83c8c092e7984eaa03dbecc1083f49da13129 (patch)
tree48dfeaa213fcf51f16a7b8324a72d856d36872bb /crates
parent3744c99b07f97a954a8468bef5fdb08c5c7914d7 (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,
),
_ => {}
}