shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.
https://nextra.site
MIT License
11.91k stars 1.29k forks source link

It is not possible to mark more than one identical footnote. #2620

Closed bulhakovolexii closed 10 months ago

bulhakovolexii commented 10 months ago

I found the following problem.

With a clean installation and configuration according to the documentation and the latex module is enabled...

const withNextra = require("nextra")({
  theme: "nextra-theme-docs",
  themeConfig: "./theme.config.jsx",
  latex: true,
});

module.exports = withNextra();

...if i mark a footnote to the same reference more than once, compiling is impossible.

image

image

But if there is no more than one footnote, or the latex module is disabled, then everything is fine.

The problem also does not occur if i change the file extension from .mdx to .md.

image

image

Please help me fix this problem. :heart:

dimaMachina commented 10 months ago

stake trace says that error goes from rehype-katex

TypeError: Cannot read properties of undefined (reading 'className')
 ❯ ../../node_modules/.pnpm/rehype-katex@7.0.0/node_modules/rehype-katex/lib/index.js:48:56
 ❯ node element<sup> file:/Users/dmytro/Desktop/nextra/node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/index.js:346:27
 ❯ node element<a> file:/Users/dmytro/Desktop/nextra/node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/index.js:363:61
 ❯ node element<p> file:/Users/dmytro/Desktop/nextra/node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/index.js:363:61
 ❯ node element<li> file:/Users/dmytro/Desktop/nextra/node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/index.js:363:61
 ❯ node element<ol> file:/Users/dmytro/Desktop/nextra/node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/index.js:363:61
 ❯ node element<section> file:/Users/dmytro/Desktop/nextra/node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/index.js:363:61
 ❯ node root file:/Users/dmytro/Desktop/nextra/node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/index.js:363:61
 ❯ visitParents ../../node_modules/.pnpm/unist-util-visit-parents@6.0.1/node_modules/unist-util-visit-parents/lib/index.js:304:31
 ❯ ../../node_modules/.pnpm/rehype-katex@7.0.0/node_modules/rehype-katex/lib/index.js:47:5
dimaMachina commented 10 months ago

after more deep dive into this problem, I figured out that updating @mdx-js/mdx from 2.3.0 to 3.0.0 fixes this issue (Nextra 3 already uses mdx v3)

Use Nextra 3 alpha and refactor $$ style to https://the-guild.dev/blog/nextra-3#-syntax-no-longer-works-for-latex

bulhakovolexii commented 10 months ago

I tried the alpha version, indeed, it does not contain such a bug. Big thanks!