Skip to content

Regression: SVG(data:) returns nil for documents with ex/em width/height units (worked in 0.20.1, fails in 0.28.0) #130

Description

@malgapo-bot

Summary

SVG(data:) returns nil for any SVG whose root width/height attributes use ex or em units. These documents parsed fine in 0.20.1; px (and unitless) values work in both versions.

Minimal repro

import SwiftDraw

let ex = #"<svg xmlns="http://www.w3.org/2000/svg" width="2ex" height="1ex"><rect width="5" height="5"/></svg>"#
let em = #"<svg xmlns="http://www.w3.org/2000/svg" width="2em" height="1em"><rect width="5" height="5"/></svg>"#
let px = #"<svg xmlns="http://www.w3.org/2000/svg" width="2px" height="1px"><rect width="5" height="5"/></svg>"#

SVG(data: Data(ex.utf8))  // nil on 0.28.0 — parsed on 0.20.1
SVG(data: Data(em.utf8))  // nil on 0.28.0 — parsed on 0.20.1
SVG(data: Data(px.utf8))  // parses on both

Why it matters

MathJax v3 always emits ex units on its SVG output roots, e.g.

<svg style="vertical-align: -0.025ex;" xmlns="http://www.w3.org/2000/svg" width="1.294ex" height="1.025ex" role="img" …>

so every MathJax-generated SVG now fails to parse. Downstream, LaTeXSwiftUI renders equations via MathJaxSwift → SwiftDraw; once dependency resolution picks SwiftDraw ≥ 0.28, every equation silently renders blank. Pinning SwiftDraw to 0.20.1 restores rendering.

Environment

  • SwiftDraw 0.28.0 (fails) vs 0.20.1 (works) — I haven't bisected the versions in between
  • macOS 26.3, Xcode 26.6

Happy to test a fix or provide more samples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions