prism-react-renderer
prism-react-renderer copied to clipboard
Unable to add additional languages
Overview
I followed the FAQ How do I add more language highlighting support? on README.md
to add additional languages other than the languages mentioned here. However, the error popped up:
Uncaught Error: Cannot find module './prism-latex'
Issue
I then went to check if the languages I wanted to add were in prism-react-renderer/prism
, but none of them were found:
- latex
- tex
- context
The version I am using is 1.3.1
:
"dependencies": {
"@docusaurus/core": "2.0.0-beta.15",
"@docusaurus/preset-classic": "2.0.0-beta.15",
"@docusaurus/theme-live-codeblock": "^2.0.0-beta.15",
"@mdx-js/react": "^1.6.21",
"@types/prettier": "^2.4.2",
"clsx": "^1.1.1",
"hast-util-is-element": "^1.1.0",
"prettier": "^2.5.1",
"prism-react-renderer": "^1.3.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"rehype-katex": "^4.0.0",
"remark-math": "^3.0.1",
"remark-mermaid-dataurl": "^1.0.2"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.0.0-beta.15",
"@tsconfig/docusaurus": "^1.0.4",
"typescript": "^4.5.2"
},
I use prism-react-renderer
in docusaurus
. Here is my code in .md
:
```latex
f(x)=
\left\{
\begin{matrix}
x^{2} + 1, x \geq 0 \\
x^{2} + 2, x < 0
\end{matrix}
\right.
```
Expected Behavior
Add syntax highlighting support for latex, tex, and context (They are basically the same though).
@SiegeSailor Docusaurus offers a special API to declare additional languages. Please see our docs: https://docusaurus.io/docs/markdown-features/code-blocks#supported-languages
@Josh-Cena Thank you for your response. However, I did use the special API to declare additional languages. The error message Uncaught Error: Cannot find module './prism-latex'
comes after I add languages such as latex
to docusaurus.config.js
.
Sorry, I can't reproduce it.
themeConfig: {
prism: {
additionalLanguages: ['latex'],
},
}
```latex
\textit{Hello world!}
```
Could you look into node_modules/prismjs/components
and see if prism-latex
exists?
@Josh-Cena Thank you for further research.
It looks like that prism-latex
does exist in node_modules/prismjs/components
:
But Uncaught Error: Cannot find module './prism-latex'
pops up when I use the following config:
If I don't set up latex in themeConfig
, then the syntax wouldn't be highlighted:
```latex
f(x)=
\left\{
\begin{matrix}
x^{2} + 1, x \geq 0 \\
x^{2} + 2, x < 0
\end{matrix}
\right.
```
Do you have a reproduction demo? Like your GitHub repo.
@Josh-Cena Here is the repository I am using Docusaurus.
Hi, @Josh-Cena.
Sorry for bothering you. Is there any update?
Unable to reproduce this, please reopen in the docusaurus repo if needed.