-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I don't think there's a trivial way to fix this, because the way KaTeX extensions work is quite weird (it relies on a global katex instance). I have been wrestling with this since my first day of using Docusaurus, and currently I copied the source of rehype-katex (which is surprisingly short), and added the import myself. See https://github.com/Josh-Cena/Josh-Cena.github.io/blob/master/src/remark/rehypeKatex.js I'm sure there are updates needed to support Docusaurus v3, but we'll see later. |
Beta Was this translation helpful? Give feedback.
-
Here's the way to add the copy-tex support: copy katex/dist/contrib/mhchem.mjs to /src folder, with some addition:
After that, load it as a client module. Here's the way to add the mhchem support: use add |
Beta Was this translation helpful? Give feedback.
Here's the way to add the copy-tex support:
copy katex/dist/contrib/mhchem.mjs to /src folder, with some addition:
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
on the top of the filedocument.addEventListener('copy', function (event) {
, and wrap this function withif (ExecutionEnvironment.canUseDOM) {}
.After that, load it as a client module.
Here's the way to add the mhchem support:
use
yarn patch
to modify therehype-katex
module(rather than just making a simple copy) to avoid cache warning.add
require('katex/contrib/mhchem')
at the top of /lib/index.js