From f151995e16c18adf963fd61c6e4a893c634ae3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jani=20Ev=C3=A4kallio?= Date: Tue, 31 Jan 2017 01:20:42 +0000 Subject: [PATCH 1/2] Add alias "sh" for bash syntax --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index bb999c3..862ca57 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,7 @@ var MAP_LANGUAGES = { 'js': 'javascript', 'rb': 'ruby', 'cs': 'csharp', + 'sh': 'bash', 'html': 'markup' }; From cd7f16969f11d2ea79968078fae9ea56ffd5e2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jani=20Ev=C3=A4kallio?= Date: Tue, 31 Jan 2017 01:29:07 +0000 Subject: [PATCH 2/2] Add pluginsConfig.prism.lang to add support for custom syntax prefixes --- README.md | 13 +++++++++++++ index.js | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 91e214c..52a7cdf 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,19 @@ Override default styles. All css files must reside in the same folder. #### Xonokai `syntax-highlighting/assets/css/prism/prism-xonokai.css` ![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. diff --git a/index.js b/index.js index bb999c3..3d30735 100644 --- a/index.js +++ b/index.js @@ -69,10 +69,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]) {