diff --git a/lib/hexo/post.js b/lib/hexo/post.js index fc0ac7cc81..1d62074eca 100644 --- a/lib/hexo/post.js +++ b/lib/hexo/post.js @@ -43,7 +43,7 @@ class PostRenderCache { const rSwigVar = /\{\{[\s\S]*?\}\}/g; const rSwigComment = /\{#[\s\S]*?#\}/g; const rSwigBlock = /\{%[\s\S]*?%\}/g; - const rSwigFullBlock = /\{% *(.+?)(?: *| +.*)%\}[\s\S]+?\{% *end\1 *%\}/g; + const rSwigFullBlock = /\{% *(.+?)(?: *| +.*?)%\}[\s\S]+?\{% *end\1 *%\}/g; const escape = _str => _escapeContent(this.cache, _str); return str.replace(rSwigFullBlock, escape) diff --git a/test/scripts/hexo/post.js b/test/scripts/hexo/post.js index ce236f8019..a02b8b4a8e 100644 --- a/test/scripts/hexo/post.js +++ b/test/scripts/hexo/post.js @@ -888,4 +888,48 @@ describe('Post', () => { }); }); + // test for PR #4161 + it('render() - adjacent tags', () => { + const content = [ + '{% pullquote %}content1{% endpullquote %}', + '', + 'This is a following paragraph', + '', + '{% pullquote %}content2{% endpullquote %}' + ].join('\n'); + + return post.render(null, { + content, + engine: 'markdown' + }).then(data => { + data.content.trim().should.eql([ + '
\n', + 'content1
\n
This is a following paragraph
\n', + '\n' + ].join('')); + }); + }); + + // test for PR #4161 + it('render() - adjacent tags with args', () => { + const content = [ + '{% pullquote center %}content1{% endpullquote %}', + '', + 'This is a following paragraph', + '', + '{% pullquote center %}content2{% endpullquote %}' + ].join('\n'); + + return post.render(null, { + content, + engine: 'markdown' + }).then(data => { + data.content.trim().should.eql([ + 'content2
\n
\n', + 'content1
\n
This is a following paragraph
\n', + '\n' + ].join('')); + }); + }); + });content2
\n