Skip to content

Commit

Permalink
fix: console log Unknown language: ""
Browse files Browse the repository at this point in the history
highlight.js throws an error for option `{auto: false}` if no language
is given. As an ugly side-effect this error is logged via console.log.
Setting the language in thoses cases to `plaintext` prevents this.
  • Loading branch information
commenthol committed Mar 1, 2020
1 parent 94a9fe6 commit 8efa3c3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -10,7 +10,7 @@ const maybe = f => {

// Highlight with given language.
const highlight = (code, lang) =>
maybe(() => hljs.highlight(lang, code, true).value) || ''
maybe(() => hljs.highlight(lang || 'plaintext', code, true).value) || ''

// Highlight with given language or automatically.
const highlightAuto = (code, lang) =>
Expand Down
2 changes: 1 addition & 1 deletion test.js
@@ -1,4 +1,4 @@
const { equal } = require('assert')
const { strictEqual: equal } = require('assert')
const md = require('markdown-it')
const highlightjs = require('./')

Expand Down

0 comments on commit 8efa3c3

Please sign in to comment.