From 40c5973d5ac74f4d6f0a2fd9ee3d7b58ea9cbcfe Mon Sep 17 00:00:00 2001 From: Mihaela Mihaljevic Date: Tue, 9 Jun 2026 05:29:14 +0200 Subject: [PATCH] feat(html): SVG element-name case adjustment in foreign content (#83) --- CHANGELOG.md | 1 + README.md | 2 +- Sources/HTML/HTMLDocumentBuilder.swift | 7 +++++-- Sources/HTML/HTMLForeignNames.swift | 23 +++++++++++++++++++++++ Tests/HTMLForeignContentTests.swift | 16 ++++++++++++++++ 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 Sources/HTML/HTMLForeignNames.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index a7f90dd..8ac2c89 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 SVG element-name case adjustment (#83, stage 3): an SVG element written in mixed case (which the tokenizer lowercases) is restored to its canonical camel case in the tree, so ``, ``, ``, and the rest carry their correct SVG names. Applies only in the SVG namespace; same-named HTML elements keep their lowercased name. - 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 `