Fix bug where newlines were inserted inside fenced code blocks.

Change firstPass() code that checks for fenced code blocks to check all
of them and properly keep track of lastFencedCodeBlockEnd.
This way, it won't misinterpret the end of a fenced code block as a
beginning of a new one.
This commit is contained in:
Dmitri Shuralyov 2014-04-11 21:27:28 -07:00
parent ef2a2b02dc
commit 8df342acd5

View File

@ -330,9 +330,11 @@ func firstPass(p *parser, input []byte) []byte {
if p.flags&EXTENSION_FENCED_CODE != 0 {
// when last line was none blank and a fenced code block comes after
if !lastLineWasBlank && beg >= lastFencedCodeBlockEnd {
if beg >= lastFencedCodeBlockEnd {
if i := p.fencedCode(&out, append(input[beg:], '\n'), false); i > 0 {
out.WriteByte('\n') // need to inject additional linebreak
if !lastLineWasBlank {
out.WriteByte('\n') // need to inject additional linebreak
}
lastFencedCodeBlockEnd = beg + i
}
}