Skip to content

Commit

Permalink
fix: remove highlight warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Sep 14, 2021
1 parent d100302 commit e9fd47e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require('path');
const fs = require('fs-extra');
const normalizePath = require('normalize-path');
const marked = require('marked');
const highlight = require('highlight.js');
const {highlight} = require('highlight.js');
const removeMd = require('remove-markdown');
const humanize = require('string-humanize');

Expand Down Expand Up @@ -146,11 +146,12 @@ class Renderer {
smartLists: true,
breaks: false,
smartypants: true,
highlight: (code, lang) => {
highlight: (code, language) => {
try {
code = lang && lang !== 'no-highlight' ? highlight.highlight(lang, code, true).value : code;
code = language && language !== 'no-highlight' ?
highlight(code, {language, ignoreIllegals: true}).value : code;
} catch (_) {
console.error(`Unsupported language for highlighting: ${lang}`);
console.error(`Unsupported language for highlighting: ${language}`);
}

return code;
Expand Down

0 comments on commit e9fd47e

Please sign in to comment.