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

refactor(post/tag): render tag before content #4171

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test(post): add cases for issue #3346
SukkaW committed Mar 4, 2020

Verified

This commit was signed with the committer’s verified signature. The key has expired.
tvdeyen Thomas von Deyen
commit 32d563811a3cdfb6b6b76a69318066079a36ce0b
26 changes: 24 additions & 2 deletions test/fixtures/post_render.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ const code = [
' sleep()'
].join('\n');

const content = [
exports.content = [
'# Title',
'``` python',
code,
@@ -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>',
@@ -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
@@ -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);
});
});
});