fix(mathml): render a script without a base over an empty base
This commit is contained in:
@@ -37,6 +37,12 @@ var corpus = []struct {
|
||||
{"sqrt", `\sqrt{x}`, `<msqrt><mi>x</mi></msqrt>`},
|
||||
{"root with index", `\sqrt[3]{x}`, `<mroot><mi>x</mi><mn>3</mn></mroot>`},
|
||||
{"sub and sup", `x_1^2`, `<msubsup><mi>x</mi><mn>1</mn><mn>2</mn></msubsup>`},
|
||||
{"baseless sup", `^3\mathrm{He}`,
|
||||
`<msup><mrow></mrow><mn>3</mn></msup><mrow><mi mathvariant="normal">H</mi><mi mathvariant="normal">e</mi></mrow>`},
|
||||
{"baseless sub", `_1\mathrm{H}`,
|
||||
`<msub><mrow></mrow><mn>1</mn></msub><mi mathvariant="normal">H</mi>`},
|
||||
{"baseless group", `^{-3}`,
|
||||
`<msup><mrow></mrow><mrow><mo>-</mo><mn>3</mn></mrow></msup>`},
|
||||
{"single digit script", `x^10`, `<msup><mi>x</mi><mn>1</mn></msup><mn>0</mn>`},
|
||||
{"group", `{xy}`, `<mrow><mi>x</mi><mi>y</mi></mrow>`},
|
||||
{"left right", `\left( x \right)`,
|
||||
|
||||
@@ -128,6 +128,12 @@ func (p *parser) atom() *node {
|
||||
return nil
|
||||
}
|
||||
return p.scripts(n)
|
||||
case tokCaret, tokUnderscore:
|
||||
// A script without a base, the isotope notation of ^3He, takes
|
||||
// an empty base: the script renders over nothing, the way the
|
||||
// notation is printed, and degrading it would refuse notation
|
||||
// the mathematics carries.
|
||||
return p.scripts(el("mrow"))
|
||||
}
|
||||
p.pos++
|
||||
return errorNode(t.text)
|
||||
|
||||
Reference in New Issue
Block a user