all repos — grayfriday @ bc4735b84d3a4ea8d1b108621519c820a61599b2

blackfriday fork with a few changes

Remove callback from Footnotes renderer event

Split Footnotes into two events: BeginFootnotes and EndFootnotes,
removing the need for callback.
Vytautas Ĺ altenis vytas@rtfb.lt
Mon, 26 Oct 2015 20:39:08 +0200
commit

bc4735b84d3a4ea8d1b108621519c820a61599b2

parent

6d6be3d2b25b61da82ba5d55a493da404f363bda

3 files changed, 25 insertions(+), 19 deletions(-)

jump to
M html.gohtml.go

@@ -342,12 +342,14 @@ out.Write(text)

out.WriteString("</td>") } -func (options *Html) Footnotes(out *bytes.Buffer, text func()) { +func (options *Html) BeginFootnotes(out *bytes.Buffer) { out.WriteString("<div class=\"footnotes\">\n") options.HRule(out) options.BeginList(out, ListTypeOrdered) - text() - options.EndList(out, ListTypeOrdered) +} + +func (r *Html) EndFootnotes(out *bytes.Buffer) { + r.EndList(out, ListTypeOrdered) out.WriteString("</div>\n") }
M latex.golatex.go

@@ -168,8 +168,11 @@ out.Write(text)

} // TODO: this -func (options *Latex) Footnotes(out *bytes.Buffer, text func()) { +func (r *Latex) BeginFootnotes(out *bytes.Buffer) { +} +// TODO: this +func (r *Latex) EndFootnotes(out *bytes.Buffer) { } func (options *Latex) FootnoteItem(out *bytes.Buffer, name, text []byte, flags ListType) {
M markdown.gomarkdown.go

@@ -175,7 +175,8 @@ Table(out *bytes.Buffer, header []byte, body []byte, columnData []int)

TableRow(out *bytes.Buffer, text []byte) TableHeaderCell(out *bytes.Buffer, text []byte, flags int) TableCell(out *bytes.Buffer, text []byte, flags int) - Footnotes(out *bytes.Buffer, text func()) + BeginFootnotes(out *bytes.Buffer) + EndFootnotes(out *bytes.Buffer) FootnoteItem(out *bytes.Buffer, name, text []byte, flags ListType) TitleBlock(out *bytes.Buffer, text []byte)

@@ -456,21 +457,21 @@ p.r.DocumentHeader(&output)

p.block(&output, input) if p.flags&Footnotes != 0 && len(p.notes) > 0 { - p.r.Footnotes(&output, func() { - 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) - } else { - p.inline(&buf, ref.title) - } - p.r.FootnoteItem(&output, ref.link, buf.Bytes(), flags) - flags &^= ListItemBeginningOfList | ListItemContainsBlock + p.r.BeginFootnotes(&output) + 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) + } else { + p.inline(&buf, ref.title) } - }) + p.r.FootnoteItem(&output, ref.link, buf.Bytes(), flags) + flags &^= ListItemBeginningOfList | ListItemContainsBlock + } + p.r.EndFootnotes(&output) } p.r.DocumentFooter(&output)