Cleanup MathML <mrow>, <mtext>, <mn> (#1338)

* Avoid unnecessary <mrow> wrapping

buildMathML gains two helpers:
* `makeRow` helper wraps an array of nodes in `<mrow>`,
  unless the array has length 1, in which case no wrapping is necessary.
* `buildExpressionRow` for common case of `makeRow(buildExpression(...))`

* Combine adjacent <mtext>s in all cases

No more need for `makeTextRow` helper or anything fancy in text MathML handler.

* Concatenate <mn>s and decimal point into single <mn>

Fix #203

* Fix snapshots
This commit is contained in:
Erik Demaine
2018-05-21 22:56:34 -04:00
committed by GitHub
parent ef9cd5c172
commit 485c509879
8 changed files with 104 additions and 113 deletions

View File

@@ -35,6 +35,10 @@ describe("A MathML builder", function() {
expect(getMathML("\\sin{x}+1\\;\\text{a}")).toMatchSnapshot();
});
it('should concatenate digits into single <mn>', () => {
expect(getMathML("\\sin{\\alpha}=0.34")).toMatchSnapshot();
});
it('should make prime operators into <mo> nodes', () => {
expect(getMathML("f'")).toMatchSnapshot();
});