From 4b793a1aed1c55f594fb592987e114094a824889 Mon Sep 17 00:00:00 2001 From: yuin Date: Sun, 17 Oct 2021 19:48:50 +0900 Subject: [PATCH] #248 - 11 --- _test/extra.txt | 10 ++++++++++ parser/parser.go | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/_test/extra.txt b/_test/extra.txt index 4c075f3..82c7267 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -591,3 +591,13 @@ a //- - - - - - - - -//

\v

//= = = = = = = = = = = = = = = = = = = = = = = =// + + +47: Escape back slashes should not be treated as hard line breaks +//- - - - - - - - -// +\\\\ +a +//- - - - - - - - -// +

\ +a

+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/parser/parser.go b/parser/parser.go index 362893d..0276bee 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -1132,11 +1132,11 @@ func (p *parser) parseBlock(block text.BlockReader, parent ast.Node, pc Context) softLinebreak := false hardlineBreak := false hasNewLine := line[lineLength-1] == '\n' - if lineLength >= 2 && line[lineLength-2] == '\\' && hasNewLine { // ends with \\n + if ((lineLength >= 3 && line[lineLength-2] == '\\' && line[lineLength-3] != '\\') || (lineLength == 2 && line[lineLength-2] == '\\')) && hasNewLine { // ends with \\n lineLength -= 2 hardlineBreak = true - } else if lineLength >= 3 && line[lineLength-3] == '\\' && line[lineLength-2] == '\r' && hasNewLine { // ends with \\r\n + } else if ((lineLength >= 4 && line[lineLength-3] == '\\' && line[lineLength-2] == '\r' && line[lineLength-4] != '\\') || (lineLength == 3 && line[lineLength-3] == '\\' && line[lineLength-2] == '\r')) && hasNewLine { // ends with \\r\n lineLength -= 3 hardlineBreak = true } else if lineLength >= 3 && line[lineLength-3] == ' ' && line[lineLength-2] == ' ' && hasNewLine { // ends with [space][space]\n