From e9fd47e204aadc54fb4d53a7bdb0e44957ccd8e7 Mon Sep 17 00:00:00 2001 From: sinedied Date: Tue, 14 Sep 2021 15:49:48 +0200 Subject: [PATCH] fix: remove highlight warning --- lib/renderer.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/renderer.js b/lib/renderer.js index 007f13c..e7ae39f 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -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'); @@ -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;