Remove callback from List renderer event Split List into two events: BeginList and EndList, removing the need for callback.
Vytautas Ĺ altenis vytas@rtfb.lt
Mon, 26 Oct 2015 20:32:33 +0200
4 files changed,
21 insertions(+),
15 deletions(-)
M
block.go
→
block.go
@@ -1050,19 +1050,18 @@ // parse ordered or unordered list block
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 }
M
html.go
→
html.go
@@ -345,7 +345,9 @@
func (options *Html) Footnotes(out *bytes.Buffer, text func()) { out.WriteString("<div class=\"footnotes\">\n") options.HRule(out) - options.List(out, text, ListTypeOrdered) + options.BeginList(out, ListTypeOrdered) + text() + options.EndList(out, ListTypeOrdered) out.WriteString("</div>\n") }@@ -372,7 +374,7 @@ }
out.WriteString("</li>\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 @@ out.WriteString("<ol>")
} else { out.WriteString("<ul>") } - text() +} + +func (r *Html) EndList(out *bytes.Buffer, flags ListType) { if flags&ListTypeDefinition != 0 { out.WriteString("</dl>\n") } else if flags&ListTypeOrdered != 0 {
M
latex.go
→
latex.go
@@ -98,13 +98,15 @@ func (options *Latex) HRule(out *bytes.Buffer) {
out.WriteString("\n\\HRule\n") } -func (options *Latex) List(out *bytes.Buffer, text func(), flags ListType) { +func (r *Latex) BeginList(out *bytes.Buffer, flags ListType) { if flags&ListTypeOrdered != 0 { out.WriteString("\n\\begin{enumerate}\n") } else { out.WriteString("\n\\begin{itemize}\n") } - text() +} + +func (r *Latex) EndList(out *bytes.Buffer, flags ListType) { if flags&ListTypeOrdered != 0 { out.WriteString("\n\\end{enumerate}\n") } else {
M
markdown.go
→
markdown.go
@@ -166,7 +166,8 @@ BlockHtml(out *bytes.Buffer, text []byte)
BeginHeader(out *bytes.Buffer, level int, id string) int EndHeader(out *bytes.Buffer, level int, id string, tocMarker int) HRule(out *bytes.Buffer) - List(out *bytes.Buffer, text func(), flags ListType) + BeginList(out *bytes.Buffer, flags ListType) + EndList(out *bytes.Buffer, flags ListType) ListItem(out *bytes.Buffer, text []byte, flags ListType) Paragraph(out *bytes.Buffer, text func()) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int)