Browse Source

Merge pull request #20 from jevakallio/user-defined-alias

Add pluginsConfig.prism.lang to add support for custom syntax prefixes
robert mcguinness 7 years ago
parent
commit
91469bebca
2 changed files with 15 additions and 1 deletions
  1. 13 0
      README.md
  2. 2 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.

+ 2 - 1
index.js

@@ -70,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]) {