Skip to content

Support MathML (mml:*) elements for XHTML rendering#236

Merged
Girgias merged 1 commit intophp:masterfrom
lacatoire:feat/mathml-rendering
Feb 5, 2026
Merged

Support MathML (mml:*) elements for XHTML rendering#236
Girgias merged 1 commit intophp:masterfrom
lacatoire:feat/mathml-rendering

Conversation

@lacatoire
Copy link
Contributor

Summary

  • Add mappings for all presentation MathML elements (mml:math, mml:mi, mml:mn, mml:mo, …) in
    the Generic XHTML format
  • A single format_mml_element() handler strips the mml: prefix and outputs standard HTML5 MathML
    tags (<math>, <mi>, etc.)
  • Adds xmlns="http://www.w3.org/1998/Math/MathML" on the <math> root element for XHTML
    compatibility
  • Preserves MathML attributes (display, mathvariant, width, …) and xml:idid
  • Handles self-closing elements (e.g. <mspace/>)
  • Does not inject class= attributes (unlike transformFromMap)
  • Text nodes inside MathML elements are handled by the existing TEXT() method

Closes #172

Test plan

  • New .phpt test covering inline equation, self-closing <mspace/>, and mathvariant
    attribute
  • Full existing test suite still passes

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this!

@Girgias Girgias merged commit 61ad3e7 into php:master Feb 5, 2026
11 checks passed
@lacatoire lacatoire deleted the feat/mathml-rendering branch February 5, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support MathML tags for rendering

2 participants