remark-math: invalid javascript @ generated object keys

Initial checklist

Affected packages and versions

rehype-mathjax: 4.0.2

Link to runnable example

No response

Steps to reproduce

// @ vite.config.js
{
  plugins: [
    XDM({
      rehypePlugins: [Rehype_MathJax],
      remarkPlugins: [Remark_Math   ],
    })
  ]
}

Expected behavior

Example snippet

Lift($L$) can be determined by Lift Coefficient ($C_L$) like the following equation.

should compile from an mdx file without error.

Actual behavior

Browser Error:

Uncaught (in promise) SyntaxError: Unexpected token '-'

image

It seems that the error would be prevented by wrapping the generated mdx-container key in quotes.

Through trial & error I found that this issue:

  • occurs when parsing mdx files via either mdx-js or xdm
  • does not occur when swapping rehype-katex in place of rehype-mathjax

Runtime

Node v16

Package manager

yarn v1

OS

Windows

Build and bundle tools

Vite

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Ah yeah, that was the issue. Ok I’ll try diffing that result against the one from Solid & see if anybody @ their Discord might know what’s going on if I can’t figure it out. Thanks for the assistance!

Thanks for the report! I fixed it in xdm (expect a release in a minute), and will release it in MDX in the next RC / actual release (a week or two?). I’ll close this issue here because there are no code changes required in remarkjs/remark-math!