Skip to content

Commit fc02edc

Browse files
uioleeyoshinorin
authored andcommitted
feat(highlight): add an option to switch stripIndent (hexojs#5427)
Co-authored-by: yoshinorin <[email protected]>
1 parent 461fa1c commit fc02edc

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

lib/hexo/default_config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ export = {
4848
language_attr: false,
4949
hljs: false,
5050
line_threshold: 0,
51-
first_line_number: 'always1'
51+
first_line_number: 'always1',
52+
strip_indent: true
5253
},
5354
prismjs: {
5455
preprocess: true,
5556
line_number: true,
5657
tab_replace: '',
57-
exclude_languages: []
58+
exclude_languages: [],
59+
strip_indent: true
5860
},
5961
// Category & Tag
6062
default_category: 'uncategorized',

lib/plugins/highlight/highlight.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ module.exports = function highlightFilter(this: Hexo, code: string, options: Opt
3333
languageAttr,
3434
mark: options.mark,
3535
tab: hljsCfg.tab_replace,
36-
wrap: hljsCfg.wrap
36+
wrap: hljsCfg.wrap,
37+
stripIndent: hljsCfg.strip_indent
3738
};
3839
if (hljsCfg.first_line_number === 'inline') {
3940
if (typeof options.firstLineNumber !== 'undefined') {

lib/plugins/highlight/prism.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ module.exports = function(code, options) {
1515
lang: options.lang,
1616
lineNumber,
1717
mark: options.mark,
18-
tab: prismjsCfg.tab_replace
18+
tab: prismjsCfg.tab_replace,
19+
stripIndent: prismjsCfg.strip_indent
1920
};
2021

2122
if (!prismHighlight) prismHighlight = require('hexo-util').prismHighlight;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"hexo-fs": "^4.1.1",
4747
"hexo-i18n": "^2.0.0",
4848
"hexo-log": "^4.0.1",
49-
"hexo-util": "^3.0.1",
49+
"hexo-util": "^3.3.0",
5050
"js-yaml": "^4.1.0",
5151
"js-yaml-js-types": "^1.0.0",
5252
"micromatch": "^4.0.4",

0 commit comments

Comments
 (0)