Skip to content

Commit

Permalink
fix(saber-highlighter-prism): add aliases for some languages (#220)
Browse files Browse the repository at this point in the history
* fix(saber-highlighter-prism): add aliases for some languages

* fix lint
  • Loading branch information
meteorlxy authored and egoist committed May 29, 2019
1 parent f3ec588 commit efd0256
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/saber-highlighter-prism/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down

0 comments on commit efd0256

Please sign in to comment.