Skip to content

Commit

Permalink
test(post): add cases for issue hexojs#3346
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Mar 4, 2020
1 parent 2ef9c9b commit 32d5638
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/fixtures/post_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const code = [
' sleep()'
].join('\n');

const content = [
exports.content = [
'# Title',
'``` python',
code,
Expand All @@ -24,7 +24,19 @@ const content = [
'{% endquote %}'
].join('\n');

exports.content = content;
exports.content_for_issue_3346 = [
'# Title',
'```',
'{% test1 %}',
'{{ test2 }}',
'```',
'some content',
'',
'## Another title',
'{% blockquote %}',
'quote content',
'{% endblockquote %}'
].join('\n');

exports.expected = [
'<h1 id="Title"><a href="#Title" class="headerlink" title="Title"></a>Title</h1>',
Expand All @@ -50,3 +62,13 @@ exports.expected_disable_nunjucks = [
'quote content<br>',
'{% endquote %}</p>'
].join('');

exports.expected_for_issue_3346 = [
'<h1 id="Title"><a href="#Title" class="headerlink" title="Title"></a>Title</h1>',
highlight('{% test1 %}\n{{ test2 }}').replace(/{/g, '&#123;').replace(/}/g, '&#125;'), // Escaped by backtick_code_block
'\n<p>some content</p>\n',
'<h2 id="Another-title"><a href="#Another-title" class="headerlink" title="Another title"></a>Another title</h2>',
'<blockquote>',
'<p>quote content</p>\n',
'</blockquote>'
].join('');
11 changes: 11 additions & 0 deletions test/scripts/hexo/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -939,4 +939,15 @@ describe('Post', () => {
});
});

// test for Issue #3346
it('render() - swig tag inside backtick code block', () => {
const content = fixture.content_for_issue_3346;

return post.render(null, {
content,
engine: 'markdown'
}).then(data => {
data.content.trim().should.eql(fixture.expected_for_issue_3346);
});
});
});

0 comments on commit 32d5638

Please sign in to comment.