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.
Dmitri Shuralyov shurcooL@gmail.com
Fri, 11 Apr 2014 21:27:28 -0700
1 files changed,
4 insertions(+),
2 deletions(-)
jump to
M
markdown.go
→
markdown.go
@@ -330,9 +330,11 @@ }
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 } }