From 886cf249e95a93c684c8d608f2e900cba6994f2b Mon Sep 17 00:00:00 2001 From: endiliey Date: Fri, 8 Jun 2018 00:29:31 +0800 Subject: [PATCH] if 'usePrism' is true, use prismjs on all languages --- docs/api-doc-markdown.md | 2 +- docs/api-site-config.md | 2 +- lib/core/renderMarkdown.js | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/api-doc-markdown.md b/docs/api-doc-markdown.md index 7653300c773f..a5aa60cc43b5 100644 --- a/docs/api-doc-markdown.md +++ b/docs/api-doc-markdown.md @@ -183,7 +183,7 @@ While Highlight.js provides support for [many popular languages out of the box]( ### Using Prism.js as additional syntax highlighter -While highlight.js support a lot of languages, you can opt to use prism.js to syntax highlight certain languages available on [Prism](https://github.com/PrismJS/prism/tree/master/components). Include those languages in `usePrism` field in your [siteConfig.js](site-config.md) +While highlight.js support a lot of languages, you can opt to use prism.js to syntax highlight certain languages available on [Prism](https://github.com/PrismJS/prism/tree/master/components). Include those languages in `usePrism` field in your [siteConfig.js](api-site-config.md) Example: ``` diff --git a/docs/api-site-config.md b/docs/api-site-config.md index 49e331c94c03..8c16fe5888d9 100644 --- a/docs/api-site-config.md +++ b/docs/api-site-config.md @@ -173,7 +173,7 @@ h1 { `users` - The `users` array mentioned earlier. -`usePrism` - Array of languages to use prism.js syntax highlighter. Refer to [Using PrismJS as additional syntax highlighter](api-doc-markdown.md#using-prismjs-as-additional-syntax-highlighter). +`usePrism` - Array of languages to use prism.js syntax highlighter. Refer to [Using PrismJS as additional syntax highlighter](api-doc-markdown.md#using-prismjs-as-additional-syntax-highlighter). Set it to `true` to use PrismJS on all languages. `wrapPagesHTML` - Boolean flag to indicate whether `html` files in `/pages` should be wrapped with Docusaurus site styles, header and footer. This feature is experimental and relies on the files being `html` fragments instead of complete pages. It inserts the contents of your `html` file with no extra processing. Defaults to `false`. diff --git a/lib/core/renderMarkdown.js b/lib/core/renderMarkdown.js index 1c5440ed7857..e2e6b9b729d9 100644 --- a/lib/core/renderMarkdown.js +++ b/lib/core/renderMarkdown.js @@ -30,10 +30,9 @@ class MarkdownRenderer { lang || (siteConfig.highlight && siteConfig.highlight.defaultLang); if (lang && hljs.getLanguage(lang)) { try { - // try to use prism.js for certain language if ( - siteConfig.usePrism && - siteConfig.usePrism.indexOf(lang) !== -1 + siteConfig.usePrism === true || + (siteConfig.usePrism && siteConfig.usePrism.indexOf(lang) !== -1) ) { try { const language = alias[lang] || lang;