Skip to content
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
3 changes: 2 additions & 1 deletion lib/hexo/default_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ module.exports = {
enable: true,
auto_detect: false,
line_number: true,
tab_replace: ''
tab_replace: '',
wrap: true
},
// Category & Tag
default_category: 'uncategorized',
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/filter/before_post_render/backtick_code_block.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function backtickCodeBlock(data) {
hljs: config.hljs,
autoDetect: config.auto_detect,
gutter: config.line_number,
tab: config.tab_replace
tab: config.tab_replace,
wrap: config.wrap
};

if (options.gutter) {
Expand Down
17 changes: 17 additions & 0 deletions test/scripts/filters/backtick_code_block.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,21 @@ describe('Backtick code block', () => {
codeBlock(data);
data.content.should.eql('<escape>' + expected + '</escape>');
});

it('wrap', () => {
hexo.config.highlight.wrap = false;

const data = {
content: [
'``` js',
code,
'```'
].join('\n')
};

codeBlock(data);
data.content.should.eql('<escape>' + highlight(code, { lang: 'js', wrap: false }) + '</escape>');

hexo.config.highlight.wrap = true;
});
});