diff --git a/lib/hexo/default_config.ts b/lib/hexo/default_config.ts index 39c9a6be79..39ec6f4dd8 100644 --- a/lib/hexo/default_config.ts +++ b/lib/hexo/default_config.ts @@ -48,13 +48,15 @@ export = { language_attr: false, hljs: false, line_threshold: 0, - first_line_number: 'always1' + first_line_number: 'always1', + strip_indent: true }, prismjs: { preprocess: true, line_number: true, tab_replace: '', - exclude_languages: [] + exclude_languages: [], + strip_indent: true }, // Category & Tag default_category: 'uncategorized', diff --git a/lib/plugins/highlight/highlight.ts b/lib/plugins/highlight/highlight.ts index 04d507ec92..ddc79902f1 100644 --- a/lib/plugins/highlight/highlight.ts +++ b/lib/plugins/highlight/highlight.ts @@ -33,7 +33,8 @@ module.exports = function highlightFilter(this: Hexo, code: string, options: Opt languageAttr, mark: options.mark, tab: hljsCfg.tab_replace, - wrap: hljsCfg.wrap + wrap: hljsCfg.wrap, + stripIndent: hljsCfg.strip_indent }; if (hljsCfg.first_line_number === 'inline') { if (typeof options.firstLineNumber !== 'undefined') { diff --git a/lib/plugins/highlight/prism.ts b/lib/plugins/highlight/prism.ts index 33304068d4..55da21d02e 100644 --- a/lib/plugins/highlight/prism.ts +++ b/lib/plugins/highlight/prism.ts @@ -15,7 +15,8 @@ module.exports = function(code, options) { lang: options.lang, lineNumber, mark: options.mark, - tab: prismjsCfg.tab_replace + tab: prismjsCfg.tab_replace, + stripIndent: prismjsCfg.strip_indent }; if (!prismHighlight) prismHighlight = require('hexo-util').prismHighlight; diff --git a/package.json b/package.json index 1bf2ee98cd..15e4ee3c76 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "hexo-fs": "^4.1.1", "hexo-i18n": "^2.0.0", "hexo-log": "^4.0.1", - "hexo-util": "^3.0.1", + "hexo-util": "^3.3.0", "js-yaml": "^4.1.0", "js-yaml-js-types": "^1.0.0", "micromatch": "^4.0.4",