diff --git a/crates/typst-html/src/lib.rs b/crates/typst-html/src/lib.rs index 0e3833400..cc771fc83 100644 --- a/crates/typst-html/src/lib.rs +++ b/crates/typst-html/src/lib.rs @@ -6,11 +6,9 @@ pub use self::encode::html; use comemo::{Track, Tracked, TrackedMut}; pub use ecow::EcoVec; -use typst_library::diag::{bail, warning, At, SourceDiagnostic, SourceResult, StrResult}; +use typst_library::diag::{bail, warning, At, SourceResult}; use typst_library::engine::{Engine, Route, Sink, Traced}; -use typst_library::foundations::{ - Content, Datetime, Smart, StyleChain, Target, TargetElem, -}; +use typst_library::foundations::{Content, StyleChain, Target, TargetElem}; use typst_library::html::{ attr, tag, FrameElem, HtmlDocument, HtmlElem, HtmlElement, HtmlNode, }; @@ -87,7 +85,7 @@ fn html_document_impl( let output = handle_list(&mut engine, &mut locator, children.iter().copied())?; let introspector = Introspector::html(&output); - let root = root_element(&mut engine, output, &info)?; + let root = root_element(output, &info)?; Ok(HtmlDocument { info, root, introspector }) } @@ -265,14 +263,8 @@ fn handle( /// Wrap the nodes in `` and `` if they are not yet rooted, /// supplying a suitable ``. -fn root_element( - engine: &mut Engine, - output: Vec, - info: &DocumentInfo, -) -> SourceResult { - let head = head_element(engine, info).map_err(|err| { - EcoVec::from([SourceDiagnostic::warning(Span::detached(), err)]) - })?; +fn root_element(output: Vec, info: &DocumentInfo) -> SourceResult { + let head = head_element(info); let body = match classify_output(output)? { OutputKind::Html(element) => return Ok(element), OutputKind::Body(body) => body, @@ -282,7 +274,7 @@ fn root_element( } /// Generate a `` element. -fn head_element(engine: &mut Engine, info: &DocumentInfo) -> StrResult { +fn head_element(info: &DocumentInfo) -> HtmlElement { let mut children = vec![]; children.push(HtmlElement::new(tag::meta).with_attr(attr::charset, "utf-8").into()); @@ -329,29 +321,7 @@ fn head_element(engine: &mut Engine, info: &DocumentInfo) -> StrResult children.push( - HtmlElement::new(tag::meta) - .with_attr(attr::name, "date") - .with_attr( - attr::content, - Datetime::today(engine, Smart::Auto)?.display(Smart::Auto)?, - ) - .into(), - ), - Smart::Custom(optional_date) => { - if let Some(date) = optional_date { - children.push( - HtmlElement::new(tag::meta) - .with_attr(attr::name, "date") - .with_attr(attr::content, date.display(Smart::Auto).unwrap()) - .into(), - ) - } - } - } - - Ok(HtmlElement::new(tag::head).with_children(children)) + HtmlElement::new(tag::head).with_children(children) } /// Determine which kind of output the user generated. diff --git a/tests/ref/html/basic-table.html b/tests/ref/html/basic-table.html index 7d0bf1c50..189a5b314 100644 --- a/tests/ref/html/basic-table.html +++ b/tests/ref/html/basic-table.html @@ -3,7 +3,6 @@ - diff --git a/tests/ref/html/block-html.html b/tests/ref/html/block-html.html index 93a792a08..d1716c6d7 100644 --- a/tests/ref/html/block-html.html +++ b/tests/ref/html/block-html.html @@ -3,7 +3,6 @@ -

Paragraph

diff --git a/tests/ref/html/box-html.html b/tests/ref/html/box-html.html index 0bedecd74..b2a26533b 100644 --- a/tests/ref/html/box-html.html +++ b/tests/ref/html/box-html.html @@ -3,7 +3,6 @@ -

Text Span.

diff --git a/tests/ref/html/col-gutter-table.html b/tests/ref/html/col-gutter-table.html index d78ff99e1..54170f534 100644 --- a/tests/ref/html/col-gutter-table.html +++ b/tests/ref/html/col-gutter-table.html @@ -3,7 +3,6 @@ -
diff --git a/tests/ref/html/col-row-gutter-table.html b/tests/ref/html/col-row-gutter-table.html index d78ff99e1..54170f534 100644 --- a/tests/ref/html/col-row-gutter-table.html +++ b/tests/ref/html/col-row-gutter-table.html @@ -3,7 +3,6 @@ -
diff --git a/tests/ref/html/enum-par.html b/tests/ref/html/enum-par.html index 25ebb1037..60d4592b7 100644 --- a/tests/ref/html/enum-par.html +++ b/tests/ref/html/enum-par.html @@ -3,7 +3,6 @@ -
diff --git a/tests/ref/html/enum-start.html b/tests/ref/html/enum-start.html index b4abaa77b..fc9b3c061 100644 --- a/tests/ref/html/enum-start.html +++ b/tests/ref/html/enum-start.html @@ -3,7 +3,6 @@ -
    diff --git a/tests/ref/html/heading-html-basic.html b/tests/ref/html/heading-html-basic.html index 7c1762789..54a22faf4 100644 --- a/tests/ref/html/heading-html-basic.html +++ b/tests/ref/html/heading-html-basic.html @@ -3,7 +3,6 @@ -

    Level 1

    diff --git a/tests/ref/html/link-basic.html b/tests/ref/html/link-basic.html index 6be58d33d..89cb54db5 100644 --- a/tests/ref/html/link-basic.html +++ b/tests/ref/html/link-basic.html @@ -3,7 +3,6 @@ -

    https://example.com/

    diff --git a/tests/ref/html/list-par.html b/tests/ref/html/list-par.html index 813562ee5..7c747ff44 100644 --- a/tests/ref/html/list-par.html +++ b/tests/ref/html/list-par.html @@ -3,7 +3,6 @@ -
    diff --git a/tests/ref/html/par-semantic-html.html b/tests/ref/html/par-semantic-html.html index 80dfcc70f..09c7d2fd0 100644 --- a/tests/ref/html/par-semantic-html.html +++ b/tests/ref/html/par-semantic-html.html @@ -3,7 +3,6 @@ -

    Heading is no paragraph

    diff --git a/tests/ref/html/quote-attribution-link.html b/tests/ref/html/quote-attribution-link.html index 809fac6cc..c12d2ae2d 100644 --- a/tests/ref/html/quote-attribution-link.html +++ b/tests/ref/html/quote-attribution-link.html @@ -3,7 +3,6 @@ -
    Compose papers faster
    diff --git a/tests/ref/html/quote-nesting-html.html b/tests/ref/html/quote-nesting-html.html index 9a9a383b8..6b05a94a0 100644 --- a/tests/ref/html/quote-nesting-html.html +++ b/tests/ref/html/quote-nesting-html.html @@ -3,7 +3,6 @@ -

    When you said that “he surely meant that ‘she intended to say “I'm sorry”’”, I was quite confused.

    diff --git a/tests/ref/html/quote-plato.html b/tests/ref/html/quote-plato.html index a4fdcccff..039835082 100644 --- a/tests/ref/html/quote-plato.html +++ b/tests/ref/html/quote-plato.html @@ -3,7 +3,6 @@ -
    … ἔοικα γοῦν τούτου γε σμικρῷ τινι αὐτῷ τούτῳ σοφώτερος εἶναι, ὅτι ἃ μὴ οἶδα οὐδὲ οἴομαι εἰδέναι.
    diff --git a/tests/ref/html/row-gutter-table.html b/tests/ref/html/row-gutter-table.html index d78ff99e1..54170f534 100644 --- a/tests/ref/html/row-gutter-table.html +++ b/tests/ref/html/row-gutter-table.html @@ -3,7 +3,6 @@ -
diff --git a/tests/ref/html/terms-par.html b/tests/ref/html/terms-par.html index a070aa919..78bc5df16 100644 --- a/tests/ref/html/terms-par.html +++ b/tests/ref/html/terms-par.html @@ -3,7 +3,6 @@ -