diff --git a/lib/plugins/filter/before_post_render/backtick_code_block.js b/lib/plugins/filter/before_post_render/backtick_code_block.js index 59c2304971..07b2691ff3 100644 --- a/lib/plugins/filter/before_post_render/backtick_code_block.js +++ b/lib/plugins/filter/before_post_render/backtick_code_block.js @@ -9,6 +9,7 @@ const rLangCaption = /([^\s]+)\s*(.+)?/; function backtickCodeBlock(data) { const config = this.config.highlight || {}; + const { log } = this; if (!config.enable) return; data.content = data.content.replace(rBacktick, ($0, start, $2, _args, content, end) => { const args = _args.split('=').shift(); @@ -35,6 +36,13 @@ function backtickCodeBlock(data) { } } + if (options.exclude_languages && Array.isArray(options.exclude_languages)) { + // The exclude_languages is an array + } else { + log.debug(`The highlight.exclude_languages does not work with: ${options.exclude_languages}`); + options.exclude_languages = []; + } + if (args) { const match = rAllOptions.exec(args) || rLangCaption.exec(args); @@ -50,13 +58,11 @@ function backtickCodeBlock(data) { } } - if (options.exclude_languages) { - if (options.exclude_languages.includes(options.lang)) { - // Only wrap with
- options.wrap = false; - options.gutter = false; - options.autoDetect = false; - } + if (options.exclude_languages.includes(options.lang)) { + // Only wrap with
+ options.wrap = false; + options.gutter = false; + options.autoDetect = false; } } }