https://github.com/transpect/mml-normalize
MathML normalization
https://github.com/transpect/mml-normalize
Last synced: 4 months ago
JSON representation
MathML normalization
- Host: GitHub
- URL: https://github.com/transpect/mml-normalize
- Owner: transpect
- License: bsd-2-clause
- Created: 2017-05-17T07:56:47.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2026-01-30T12:15:38.000Z (5 months ago)
- Last Synced: 2026-01-31T05:20:07.735Z (5 months ago)
- Language: XSLT
- Size: 135 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mathml-normalize
An XSLT library to normalize MathML equations with heuristic methods.
## Description
The authoring of math equations is an error-prone process, especially with WYSIWYG editors such as MathType and Microsoft Word Equation Editor. For example, authors tend to write symbols accidentally in text mode instead of changing the font-style to normal. This results most likely in wrong MathML markup for the symbol, like `mtext` where `mi` is appropriate.
Consider this MathML equation with wrong markup:
```xml
E=m
c
2
```
After mml-normalize, the `mtext` was resolved and the text was properly tagged with `mi` and `mo` elements. Furthermore, the `msubsup` was replaced with `msup`:
```xml
E
=
m
c
2
```
## Invoke with Saxon
mml-normalize contains two XSLT modes. First, you should invoke `mml2tex-grouping` and afterwards `mml2tex-preprocess`.
```
$ saxon -xsl:mml-normalize/xsl/mml-normalize.xsl -s:eq.xml -o:eq-nrmlzd.xml -im:mml2tex-grouping
$ saxon -xsl:mml-normalize/xsl/mml-normalize.xsl -s:eq.xml -o:eq-nrmlzd.xml -im:mml2tex-preprocess
```
## Note
In our experience of working with poorly formatted equations, this XSLT improved the markup plenty of times. However, due to the nature of heuristic methods, there can be cases where this XSLT is no help at all or changes something for the worse. We suggest to include Schematron checking and a certain level of math proofreading in your process.