Skip to content

Commit

Permalink
feat(highlight): add an option to disable stripIndent
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Feb 20, 2024
1 parent 6bf9e6c commit 7dd017f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/hexo/default_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ export = {
language_attr: false,
hljs: false,
line_threshold: 0,
first_line_number: 'always1'
first_line_number: 'always1',
disable_strip_indent: false
},
prismjs: {
preprocess: true,
line_number: true,
tab_replace: '',
exclude_languages: []
exclude_languages: [],
disable_strip_indent: false
},
// Category & Tag
default_category: 'uncategorized',
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/highlight/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
disableStripIndent: hljsCfg.disable_strip_indent
};
if (hljsCfg.first_line_number === 'inline') {
if (typeof options.firstLineNumber !== 'undefined') {
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/highlight/prism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = function(code, options) {
lang: options.lang,
lineNumber,
mark: options.mark,
tab: prismjsCfg.tab_replace
tab: prismjsCfg.tab_replace,
disableStripIndent: prismjsCfg.disable_strip_indent
};

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

0 comments on commit 7dd017f

Please sign in to comment.