From c1bf6d4bdfbcdad07f7257af8c0685908b477fe4 Mon Sep 17 00:00:00 2001 From: Hao Luo Date: Fri, 25 Aug 2017 20:17:22 -0500 Subject: [PATCH 1/4] added ignore prism config --- README.md | 14 ++++++++++++++ index.js | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 4a14fdf..c997afd 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,20 @@ Support non-standard syntax prefixes by aliasing existing prefixes. } ``` +### `ignore` +Due to other plugins using code block notion to denote other functionality, you can ignore certain langs + +```json +"pluginsConfig": { + "prism": { + "ignore": [ + "mermaid", //used by https://github.com/yanni4night/gitbook-plugin-mermaid-full + "eval-js" //used by https://github.com/brian-dawn/gitbook-plugin-klipse + ] + } +} +``` + ### Prism Themes [https://github.com/PrismJS/prism](https://github.com/PrismJS/) diff --git a/index.js b/index.js index 4ebd8fb..7b5c9fe 100644 --- a/index.js +++ b/index.js @@ -86,11 +86,17 @@ module.exports = { var highlighted = ''; var userDefined = getConfig(this, 'pluginsConfig.prism.lang', {}); + var userIgnored = getConfig(this, 'pluginsConfig.prism.ignore', []); // Normalize language id var lang = block.kwargs.language || DEFAULT_LANGUAGE; lang = userDefined[lang] || MAP_LANGUAGES[lang] || lang; + // Check to see if the lang is ignored + if (userIgnored.indexOf(lang) === -1) { + return block.body + } + // Try and find the language definition in components folder if (!languages[lang]) { try { From 5be46eb8c0be9abacac235db674b740536519670 Mon Sep 17 00:00:00 2001 From: Hao Luo Date: Fri, 25 Aug 2017 20:31:46 -0500 Subject: [PATCH 2/4] fixed logic error --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7b5c9fe..b2ff9d4 100644 --- a/index.js +++ b/index.js @@ -93,7 +93,7 @@ module.exports = { lang = userDefined[lang] || MAP_LANGUAGES[lang] || lang; // Check to see if the lang is ignored - if (userIgnored.indexOf(lang) === -1) { + if (userIgnored.indexOf(lang) > -1) { return block.body } From 67ff4753e36a241ac9d88939a3d628712c8c5e7d Mon Sep 17 00:00:00 2001 From: Hao Luo Date: Fri, 25 Aug 2017 20:36:48 -0500 Subject: [PATCH 3/4] upped minor version per semantic versioning --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c96a9e2..e56b647 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "gitbook-plugin-prism", "description": "Prism highlighting for gitbook", "main": "index.js", - "version": "2.2.1", + "version": "2.3.1", "scripts": { "lint": "eslint index.js test.js", "test": "npm run lint && tape test.js" From 9b167f755eed83844e66cf9ecf3614021c33b3c6 Mon Sep 17 00:00:00 2001 From: Hao Luo Date: Fri, 25 Aug 2017 20:39:17 -0500 Subject: [PATCH 4/4] removed comments in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c997afd..b795e0b 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ Due to other plugins using code block notion to denote other functionality, you "pluginsConfig": { "prism": { "ignore": [ - "mermaid", //used by https://github.com/yanni4night/gitbook-plugin-mermaid-full - "eval-js" //used by https://github.com/brian-dawn/gitbook-plugin-klipse + "mermaid", + "eval-js" ] } }