remarkjs / remark-math

remark and rehype plugins to support math
https://remark.js.org
MIT License
357 stars 52 forks source link

mhchem doesn't seem to work with rehype-katex #97

Closed djoudimansouri-ti closed 3 months ago

djoudimansouri-ti commented 3 months ago

Initial checklist

Affected packages and versions

latest

Link to runnable example

No response

Steps to reproduce

Node version : v21.5.0 NPM version : 10.2.4 PNPM version : 8.13.1

I'm using the rehype-katex plugin in react-markdown in a Nextjs14 app, and while KaTeX seem to work and displays maths equations and symbols with little to no issues, i can't say the same for chimical reactions, even the KaTeX package imports the mhchem module and declares the macros properly, i can't seem to get it to work in my app, in which i call the plugin like this :

        <ReactMarkdown
            className="prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0"
            remarkPlugins={[remarkGfm, remarkMath]}
            rehypePlugins={[rehypeKatex]}
            components={{
              p({ children }) {
                return <p className="mb-2 last:mb-0 ">{children}</p>
              },
            }}
          >
             {`$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$`} 
          </ReactMarkdown>

Expected behavior

The chemical reaction equation should be properly formated and show this :

image

Actual behavior

Instead, nothing is happening, it's style displayed like this :

\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}

Runtime

Other (please specify in steps to reproduce)

Package manager

Other (please specify in steps to reproduce)

OS

Linux

Build and bundle tools

Next.js

wooorm commented 3 months ago

See: https://github.com/remarkjs/remark-math/issues/81#issuecomment-1434803831. See: https://github.com/remarkjs/remark-math/pull/34#issuecomment-527345050.

github-actions[bot] commented 3 months ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

github-actions[bot] commented 3 months ago

Hi! Thanks for taking the time to contribute!

Because we treat issues as our backlog, we close duplicates to focus our work and not have to touch the same chunk of code for the same reason multiple times. This is also why we may mark something as duplicate that isn’t an exact duplicate but is closely related.

Thanks, — bb

github-actions[bot] commented 3 months ago

Hi team! It seems this post is a duplicate, but hasn’t been marked as such. Please post a comment w/ Duplicate of #123(no final .) to do so. See GH docs for more info.

Thanks, — bb

wooorm commented 3 months ago

Duplicate of #34