-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to define a default language #206
Conversation
I don't want to have to add the language i'm working on to every single block nor do I want to rely on a default heuristic to find the language. This adds the ability to write ``` highlight: { defaultLang: 'xxxx' } ``` in `siteConfig.js` to force the language when not specified. I tested it without a a highlight block, without a defaultLang attribute and with one and with a wrong one. All of them work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Thanks.
I can update https://docusaurus.io/docs/en/site-config.html to reference this new config option.
lib/core/Remarkable.js
Outdated
@@ -42,30 +42,32 @@ class Remarkable extends React.Component { | |||
|
|||
renderMarkdown(source) { | |||
if (!this.md) { | |||
// Allow client sites to register their own plugins | |||
const siteConfig = require(CWD + "/siteConfig.js"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason not to put this up top with the other require
s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I put it there in the first place was so that if we reset the require, it's going to get a fresh version. But looks like we're not doing it yet, so right now it wouldn't make a difference: #205 (comment)
lib/core/Remarkable.js
Outdated
@@ -42,30 +42,32 @@ class Remarkable extends React.Component { | |||
|
|||
renderMarkdown(source) { | |||
if (!this.md) { | |||
// Allow client sites to register their own plugins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment may not make as much sense in this scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I'll move it back
I don't want to have to add the language i'm working on to every single block nor do I want to rely on a default heuristic to find the language.
This adds the ability to write
in
siteConfig.js
to force the language when not specified.I tested it without a a highlight block, without a defaultLang attribute and with one and with a wrong one. All of them work as expected.