Implement backslash hard line break

See http://spec.commonmark.org/0.18/#example-527
This commit is contained in:
neclepsio 2015-04-22 12:23:19 +02:00
parent 17bb7999de
commit 2824a549c3
1 changed files with 2 additions and 1 deletions

View File

@ -167,9 +167,10 @@ func lineBreak(p *parser, out *bytes.Buffer, data []byte, offset int) int {
out.Truncate(eol) out.Truncate(eol)
precededByTwoSpaces := offset >= 2 && data[offset-2] == ' ' && data[offset-1] == ' ' precededByTwoSpaces := offset >= 2 && data[offset-2] == ' ' && data[offset-1] == ' '
precededByBackslash := offset >= 1 && data[offset-1] == '\\' // see http://spec.commonmark.org/0.18/#example-527
// should there be a hard line break here? // should there be a hard line break here?
if p.flags&EXTENSION_HARD_LINE_BREAK == 0 && !precededByTwoSpaces { if p.flags&EXTENSION_HARD_LINE_BREAK == 0 && !precededByTwoSpaces && !precededByBackslash {
return 0 return 0
} }