Skip to content

Commit

Permalink
if 'usePrism' is true, use prismjs on all languages
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed Jun 7, 2018
1 parent d7bae24 commit 886cf24
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/api-doc-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand Down
2 changes: 1 addition & 1 deletion docs/api-site-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
5 changes: 2 additions & 3 deletions lib/core/renderMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 886cf24

Please sign in to comment.