Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(highlight): add an option to switch stripIndent #5427

Merged
merged 5 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
strip_indent: true
},
prismjs: {
preprocess: true,
line_number: true,
tab_replace: '',
exclude_languages: []
exclude_languages: [],
strip_indent: true
},
// 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,
stripIndent: hljsCfg.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,
stripIndent: prismjsCfg.strip_indent
};

if (!prismHighlight) prismHighlight = require('hexo-util').prismHighlight;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,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",
Expand Down
Loading