diff --git a/lib/hexo/post.js b/lib/hexo/post.js index 462f650ffc..2251a1592a 100644 --- a/lib/hexo/post.js +++ b/lib/hexo/post.js @@ -70,6 +70,7 @@ class PostRenderEscape { let output = ''; let swig_tag_name_begin = false; + let swig_tag_name_end = false; let swig_tag_name = ''; let swig_full_tag_start_buffer = ''; @@ -93,6 +94,7 @@ 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 + swig_tag_name_end = false; } else { output += char; } @@ -116,7 +118,7 @@ class PostRenderEscape { swig_full_tag_start_buffer = swig_full_tag_start_buffer + char; if (isNonWhiteSpaceChar(char)) { - if (!swig_tag_name_begin) { + if (!swig_tag_name_begin && !swig_tag_name_end) { swig_tag_name_begin = true; } @@ -126,6 +128,7 @@ class PostRenderEscape { } else { if (swig_tag_name_begin === true) { swig_tag_name_begin = false; + swig_tag_name_end = true; } } } diff --git a/test/fixtures/post_render.js b/test/fixtures/post_render.js index bca5d3c60e..d728191b60 100644 --- a/test/fixtures/post_render.js +++ b/test/fixtures/post_render.js @@ -32,7 +32,7 @@ exports.expected = [ '
', '

quote content 1

\n', '
\n\n', - '

quote content 2

', + '

quote content 2

\n', '
' ].join('');