Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • M MathJax
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 304
    • Issues 304
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • MathJax
  • MathJax
  • Issues
  • #2835
Closed
Open
Issue created Feb 14, 2022 by Administrator@rootContributor

mhchem TeX extension breaks internally when leaving out closing bracket

Created by: wb-joona

Issue Summary

TeX mhchem input extension produces an error from the internals when not closing the \ce command.

Steps to Reproduce:

Live minimal reproducible example here: https://codesandbox.io/s/nice-dhawan-yu49p?file=/index.html

  1. Load latest tex-chtml.js
  2. Render the equation \ce{H2O
  3. Notice uncaught error:
TypeError: t.slice is not a function
    at u.Machine (mhchem.js:1:410)
    at e.parse (tex-chtml.js:1:245691)
    at t.parse (tex-chtml.js:1:212776)
    at t.parse (tex-chtml.js:1:256801)
    at t.controlSequence (tex-chtml.js:1:220763)
    at e.t.parse (tex-chtml.js:1:243417)
    at t.parse (tex-chtml.js:1:212776)
    at t.parse (tex-chtml.js:1:256801)
    at t.Parse (tex-chtml.js:1:257409)
    at new t (tex-chtml.js:1:256142)
    at e.compile (tex-chtml.js:1:197284)
    at e.t.compile (tex-chtml.js:1:44978)
    at Object.renderMath (tex-chtml.js:1:35007)
    at e.renderConvert (tex-chtml.js:1:35820)
    at e.t.convert (tex-chtml.js:1:44865)
    at e.t.convert (tex-chtml.js:1:38921)
    at tex-chtml.js:1:22644
    at e (tex-chtml.js:1:717213)
    at new Promise (<anonymous>)
    at Object.e.handleRetriesFor (tex-chtml.js:1:717178)
    at Object.e.MathJax.<computed> [as tex2chtmlPromise] (tex-chtml.js:1:22597)
    at convert (yu49p.csb.app/:57:17)
    at HTMLInputElement.onclick (yu49p.csb.app/:133:11)

I would expect that with noerrors loaded, I would see some output at least. This error appears to break the rendering though.

The error appears to be originating here: https://github.com/mathjax/MathJax-src/blob/2dd53ce6c8af3c9cceba0baf014ea9b065130774/ts/input/tex/mhchem/MhchemConfiguration.ts#L51-L53

The catch appears to assume that the error is an array, but the actual error emitted here is the following object:

{
  id: 'MissingCloseBrace',
  message: 'Missing close brace'
}

and thus there is no .slice().

Technical details:

  • MathJax Version: 3.2.0
  • Client OS: Windows 10 Pro
  • Browser: Chrome 98.0.4758.82

Supporting information:

  • Please supply a link to a (live) minimal example page, when possible.
    • https://codesandbox.io/s/nice-dhawan-yu49p?file=/index.html
  • If your issue is with the display of the mathematics produced by MathJax, include a screen snapshot that illustrates the problem, when possible.
  • Check your browser console window for any error messages, and include them here.
  • Include the MathJax configuration you are using, and the script tag that loads MathJax itself.
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script>
    window.MathJax = {
        loader: { load: ["[tex]/noerrors", "[tex]/mhchem"] },
        tex: { packages: { "[+]": ["noerrors", "mhchem"] } },
    };
</script>
<script
    id="MathJax-script"
    async
    src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"
></script>
Assignee
Assign to
Time tracking