From d64bcaf2fa1f0e8ef3af7946183f8724ad384ebf Mon Sep 17 00:00:00 2001 From: Mihaela Mihaljevic Date: Tue, 9 Jun 2026 05:22:37 +0200 Subject: [PATCH] feat(html): SVG/MathML foreign-content namespace switching (#83) --- CHANGELOG.md | 1 + README.md | 2 +- Sources/HTML/HTMLDocumentBuilder.swift | 31 +++++++++++++-- Tests/HTMLForeignContentTests.swift | 52 ++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 Tests/HTMLForeignContentTests.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 7869cb3..a7f90dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- HTML5 foreign content (#83, stage 2): an `` or `` element and all of its descendants now carry the SVG (`http://www.w3.org/2000/svg`) or MathML (`http://www.w3.org/1998/Math/MathML`) namespace on their `QualifiedName`, so foreign elements are distinguishable from same-named HTML; ordinary HTML content (including content after a closed ``) stays in no namespace. (SVG/MathML element- and attribute-name case adjustment, and HTML integration points, are a later refinement.) - HTML5 table tree construction (#83, stage 1): a `` written without its section and row wrappers now nests correctly. A `` directly inside a `
` gets an implied ``, a `` (and section), consecutive rows share one implied ``, and an explicit ``/``/`` is not duplicated, all inside an open table only. - HTML tokenizer correctness (#84, partial): numeric character references are now range/surrogate-validated (zero, surrogates, and values above U+10FFFF yield U+FFFD) with the Windows-1252 C1 fixup table (`€` -> euro, etc.); named references are decoded by longest match with or without a trailing semicolon; a literal NUL byte becomes U+FFFD; RCDATA elements (`title`, `textarea`) decode character references while raw-text elements (`script`, `style`) take their content verbatim; and a single leading newline after `
`/`` gets an implied `