question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gatsby-plugin-mdx doesn't render "complex" Katex formulas

See original GitHub issue

Description

I don’t know the exact terms to describe it, but “complex” Katex formulas prevent MDX from rendering. (Feel free to change the title into something more specific)

I’ve figured out a workaround by passing the formula as a string to a custom component that runs the string through katex.renderToString and then passes the output to dangerouslySetInnerHTML. That might help in pinpointing where the problem occurs.

(⚠️ Note for anyone looking for a QUICKFIX: use this component to render Katex formulas that break rendering)

I have already talked to the MDX team about this, and they managed to get it working by removing gatsby-plugin-mdx from the equation (see the link for codesandboxes with examples).

Steps to reproduce

There is a minimal reproducible example here with instructions on how to make it fail as well as the workaround in action.

This is the formula in question:

$$
\begin{aligned}
  \bar{x} &= \dfrac{0+1+2+ \ldots +8}{9} = 3.56 \\
  \bar{y} &= \dfrac{23.5+25+ \ldots +37.5}{9}=30
\end{aligned}
$$

Expected result

The formula should render.

Actual result

I get this error:

error "gatsby-plugin-mdx" threw an error while running the onCreateNode lifecycle:

unknown: Expecting Unicode escape sequence \uXXXX (18:9)

  16 | {x}
  17 | {` &= \\dfrac`}
> 18 | {0+1+2+ \ldots +8}
     |          ^
  19 | {9}
  20 | {` = 3.56 `}
  21 | {`\\`}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:28 (21 by maintainers)

github_iconTop GitHub Comments

3reactions
nikbelikovcommented, Mar 31, 2021

@nikbelikov How were you able to get the \begin{align*}...\end{align*} to work properly? Which versions are you using?

please, mention @nikoladev instead 😃

image
3reactions
KyleAMathewscommented, Dec 28, 2020

Marked “not stale”. Yeah, we need to do soon a major release for the whole suite of plugins with updated dependencies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding math support to a Gatsby MDX blog - Nicky Meuleman
I wanted to add support to display equations on my blog. A popular tool to achieve this is KaTeX. The goal is being...
Read more >
Gatsbyjs LaTeX in .mdx files - javascript - Stack Overflow
I am using Gatsbyjs for my website and I'm trying to be able to write LaTeX in my .mdx files but I cannot...
Read more >
gatsby-remark-mathjax
Add MathJax to your template: MathJax is required to render the formulas correctly. Math Equations in Inline Mode. Surround your equation with $...
Read more >
Use Gatsbyjs with MDX and Latex Equations - Zhengchao Tian
I am using Gatsbyjs for a while and really love it to generate static sites. With the help of gatsby-transformer-remark plugin, It is...
Read more >
homebrew-core - Homebrew Formulae
a2ps 4.14 Any‑to‑PostScript filter aacgain 1.8 AAC‑supporting version of mp3gain aalib 1.4rc5 Portable ASCII art graphics library aamath 0.3 Renders mathematical expressions as ASCII art
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found