Browse Source

added ignore prism config

Hao Luo 7 years ago
parent
commit
c1bf6d4bdf
2 changed files with 20 additions and 0 deletions
  1. 14 0
      README.md
  2. 6 0
      index.js

+ 14 - 0
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/)

+ 6 - 0
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 {