mdx-js / eslint-mdx

ESLint Parser/Plugin for MDX
https://npmjs.org/eslint-plugin-mdx
MIT License
263 stars 32 forks source link

Parsing error with Latex #454

Closed inflation closed 1 year ago

inflation commented 1 year ago

Initial checklist

Affected packages and versions

"eslint-plugin-mdx": "2.0.5",

Link to runnable example

No response

Steps to reproduce

Any .mdx file with a latex section like:

$$
\begin{align*}
\mathcal{L} &= - \frac{1}{4} F_{\mu \nu} F^{\mu \nu} \\
    &\phantom{{}=}+ i \bar{\psi} \cancel{D} \psi + h.c. \\
    &\phantom{{}=}+ \bar{\psi}_i y_{ij} \psi_j \phi + h.c. \\
    &\phantom{{}=}+ |D_\mu \phi|^2 - V(\phi)
\end{align*}
$$

Expected behavior

Parse normally

Actual behavior

Parsing error: Could not parse expression with acorn: Unexpected token

The problem is at the * in \begin{align*}.

Runtime

Node v18

Package manager

pnpm

OS

macOS

Build and bundle tools

Next.js

ChristianMurphy commented 1 year ago

MDX does not support latex by default. If you want to enable latex in math blocks, you'd need https://github.com/remarkjs/remark-math added as a plugin through a .remarkrc file https://github.com/unifiedjs/unified-engine/blob/main/doc/configure.md

inflation commented 1 year ago

Good catch. Never noticed that, adding the plugin solved it.