Browse Source

Add pluginsConfig.prism.lang to add support for custom syntax prefixes

Jani Eväkallio 7 years ago
parent
commit
cd7f16969f
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>
 #### Xonokai <small>`syntax-highlighting/assets/css/prism/prism-xonokai.css`</small>
 ![Google Light](http://i.imgur.com/fPjEEv8.png)
 ![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
 ## Credits
 
 
 Originally based on https://github.com/spricity/google_code_prettify.
 Originally based on https://github.com/spricity/google_code_prettify.

+ 2 - 1
index.js

@@ -69,10 +69,11 @@ module.exports = {
     code: function(block) {
     code: function(block) {
 
 
       var highlighted = '';
       var highlighted = '';
+      var userDefined = this.config.get('pluginsConfig.prism.lang', {});
 
 
       // Normalize language id
       // Normalize language id
       var lang = block.kwargs.language || DEFAULT_LANGUAGE;
       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
       // Try and find the language definition in components folder
       if (!languages[lang]) {
       if (!languages[lang]) {