From 8549b83b0c19946dda0302c5ef78e6c767ac67e6 Mon Sep 17 00:00:00 2001 From: yuin Date: Fri, 29 Nov 2019 17:21:05 +0900 Subject: [PATCH] Fixes gohugoio/hugo#6549 --- _test/extra.txt | 12 ++++++++++++ parser/parser.go | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/_test/extra.txt b/_test/extra.txt index 70570b5..11e3a12 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -8,3 +8,15 @@ B //= = = = = = = = = = = = = = = = = = = = = = = =// +2 +//- - - - - - - - -// +**test**\ +test**test**\ +**test**test\ +test**test** +//- - - - - - - - -// +

test
+testtest
+testtest
+testtest

+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/parser/parser.go b/parser/parser.go index d9f54f5..9eb0b8a 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -1088,17 +1088,17 @@ func (p *parser) parseBlock(block text.BlockReader, parent ast.Node, pc Context) lineLength := len(line) hardlineBreak := false softLinebreak := line[lineLength-1] == '\n' - if lineLength > 2 && line[lineLength-2] == '\\' && softLinebreak { // ends with \\n + if lineLength >= 2 && line[lineLength-2] == '\\' && softLinebreak { // ends with \\n lineLength -= 2 hardlineBreak = true - } else if lineLength > 3 && line[lineLength-3] == '\\' && line[lineLength-2] == '\r' && softLinebreak { // ends with \\r\n + } else if lineLength >= 3 && line[lineLength-3] == '\\' && line[lineLength-2] == '\r' && softLinebreak { // ends with \\r\n lineLength -= 3 hardlineBreak = true - } else if lineLength > 3 && line[lineLength-3] == ' ' && line[lineLength-2] == ' ' && softLinebreak { // ends with [space][space]\n + } else if lineLength >= 3 && line[lineLength-3] == ' ' && line[lineLength-2] == ' ' && softLinebreak { // ends with [space][space]\n lineLength -= 3 hardlineBreak = true - } else if lineLength > 4 && line[lineLength-4] == ' ' && line[lineLength-3] == ' ' && line[lineLength-2] == '\r' && softLinebreak { // ends with [space][space]\r\n + } else if lineLength >= 4 && line[lineLength-4] == ' ' && line[lineLength-3] == ' ' && line[lineLength-2] == '\r' && softLinebreak { // ends with [space][space]\r\n lineLength -= 4 hardlineBreak = true }