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

mmltosvg : Getting "TypeError: Cannot read property 'chars' of undefined" for specific mathml equation #19

Closed
senthilsam opened this issue Jun 27, 2020 · 1 comment

Comments

@senthilsam
Copy link

Hi I am running mml2svg under direct for converting my mathml to svg. It works perfectly for other mml equations. But when i try converting the below equation it is throwing err.

Input Eqn: <math display='inline'><mrow><msup><mtext>1</mtext><mo>&#x2033;</mo></msup><mo>=</mo><mtext>(</mtext><mi>&#x03C0;</mi><mtext>/648&#x00A0;000)&#x00A0;rad</mtext></mrow></math>

Error: `D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\core\MathDocument.js:169
finally { if (e_4) throw e_4.error; }
^

TypeError: Cannot read property 'chars' of undefined
at SVGTextNode.CommonWrapper.unicodeChars (D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\output\common\Wrapper.js:433:48)
at SVGTextNode.SVGWrapper.placeChar (D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\output\svg\Wrapper.js:206:45)
at SVGTextNode.toSVG (D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\output\svg\Wrappers\TextNode.js:49:31)
at SVGmo.SVGWrapper.addChildren (D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\output\svg\Wrapper.js:61:23)
at SVGmo.toSVG (D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\output\svg\Wrappers\mo.js:63:18)
at SVGmsup.SVGscriptbase.toSVG (D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\output\svg\Wrappers\scriptbase.js:45:21)
at SVGmrow.SVGWrapper.addChildren (D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\output\svg\Wrapper.js:61:23)
at SVGmrow.toSVG (D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\output\svg\Wrappers\mrow.js:27:14)
at SVGinferredMrow.SVGWrapper.addChildren (D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\output\svg\Wrapper.js:61:23)
at SVGinferredMrow.SVGmrow.toSVG (D:\Senthil\projects\DEV\DTD Validation\MathMltoSvg\mathmltosvgandAlttext-epub\bin\Debug\mjax3-cli\node_modules\mathjax-full\js\output\svg\Wrappers\mrow.js:27:14)`

Any help on this will be much appreciated.

@dpvc
Copy link
Member

dpvc commented Jun 29, 2020

This is a duplicate of mathjax/MathJax#2402, which will be fixed in the next release. In the meantime, if you add

const SVGWrapper = require('mathjax-full/js/output/svg/Wrapper.js').SVGWrapper;
const CommonWrapper = SVGWrapper.prototype.__proto__;
SVGWrapper.prototype.unicodeChars = function (text, variant) {
  if (!variant) variant = this.variant || 'normal';
  return CommonWrapper.unicodeChars.call(this, text, variant);
}

just after the line

const RegisterHTMLHandler = require('mathjax-full/js/handlers/html.js').RegisterHTMLHandler;

that should work around the problem until then.

@dpvc dpvc added the Duplicate label Jun 29, 2020
@dpvc dpvc closed this as completed Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants