From c8bc00a3a78f6db8f9a9e22aaaf63f56a00cc2ac Mon Sep 17 00:00:00 2001 From: Endilie Yacop Sucipto Date: Sun, 10 Jun 2018 02:38:01 +0800 Subject: [PATCH] Enable using Prism for syntax highlighting (#735) * Enable user to use prism.js as syntax highlighter * add package-lock * if 'usePrism' is true, use prismjs on all languages * don't get lang by hljs if use prism * Update api-site-config.md * Update api-doc-markdown.md * only load prism css when usePrism is true --- docs/api-doc-markdown.md | 28 ++++++++ docs/api-site-config.md | 2 + lib/core/Head.js | 7 +- lib/core/renderMarkdown.js | 27 +++++++- lib/static/css/main.css | 2 +- lib/static/css/prism.css | 130 +++++++++++++++++++++++++++++++++++++ package-lock.json | 74 +++++++++++++++++++-- package.json | 1 + website/siteConfig.js | 1 + yarn.lock | 32 +++++++++ 10 files changed, 292 insertions(+), 12 deletions(-) create mode 100644 lib/static/css/prism.css diff --git a/docs/api-doc-markdown.md b/docs/api-doc-markdown.md index 907b5c534c..932284c0c3 100644 --- a/docs/api-doc-markdown.md +++ b/docs/api-doc-markdown.md @@ -180,3 +180,31 @@ While Highlight.js provides support for [many popular languages out of the box]( } } ``` + +### Using Prism as additional syntax highlighter + +While highlight.js supports a lot of languages, you can opt to use Prism to syntax highlight certain languages available in the list [here](https://github.com/PrismJS/prism/tree/master/components). Include those languages in `usePrism` field in your [siteConfig.js](api-site-config.md) + +Example: +``` +// siteConfig.js +usePrism: ['jsx'] +``` + +Notice that the code block below uses JSX syntax highlighting from Prism. + +```jsx +class Example extends React.Component { + render() { + return ( + + Docusaurus +