From af1b26fa0429f4f0393ee865a693a2a0746d3e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytautas=20=C5=A0altenis?= Date: Mon, 26 Oct 2015 20:32:33 +0200 Subject: [PATCH] Remove callback from List renderer event Split List into two events: BeginList and EndList, removing the need for callback. --- block.go | 17 ++++++++--------- html.go | 10 +++++++--- latex.go | 6 ++++-- markdown.go | 3 ++- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/block.go b/block.go index ff5ef49..298aa4d 100644 --- a/block.go +++ b/block.go @@ -1050,19 +1050,18 @@ func (p *parser) dliPrefix(data []byte) int { func (p *parser) list(out *bytes.Buffer, data []byte, flags ListType) int { i := 0 flags |= ListItemBeginningOfList - work := func() { - for i < len(data) { - skip := p.listItem(out, data[i:], &flags) - i += skip + p.r.BeginList(out, flags) - if skip == 0 || flags&ListItemEndOfList != 0 { - break - } - flags &= ^ListItemBeginningOfList + for i < len(data) { + skip := p.listItem(out, data[i:], &flags) + i += skip + if skip == 0 || flags&ListItemEndOfList != 0 { + break } + flags &= ^ListItemBeginningOfList } - p.r.List(out, work, flags) + p.r.EndList(out, flags) return i } diff --git a/html.go b/html.go index 4654911..12c60b5 100644 --- a/html.go +++ b/html.go @@ -345,7 +345,9 @@ func (options *Html) TableCell(out *bytes.Buffer, text []byte, align int) { func (options *Html) Footnotes(out *bytes.Buffer, text func()) { out.WriteString("
\n") options.HRule(out) - options.List(out, text, ListTypeOrdered) + options.BeginList(out, ListTypeOrdered) + text() + options.EndList(out, ListTypeOrdered) out.WriteString("
\n") } @@ -372,7 +374,7 @@ func (options *Html) FootnoteItem(out *bytes.Buffer, name, text []byte, flags Li out.WriteString("\n") } -func (options *Html) List(out *bytes.Buffer, text func(), flags ListType) { +func (options *Html) BeginList(out *bytes.Buffer, flags ListType) { doubleSpace(out) if flags&ListTypeDefinition != 0 { @@ -382,7 +384,9 @@ func (options *Html) List(out *bytes.Buffer, text func(), flags ListType) { } else { out.WriteString("