fix(mathml): render a script without a base over an empty base
This commit is contained in:
@@ -10,6 +10,7 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- A paragraph that follows a definition list, separated from it by a blank line, is no longer swallowed into the `dl` element: the list ends before it, and terms after the paragraph open a list of their own.
|
- A paragraph that follows a definition list, separated from it by a blank line, is no longer swallowed into the `dl` element: the list ends before it, and terms after the paragraph open a list of their own.
|
||||||
|
- A superscript or subscript without a base, the isotope notation of `^3He`, renders over an empty base instead of degrading to an merror.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ var corpus = []struct {
|
|||||||
{"sqrt", `\sqrt{x}`, `<msqrt><mi>x</mi></msqrt>`},
|
{"sqrt", `\sqrt{x}`, `<msqrt><mi>x</mi></msqrt>`},
|
||||||
{"root with index", `\sqrt[3]{x}`, `<mroot><mi>x</mi><mn>3</mn></mroot>`},
|
{"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>`},
|
{"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>`},
|
{"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>`},
|
{"group", `{xy}`, `<mrow><mi>x</mi><mi>y</mi></mrow>`},
|
||||||
{"left right", `\left( x \right)`,
|
{"left right", `\left( x \right)`,
|
||||||
|
|||||||
@@ -128,6 +128,12 @@ func (p *parser) atom() *node {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return p.scripts(n)
|
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++
|
p.pos++
|
||||||
return errorNode(t.text)
|
return errorNode(t.text)
|
||||||
|
|||||||
Reference in New Issue
Block a user