diff --git a/lib/hexo/post.ts b/lib/hexo/post.ts index 0d6810a50e..790a540663 100644 --- a/lib/hexo/post.ts +++ b/lib/hexo/post.ts @@ -69,7 +69,7 @@ class PostRenderEscape { * @returns string */ escapeAllSwigTags(str: string) { - if (!/(\{\{.+?\}\})|(\{#.+?#\})|(\{%.+?%\})/.test(str)) { + if (!/(\{\{.+?\}\})|(\{#.+?#\})|(\{%.+?%\})/s.test(str)) { return str; } let state = STATE_PLAINTEXT; diff --git a/test/scripts/hexo/post.js b/test/scripts/hexo/post.js index cf7dd423b2..109bf2367b 100644 --- a/test/scripts/hexo/post.js +++ b/test/scripts/hexo/post.js @@ -1396,4 +1396,22 @@ describe('Post', () => { should.fail(); } catch (err) {} }); + + // https://github.com/hexojs/hexo/issues/5401 + it('render() - tags in different lines', async () => { + const content = [ + '{% link', + 'foobar', + 'https://hexo.io/', + 'tttitle', + '%}' + ].join('\n'); + + const data = await post.render(null, { + content, + engine: 'markdown' + }); + + data.content.should.eql('foobar'); + }); });