From cb8d862a55601127a1e3ff02feaefdabd37b583f Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 6 Jan 2025 14:55:34 +0100 Subject: [PATCH] Terminate pretty-printed HTML with trailing newline (#5661) --- crates/typst-html/src/encode.rs | 3 +++ tests/ref/html/heading-html-basic.html | 2 +- tests/ref/html/link-basic.html | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/typst-html/src/encode.rs b/crates/typst-html/src/encode.rs index b87b0e1d6..62146f867 100644 --- a/crates/typst-html/src/encode.rs +++ b/crates/typst-html/src/encode.rs @@ -12,6 +12,9 @@ pub fn html(document: &HtmlDocument) -> SourceResult { w.buf.push_str(""); write_indent(&mut w); write_element(&mut w, &document.root)?; + if w.pretty { + w.buf.push('\n'); + } Ok(w.buf) } diff --git a/tests/ref/html/heading-html-basic.html b/tests/ref/html/heading-html-basic.html index 69a1d0172..56b1e32b7 100644 --- a/tests/ref/html/heading-html-basic.html +++ b/tests/ref/html/heading-html-basic.html @@ -27,4 +27,4 @@ Level 7 - \ No newline at end of file + diff --git a/tests/ref/html/link-basic.html b/tests/ref/html/link-basic.html index 1f4e02e12..5d998667e 100644 --- a/tests/ref/html/link-basic.html +++ b/tests/ref/html/link-basic.html @@ -18,4 +18,4 @@ Contact hi@typst.app or call 123 for more information.

- \ No newline at end of file +