malignmark tag present with linebreaking on causes output error on v4.beta6
Issue Summary
malignmark causes Math Output error on all equations when linebreaking is on and the equation is broken
Steps to Reproduce:
- Take equation from test case with malignmark present
- decrease container width so the display equation breaks
Technical details:
- MathJax Version: develop branch 6f71501db9f43966be12d1f94b1591b35fe1a578
- Client OS: MacOS 14.4.1
- Browser: Firefox 125.0.3
I am using the following MathJax configuration: See test file
and loading MathJax via See test file - Loading from built source
Test File: math_test.txt https://papile.com/math_test.html
Supporting information:
This does not occur if the item does not break or if linebreaking is not enabled (Bug in LineBreakVisitor) Removing malignmark results in it breaking correctly with no error.
See https://github.com/mathjax/MathJax-src/blob/9d1370999feba6e608271b6309cb9d304c61b54a/ts/output/common/LinebreakVisitor.ts#L423 This is called with malignmark and it has no children. This makes wrapper.childNodes[0] undefined.
Thanks for the report and for isolating the issue. Since we haven't implemented <malignmark/> and <maligngroup/>, these haven't been tested much, I'm afraid.
In any case, here is a configuration that you can use to work around the issue:
MathJax = JSON.parse(
'{"output":{"font":"mathjax-stix2","displayOverflow":"linebreak"}}'
);
MathJax.startup = {
ready() {
const {LinebreakVisitor} = MathJax._.output.common.LinebreakVisitor;
class myLinebreakVisitor extends LinebreakVisitor {
visitNode(wrapper, i) {
if (wrapper) {
super.visitNode(wrapper, i);
}
}
};
MathJax.config.output.linebreaks = MathJax.config.chtml.linebreaks = {LinebreakVisitor: myLinebreakVisitor};
MathJax.startup.defaultReady();
}
};
This subclasses the line-break visitor that patches the visitNode() method to skip the call when there is no node to visit.
I will make a PR to fix the issue in the next release.