From efd02561b29c065ba6db564efb0f07c7ef0c053c Mon Sep 17 00:00:00 2001 From: meteorlxy Date: Wed, 29 May 2019 16:29:30 +0800 Subject: [PATCH] fix(saber-highlighter-prism): add aliases for some languages (#220) * fix(saber-highlighter-prism): add aliases for some languages * fix lint --- packages/saber-highlighter-prism/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/saber-highlighter-prism/index.js b/packages/saber-highlighter-prism/index.js index 2dd1c7ec3..70614e3cc 100644 --- a/packages/saber-highlighter-prism/index.js +++ b/packages/saber-highlighter-prism/index.js @@ -2,13 +2,19 @@ const Prism = require('prismjs') const { log } = require('saber-log') const loadLanguages = require('./loadLanguages') +const languageAlias = { + vue: 'html', + sh: 'bash', + styl: 'stylus' +} + module.exports = (code, lang) => { if (!lang) return Prism.highlight(code, {}) lang = lang.toLowerCase() - if (lang === 'vue') { - lang = 'html' + if (lang in languageAlias) { + lang = languageAlias[lang] } if (!Prism.languages[lang]) {