rohit-gohri / redocusaurus

OpenAPI for Docusaurus with Redoc
https://redocusaurus.vercel.app/
MIT License
629 stars 114 forks source link

Enabling additional languages for syntax highlighting in Docusaurus breaks Redocusaurus #68

Closed inacho closed 3 years ago

inacho commented 3 years ago

How to reproduce

Add additional languages for the syntax highlighting in Docusarus (https://docusaurus.io/docs/markdown-features/code-blocks#supported-languages)

Example:

module.exports = {
  // ...
  themeConfig: {
    prism: {
      additionalLanguages: ['java'],
    },
    // ...
  },
};

The additional language is correctly enabled in Docusaurus, however, when navigating to a Redocusaurus page the following error is happening:

Uncaught (in promise) TypeError: lang is undefined

Screen Shot 2021-07-08 at 13 00 42

Dependencies used in package.json

"dependencies": {
    "@docusaurus/core": "2.0.0-beta.3",
    "@docusaurus/preset-classic": "2.0.0-beta.3",
    "@mdx-js/react": "^1.6.22",
    "@svgr/webpack": "^5.5.0",
    "clsx": "^1.1.1",
    "core-js": "^3.9.1",
    "docusaurus-theme-redoc": "^0.4.4",
    "file-loader": "^6.2.0",
    "prism-react-renderer": "^1.2.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "redoc": "^2.0.0-rc.54",
    "redocusaurus": "^0.4.4",
    "remark-mermaid-dataurl": "^1.0.1",
    "url-loader": "^4.1.1"
  },

Any idea of how to fix it? Thanks

rohit-gohri commented 3 years ago

Redoc also ships prism with itself, the global configs might be conflicting.

inacho commented 3 years ago

I noticed that the problem disappear if I add the language "scala" on top of "java":

module.exports = {
  // ...
  themeConfig: {
    prism: {
      additionalLanguages: ['java', 'scala'],
    },
    // ...
  },
};

As you said, this is probably due to conflicts with prism in Redoc. I guess Redoc expects to have Scala enabled. Feel free to close the bug.

Thanks

rohit-gohri commented 3 years ago

Thanks for posting the solution 👍