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

mathml2svg() throwing error on latest version #2879

Closed
svejdani opened this issue May 27, 2022 · 4 comments
Closed

mathml2svg() throwing error on latest version #2879

svejdani opened this issue May 27, 2022 · 4 comments
Labels
Accepted Issue has been reproduced by MathJax team Test Needed v3 v3.2

Comments

@svejdani
Copy link

Issue Summary

A summary of the issue and the browser/OS environment in which it occurs. If
suitable, include the steps required to reproduce the bug.
Mathjax function mathml2svg(mathml) throws an error. This is happening after the latest release. Script that is being used is
'https://cdn.jsdelivr.net/npm/mathjax@3/es5/mml-svg.js'
image

Steps to Reproduce:

  1. Load Mathjax using latest version script 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/mml-svg.js'
  2. Use the mathjax method mathml2svg()
  3. mathml2svg throws an error

Downgrading to version 3.1 resolves the issue. Conversion to svg was working fine before latest 3.2.1 release.

Technical details:

  • MathJax Version: 3.2.1 (latest commit: f3aaf3a)
  • Client OS: Mac OS X 11.2.3
  • Browser: Chrome 100.0.4896.127

Supporting information:

@dpvc
Copy link
Member

dpvc commented May 30, 2022

I am not able to reproduce the issue. The mathml2svg() seems to sower for me. The message you are receiving suggests that you are passing mathml2svg() a MathML string that includes a <div> tag, which will cause the error that you see. We do not currently support HTML embedded in MathML, though there is a pull request to implement it that should be part of the next feature release later this summer.

@dpvc
Copy link
Member

dpvc commented May 30, 2022

PS, if that's not it, then can you be more specific about the actual code you are using and the MathML that you are passing to mathml2svg()?

@svejdani
Copy link
Author

Here is what I'm doing on the latest version (3.2.x):

  1. Get mathML from WIRIS editor
  2. Pass mathML to mathml2svg(mathml)
  3. Get the div error

I've console logged the mathml to make sure it has no 'div' tag. Here is a screenshot:
image

Note, this is only happening on version 3.2 (latest). When I change to 3.1, everything seems to work with no errors.

Let me know if you need any more information. Thank you.

Additional info:
image

@dpvc
Copy link
Member

dpvc commented Jun 2, 2022

OK, you didn't mention that you were using the mml3 extension, which turns out to be the culprit.

Here is a configuration that will take care of it for now:

MathJax = {
  loader: {load: ['[mml]/mml3']},
  startup: {
    ready() {
      MathJax.startup.defaultReady();
      const adaptor = MathJax.startup.document.adaptor;
      MathJax.startup.document.inputJax[0].mmlFilters.add((args) => {
        if (adaptor.kind(args.data) !== 'math') {
          args.data = adaptor.tags(args.data, 'math')[0];
        }
      });
    }
  }
};

Note that as of v3.2.1, you don't need the pre-filter that you are using any longer (that issue was fixed in 3.2.1).

@dpvc dpvc added Ready for Development Accepted Issue has been reproduced by MathJax team v3 and removed Cannot Reproduce labels Jun 2, 2022
dpvc added a commit to mathjax/MathJax-src that referenced this issue Jun 8, 2022
Make sure we get the <math> element from mml3 conversion.  (mathjax/MathJax#2879)
@dpvc dpvc added Merged Merged into develop branch v3.2 and removed Ready for Review labels Jun 8, 2022
@dpvc dpvc removed the Merged Merged into develop branch label Jun 27, 2022
@dpvc dpvc closed this as completed Jun 27, 2022
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 Test Needed v3 v3.2
Projects
None yet
Development

No branches or pull requests

2 participants