Open ubbe-xyz opened 2 years ago
Uhhh... It's indeed a Redoc problem and yes we had a past issue with this... https://github.com/facebook/docusaurus/issues/5443 (with Redocusaurus)
However that one was closed because it was basically unactionable. Since this one has a repro I could look into it in more detail. Thanks π
including scala in the additional languages fixed it for me:
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ["java", "scala"],
},
I came across the same issue when adding Scala, and the workaround of the code snippet above (adding java
) worked for me as well. I initially thought it's a Prism issue, since other languages loaded correctly (tried protobuf
). This comment suggests that language loading isn't done correctly.
I came across the same issue too. I followed this 2564#issuecomment and 8065#issuecomment , and it worked for me.
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ['clike','java'],
}
and prism-clike.js:
(function (Prism) {
Prism.languages.clike = {
'comment': [
{
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
lookbehind: true,
greedy: true
},
{
pattern: /(^|[^\\:])\/\/.*/,
lookbehind: true,
greedy: true
}
],
'string': {
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
greedy: true
},
'class-name': {
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
lookbehind: true,
inside: {
'punctuation': /[.\\]/
}
},
'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
'boolean': /\b(?:false|true)\b/,
'function': /\b\w+(?=\()/,
'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
'punctuation': /[{}[\];(),.:]/
};
}(Prism))
then,
npx docusaurus clear
It seems like there may be a way to fix this in Docusaurus, without requiring manual workarounds in local installs β see this comment in #5013.
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
Thanks for the fantastic work you're doing with Docusaurus π; we use it daily for the developer documentation at Apto.
We hit the following issue, which is puzzling us.
We have code block examples on our site using syntax highlighting. We also have our API specs embedded on the site using Redoc: it's just an OpenAPI file that Redoc is using to generate the HTML which in turn we embed on a page (see the reproduction repo on how this it's done).
The setup worked well for us until last week when we loaded
java
syntax highlighting as we added code examples in Java. The site built fine with no complaints, but it caused the following runtime error in our API pages:I've scouted for similar issues but did not find any, and I don't understand the cause. Redoc also has
prism
as a dependency, so maybe it's weird dependency compatibility between the two projects?I'm happy to help fix the error if indicated how ππ½ βοΈ
Reproducible demo
https://github.com/lluia/docusaurus-highlight-issue
Steps to reproduce
yarn start
java
as syntax highlighting in the Docusaurus configExpected behavior
I can have a page that renders API documentation with Redoc without issues.
Actual behavior
In case I'm loading the
java
syntax highlighting:There's a runtime error trying to navigate to a page with Redoc.
Your environment
2.0.0-beta.18
Self-service