diff --git a/lib/core/Remarkable.js b/lib/core/Remarkable.js index 92a8a950e0..710021a417 100644 --- a/lib/core/Remarkable.js +++ b/lib/core/Remarkable.js @@ -42,21 +42,24 @@ class Remarkable extends React.Component { renderMarkdown(source) { if (!this.md) { + const siteConfig = require(CWD + "/siteConfig.js"); + this.md = new Markdown({ // Highlight.js expects hljs css classes on the code element. // This results in
langPrefix: 'hljs css ',
highlight: function (str, lang) {
+ lang = lang || (siteConfig.highlight && siteConfig.highlight.defaultLang);
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (err) {}
}
-
+
try {
return hljs.highlightAuto(str).value;
} catch (err) {}
-
+
return '';
}
});
@@ -65,7 +68,6 @@ class Remarkable extends React.Component {
this.md.use(anchors);
// Allow client sites to register their own plugins
- const siteConfig = require(CWD + "/siteConfig.js");
if (siteConfig.markdownPlugins) {
siteConfig.markdownPlugins.forEach(function(plugin) {
this.md.use(plugin);
@@ -96,4 +98,4 @@ Remarkable.defaultProps = {
options: {},
};
-module.exports = Remarkable;
\ No newline at end of file
+module.exports = Remarkable;