Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

malignmark tag present with linebreaking on causes output error on v4.beta6 #3232

Open
papile opened this issue May 15, 2024 · 1 comment
Open
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Merged Merged into develop branch v4

Comments

@papile
Copy link

papile commented May 15, 2024

Issue Summary

malignmark causes Math Output error on all equations when linebreaking is on and the equation is broken

Steps to Reproduce:

  1. Take equation from test case with malignmark present
  2. decrease container width so the display equation breaks

Technical details:

  • MathJax Version: develop branch 6f71501
  • 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.

@dpvc
Copy link
Member

dpvc commented May 19, 2024

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.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around v4 labels May 19, 2024
dpvc added a commit to mathjax/MathJax-src that referenced this issue May 19, 2024
dpvc added a commit to mathjax/MathJax-src that referenced this issue Jun 4, 2024
Prevent linebreaking from crashing on empty containers. (mathjax/MathJax#3232)
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Merged Merged into develop branch v4
Projects
None yet
Development

No branches or pull requests

2 participants