Browse Source

Merge pull request #29 from howlowck/master

Added `ignore` config to ignore langs from other plugins
robert mcguinness 6 years ago
parent
commit
20db34e359
3 changed files with 21 additions and 1 deletions
  1. 14 0
      README.md
  2. 6 0
      index.js
  3. 1 1
      package.json

+ 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",
+      "eval-js"
+    ]
+  }
+}
+```
+
 ### 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 {

+ 1 - 1
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"