Browse Source

Merge branch 'master' of https://github.com/gaearon/gitbook-plugin-prism

Rob McGuinness 7 years ago
parent
commit
8763941e86
2 changed files with 16 additions and 1 deletions
  1. 13 0
      README.md
  2. 3 1
      index.js

+ 13 - 0
README.md

@@ -65,6 +65,19 @@ Override default styles.  All css files must reside in the same folder.
 #### Xonokai <small>`syntax-highlighting/assets/css/prism/prism-xonokai.css`</small>
 ![Google Light](http://i.imgur.com/fPjEEv8.png)
 
+### Syntax aliasing
+
+To support non-standard syntax prefixes, you can alias existing prefixes:
+```json
+"pluginsConfig": {  
+  "prism": {
+    "lang": {
+      "flow": "typescript"
+    }
+  }
+}
+```
+
 ## Credits
 
 Originally based on https://github.com/spricity/google_code_prettify.

+ 3 - 1
index.js

@@ -11,6 +11,7 @@ var MAP_LANGUAGES = {
   'js': 'javascript',
   'rb': 'ruby',
   'cs': 'csharp',
+  'sh': 'bash',
   'html': 'markup'
 };
 
@@ -69,10 +70,11 @@ module.exports = {
     code: function(block) {
 
       var highlighted = '';
+      var userDefined = this.config.get('pluginsConfig.prism.lang', {});
 
       // Normalize language id
       var lang = block.kwargs.language || DEFAULT_LANGUAGE;
-      lang = MAP_LANGUAGES[lang] || lang;
+      lang = userDefined[lang] || MAP_LANGUAGES[lang] || lang;
 
       // Try and find the language definition in components folder
       if (!languages[lang]) {