From 41a48d3130e71a2684ab8c57b7fca06200108f65 Mon Sep 17 00:00:00 2001 From: Mihaela Mihaljevic Date: Tue, 9 Jun 2026 02:48:00 +0200 Subject: [PATCH] feat(xslt): serialize method=html output by the HTML rules An xsl:output method=html result is serialized through PureXML.HTML (void elements emitted without a self-closing slash, raw-text elements like script/style left unescaped) instead of as XML. Part of #82. --- CHANGELOG.md | 1 + Sources/XSLT/XSLTTransform.swift | 1 + Tests/XSLTHTMLOutputTests.swift | 50 ++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 Tests/XSLTHTMLOutputTests.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 940db43..49043c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- XSLT `method="html"` output (#82). An `xsl:output method="html"` result is now serialized by the HTML rules (void elements like `
` emitted without a self-closing slash, raw-text elements like `"), "") + #expect(out.contains("if (a < b) x()")) + #expect(!out.contains("<")) + } + + @Test("The XML output method still self-closes empty elements") + func test_xmlStillSelfCloses() throws { + let style = """ + + +
+
+ """ + #expect(try transform(style, "") == "
") + } +}