diff --git a/test/fixtures/post_render.js b/test/fixtures/post_render.js index c6f7f067a0..a03afe7f09 100644 --- a/test/fixtures/post_render.js +++ b/test/fixtures/post_render.js @@ -7,7 +7,7 @@ const code = [ ' sleep()' ].join('\n'); -const content = [ +exports.content = [ '# Title', '``` python', code, @@ -24,8 +24,6 @@ const content = [ '{% endquote %}' ].join('\n'); -exports.content = content; - exports.expected = [ '
some content
\n', + '', + '' +].join(''); diff --git a/test/scripts/hexo/post.js b/test/scripts/hexo/post.js index 846c3ef3f5..6e42af176b 100644 --- a/test/scripts/hexo/post.js +++ b/test/scripts/hexo/post.js @@ -939,4 +939,52 @@ describe('Post', () => { }); }); + // test for Issue #3346 + it('render() - swig tag inside backtick code block', async () => { + const content = fixture.content_for_issue_3346; + + const data = await post.render(null, { + content, + engine: 'markdown' + }); + + data.content.trim().should.eql(fixture.expected_for_issue_3346); + }); + + // test for https://github.com/hexojs/hexo/pull/4171#issuecomment-594412367 + it('render() - markdown content right after swig tag', async () => { + const content = [ + '{% pullquote warning %}', + 'Text', + '{% endpullquote %}', + '# Title 0', + '{% pullquote warning %}', + 'Text', + '{% endpullquote %}', + '{% pullquote warning %}', + 'Text', + '{% endpullquote %}', + '# Title 1', + '{% pullquote warning %}', + 'Text', + '{% endpullquote %}', + '{% pullquote warning %}Text{% endpullquote %}', + '# Title 2', + '{% pullquote warning %}Text{% endpullquote %}', + '{% pullquote warning %}Text{% endpullquote %}', + '# Title 3', + '{% pullquote warning %}Text{% endpullquote %}' + ].join('\n'); + + const data = await post.render(null, { + content, + engine: 'markdown' + }); + + // We only to make sure markdown content is rendered correctly + data.content.trim().should.include('quote content
\n', + '