From 114d6b0d686dee9e73a4ef5440a467e872e52043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytautas=20=C5=A0altenis?= Date: Thu, 5 Nov 2015 22:00:37 +0200 Subject: [PATCH] Eradicate 'out' parameter in top level code --- markdown.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/markdown.go b/markdown.go index af903cc..39a8347 100644 --- a/markdown.go +++ b/markdown.go @@ -424,7 +424,7 @@ func firstPass(p *parser, input []byte) []byte { // track fenced code block boundaries to suppress tab expansion // inside them: if beg >= lastFencedCodeBlockEnd { - if i := p.fencedCode(&out, input[beg:], false); i > 0 { + if i := p.fencedCode(input[beg:], false); i > 0 { lastFencedCodeBlockEnd = beg + i } } @@ -461,36 +461,38 @@ func firstPass(p *parser, input []byte) []byte { // second pass: actual rendering func secondPass(p *parser, input []byte) []byte { - var output bytes.Buffer - - p.r.DocumentHeader(&output) - p.block(&output, input) + p.r.DocumentHeader() + p.block(input) if p.flags&Footnotes != 0 && len(p.notes) > 0 { - p.r.BeginFootnotes(&output) + p.r.BeginFootnotes() flags := ListItemBeginningOfList for i := 0; i < len(p.notes); i += 1 { ref := p.notes[i] var buf bytes.Buffer if ref.hasBlock { flags |= ListItemContainsBlock - p.block(&buf, ref.title) + buf.Write(p.r.CaptureWrites(func() { + p.block(ref.title) + })) } else { - p.inline(&buf, ref.title) + buf.Write(p.r.CaptureWrites(func() { + p.inline(ref.title) + })) } - p.r.FootnoteItem(&output, ref.link, buf.Bytes(), flags) + p.r.FootnoteItem(ref.link, buf.Bytes(), flags) flags &^= ListItemBeginningOfList | ListItemContainsBlock } - p.r.EndFootnotes(&output) + p.r.EndFootnotes() } - p.r.DocumentFooter(&output) + p.r.DocumentFooter() if p.nesting != 0 { panic("Nesting level did not end at zero") } - return output.Bytes() + return p.r.GetResult() } //