diff --git a/lib/hexo/post.js b/lib/hexo/post.js index 77a7780312..a1c356b481 100644 --- a/lib/hexo/post.js +++ b/lib/hexo/post.js @@ -93,6 +93,8 @@ class PostRenderEscape { swig_tag_name = ''; swig_full_tag_start_buffer = ''; swig_tag_name_begin = false; // Mark if it is the first non white space char in the swig tag + } else { + output += char; } } else { output += char; diff --git a/test/scripts/hexo/post.js b/test/scripts/hexo/post.js index 6bba9a6aae..c9fdbc6060 100644 --- a/test/scripts/hexo/post.js +++ b/test/scripts/hexo/post.js @@ -902,6 +902,28 @@ describe('Post', () => { ].join('\n')); }); + it('render() - shouln\'t break curly brackets', async () => { + hexo.config.prismjs.enable = true; + hexo.config.highlight.enable = false; + + const content = [ + '\\begin{equation}', + 'E=h\\nu', + '\\end{equation}' + ].join('\n'); + + const data = await post.render(null, { + content, + engine: 'markdown' + }); + + data.content.should.include('\\begin{equation}'); + data.content.should.include('\\end{equation}'); + + hexo.config.prismjs.enable = false; + hexo.config.highlight.enable = true; + }); + // #2321 it('render() - allow backtick code block in "blockquote" tag plugin', async () => { const code = 'alert("Hello world")';