Wiris

Documentation / MathType

  • Demos
  • Visit our website
  • Downloads
  • Contact us
  • MathType

    • WirisQuizzes

      • Nubric

        • CalcMe

          • MathPlayer

            • Store FAQ

              • MathFlow

                • BF FAQ

                  • Miscellaneous

                    • Wiris Integrations

                      • Home
                      • MathType
                      • Technical documentation
                      • MathType for HTML editors
                      • Reference

                      Modified XML encoding for MathML

                      Reading time: 1min

                      Reference describing the modified XML encoding used by MathType to safely store MathML in environments that cannot contain raw XML.

                      Summary

                      MathML is an XML-based language. Some platforms and HTML contexts cannot safely store raw XML because reserved XML characters may be filtered, escaped incorrectly, or interpreted as HTML markup.

                      To avoid these issues, MathType uses a modified XML encoding that replaces the five reserved XML characters with alternative Unicode characters. The original MathML can be restored by reversing these substitutions.

                      Why a modified encoding is used

                      MathType stores formulas as MathML. In some environments, however, embedding raw MathML directly is not possible. Typical examples include:

                      • HTML attributes (such as data-mathml).
                      • HTML editors that sanitize unknown XML tags.
                      • Content management systems that remove embedded XML.
                      • Legacy platforms that treat MathML as invalid HTML.

                      Using the modified encoding preserves MathML while allowing it to be safely stored within HTML content.

                      Character mapping

                      The following substitutions are applied.

                      XML character Replacement character
                      < «
                      > »
                      & §
                      " ¨
                      ' `

                      To recover the original MathML, replace each encoded character with its corresponding XML character.

                      Example

                      Original MathML:

                      <mi>x</mi>
                      

                      Stored using the modified encoding:

                      «mi»x«/mi»
                      

                      Typical use cases

                      The modified encoding is commonly found in:

                      • The data-mathml attribute of legacy MathType image formulas.
                      • Exported HTML content.
                      • Integrations that store MathML inside HTML attributes.

                      See Migrate MathType image formulas to MathML for a practical migration example.

                       

                      Decoding

                      Decoding simply consists of reversing the character substitutions listed above. Any programming language capable of replacing characters or strings can restore the original MathML. For example:

                      From To
                      « <
                      » >
                      § &
                      ¨ "
                      ` '

                      Legacy XSLT example

                      Earlier versions of the documentation included an XSLT stylesheet that demonstrated how to automatically reverse the modified encoding. The same result can be achieved with any XML or text-processing library that supports the character substitutions shown above.

                      Notes

                      • This encoding does not modify the MathML structure or semantics.
                      • Only the five reserved XML characters are replaced.
                      • The encoding is fully reversible.
                      • New integrations working directly with MathML usually do not need to apply this encoding manually.

                      Related articles

                      • Migrate MathType image formulas to MathML.
                      • Full MathML mode.
                      • Content MathML.

                      Was this article helpful?

                      Give feedback about this article

                      Related Articles

                      • MathML makes elementary math accessible
                      • MathType MTEF v.5 (MathType 4.0 and later)
                      • Content MathML

                      Modified XML encoding for MathML

                      Summary Why a modified encoding is used Character mapping Example Typical use cases Decoding Legacy XSLT example Notes Related articles

                      Empowering STEM education

                      MathType

                      • Office Tools
                      • LMS
                      • XML
                      • HTML

                      WirisQuizzes

                      Nubric

                      Integrations

                      Solutions

                      • Education
                      • Publishing houses – platforms and interactive
                      • Publishing houses – Print and digital
                      • Technical writers

                      Pricing

                      Downloads

                      Blog

                      • Success stories

                      About us

                      • Careers
                      • Partnership

                      Contact Us

                      Contact Sales

                      European union (European Regional Development Fund) and 1EdTech (TrustEd Apps Certified)
                      • Cookie Policy
                      • Terms of Use
                      • Privacy Policy / GDPR
                      • Student Data Privacy
                      • Compliance
                      • Cookie Settings

                      © Wiris 2026

                      Expand