all repos — grayfriday @ 607f2ceb8a9183899fcc3026d23f115d733bad07

blackfriday fork with a few changes

Move complex conditional to a helper func
Vytautas Ĺ altenis vytas@rtfb.lt
Thu, 29 Oct 2015 20:02:11 +0200
commit

607f2ceb8a9183899fcc3026d23f115d733bad07

parent

133788657b0ddebf0e884571fc99a5528e55a10f

1 files changed, 13 insertions(+), 5 deletions(-)

jump to
M block.goblock.go

@@ -891,6 +891,18 @@ }

return 0 } +// blockquote ends with at least one blank line +// followed by something without a blockquote prefix +func terminateBlockquote(p *parser, data []byte, beg, end int) bool { + if p.isEmpty(data[beg:]) <= 0 { + return false + } + if end >= len(data) { + return true + } + return p.quotePrefix(data[end:]) == 0 && p.isEmpty(data[end:]) == 0 +} + // parse a blockquote fragment func (p *parser) quote(out *bytes.Buffer, data []byte) int { var raw bytes.Buffer

@@ -905,11 +917,7 @@

if pre := p.quotePrefix(data[beg:]); pre > 0 { // skip the prefix beg += pre - } else if p.isEmpty(data[beg:]) > 0 && - (end >= len(data) || - (p.quotePrefix(data[end:]) == 0 && p.isEmpty(data[end:]) == 0)) { - // blockquote ends with at least one blank line - // followed by something without a blockquote prefix + } else if terminateBlockquote(p, data, beg, end) { break }