Move complex conditional to a helper func
Vytautas Ĺ altenis vytas@rtfb.lt
Thu, 29 Oct 2015 20:02:11 +0200
1 files changed,
13 insertions(+),
5 deletions(-)
jump to
M
block.go
→
block.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 }