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

KaTeX: TypeError: Cannot read properties of undefined (reading 'type') #476

Open
philippemilink opened this issue Oct 31, 2022 · 1 comment
Labels
semver/bugfix This is a minor backward-compatible fix status/verified This has been checked by a maintainer type/bug This is a problem

Comments

@philippemilink
Copy link
Member

Sentry reported the following issue:

TypeError: Cannot read properties of undefined (reading 'type')
  File "/opt/zds/app/zmd/node_modules/katex/dist/katex.js", line 9987, col 17, in Object.mathmlBuilder [as array]
    if (cols[0].type === "separator") {
  File "/opt/zds/app/zmd/node_modules/katex/dist/katex.js", line 7178, col 50, in buildGroup
    var result = _mathmlGroupBuilders[group.type](group, options);
  File "/opt/zds/app/zmd/node_modules/katex/dist/katex.js", line 7095, col 17, in buildExpression
    var group = buildMathML_buildGroup(expression[0], options);
  File "/opt/zds/app/zmd/node_modules/katex/dist/katex.js", line 7194, col 20, in buildMathML
    var expression = buildMathML_buildExpression(tree, options); // Wrap up the expression in an mrow so it is presented in the semantics
  File "/opt/zds/app/zmd/node_modules/katex/dist/katex.js", line 7263, col 22, in buildTree
    var mathMLNode = buildMathML(tree, expression, options, false);
  File "/opt/zds/app/zmd/node_modules/katex/dist/katex.js", line 17303, col 12, in renderToDomTree
    return buildTree_buildTree(tree, expression, settings);
  File "/opt/zds/app/zmd/node_modules/katex/dist/katex.js", line 17263, col 16, in renderToString
    var markup = katex_renderToDomTree(expression, options).toMarkup();
  File "/opt/zds/app/zmd/node_modules/rehype-katex/index.js", line 48, col 18, in onelement
    result = katex(
  File "/opt/zds/app/zmd/node_modules/unist-util-visit/index.js", line 27, col 12, in overload
    return visitor(node, index, parent)
  File "/opt/zds/app/zmd/node_modules/unist-util-visit-parents/index.js", line 56, col 27, in visit
    result = toResult(visitor(node, parents))

I have the full content that triggered this error, but I managed to make https://zestedesavoir.github.io/zmarkdown/ stop render the Markdown with only this content (probably the above error is occuring):

zz

$$
\begin{array}{}
t\\
t
\end{array}
$$

The LaTeX equation does not seem to be valid (I get an error when trying to build a LaTeX file containing this equation), but I guess zmd should rather just issue a warning, not an error.

@philippemilink philippemilink added the type/bug This is a problem label Oct 31, 2022
@LikaKavkasidze LikaKavkasidze added semver/bugfix This is a minor backward-compatible fix status/verified This has been checked by a maintainer labels Dec 12, 2022
@LikaKavkasidze LikaKavkasidze modified the milestone: zmarkdown@11.2.0 Dec 12, 2022
@LikaKavkasidze
Copy link
Member

I planned to fix this issue in ZMd 11.2, but unfortunately, it seems to be an upstream problem: KaTeX is throwing an error because of incorrect behavior instead of returning it properly. I need to check if it still fails with newer versions of KaTeX before opening an issue on their bug tracker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/bugfix This is a minor backward-compatible fix status/verified This has been checked by a maintainer type/bug This is a problem
Projects
None yet
Development

No branches or pull requests

2 participants