diff --git a/lib/hexo/default_config.ts b/lib/hexo/default_config.ts index 379f80737e..5e01f5781d 100644 --- a/lib/hexo/default_config.ts +++ b/lib/hexo/default_config.ts @@ -51,7 +51,8 @@ export = { prismjs: { preprocess: true, line_number: true, - tab_replace: '' + tab_replace: '', + exclude_languages: [] }, // Category & Tag default_category: 'uncategorized', diff --git a/lib/plugins/highlight/prism.ts b/lib/plugins/highlight/prism.ts index 1e37674fd0..33304068d4 100644 --- a/lib/plugins/highlight/prism.ts +++ b/lib/plugins/highlight/prism.ts @@ -20,5 +20,9 @@ module.exports = function(code, options) { if (!prismHighlight) prismHighlight = require('hexo-util').prismHighlight; + if (Array.isArray(prismjsCfg.exclude_languages) && prismjsCfg.exclude_languages.includes(prismjsOptions.lang)) { + // Only wrap with
+ return `${require('hexo-util').escapeHTML(code)}
`;
+ }
return prismHighlight(code, prismjsOptions);
};
diff --git a/test/scripts/filters/backtick_code_block.js b/test/scripts/filters/backtick_code_block.js
index 4b7c932f52..5c75bbccdb 100644
--- a/test/scripts/filters/backtick_code_block.js
+++ b/test/scripts/filters/backtick_code_block.js
@@ -635,5 +635,20 @@ describe('Backtick code block', () => {
codeBlock(data);
data.content.should.eql('${escapeSwigTag(util.escapeHTML(code))}
`;
+ codeBlock(data);
+ data.content.should.eql('