Problem using remark-math with MDX
See original GitHub issueI’ve been trying to plug in the KaTeX renderer into the chain of plugins for MDX, but so far, I’m stuck with with some of the formulae incorrectly rendering.
My webpack rules
part is as follows:
{
test: /\.mdx$/,
use: [
...babelLoader,
{
loader: '@mdx-js/loader',
options: {
mdPlugins: [math],
hastPlugins: [katex]
}
}
]
}
…where math
and katex
are the packages remark-math
and rehype-katex
, respectively. I’m using preact
and preact-compat
with the following aliases:
alias: {
react: 'preact-compat/dist/preact-compat',
'react-dom': 'preact-compat/dist/preact-compat',
'react-addons-create-fragment': 'preact-compat/dist/preact-compat'
}
To illustrate the problem, I’m trying to render the following page:
import 'katex/dist/katex.css';
import { h } from 'preact';
## Math test
$$
\sum{1}
$$
$$
\sum{i}
$$
The first equation renders fine, since 1
is a literal and is just converted to a string in the JSX. However, the second equation uses {i}
in the rendered JSX and tries to evaluate the i
, which fails because i
is undefined
.
Is there a way to have JSX be ignored or forced to escape in the math portion of the MDX?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Next.js MDX rendering problem with remark-math and rehype ...
I am using MDX in my NEXT.JS project with the react-math and rehype-katex plugins. When I render the MDX files it gives me...
Read more >Math - MDX
This guide explores how to support math (LaTeX) in MDX. ... Math can be enabled by using a remark plugin: remark-math , combined...
Read more >remark-math examples - CodeSandbox
Remark Math Examples. Learn how to use remark-math by viewing and forking example apps that make use of remark-math on CodeSandbox.
Read more >Using KaTeX With Gatsby and MDX - Trevor Blades
My website is built with Gatsby and MDX using gatsby-plugin-mdx , which accepts remark and rehype plugins as configuration options. Luckily there's a...
Read more >remark-plugin - Keywords - unified
remark plugin to support MDX syntax ... remark plugin to autolink references like in GitHub issues, PRs, and comments. 71%; 330k; 2.71 kB...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@linonetwo released in v0.15.3-0.
Sorry, I’m AFK for the next couple of days, I may have missed something in my reproduction, like an older version of MDX, maybe. I’ll see if this is still an issue with my setup when I can check it. Thank you!