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
- Load latest
tex-chtml.js
- Render the equation
\ce{H2O
- 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.
- 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>