1
0
mirror of https://github.com/danog/blackfriday.git synced 2024-11-26 20:14:43 +01:00

Remove callback from Paragraph renderer event

Split Paragraph into two events: BeginParagraph and EndParagraph,
removing the need for callback.
This commit is contained in:
Vytautas Šaltenis 2015-10-26 20:35:42 +02:00
parent af1b26fa04
commit 6d6be3d2b2
4 changed files with 13 additions and 10 deletions

View File

@ -1269,10 +1269,9 @@ func (p *parser) renderParagraph(out *bytes.Buffer, data []byte) {
end--
}
work := func() {
p.inline(out, data[beg:end])
}
p.r.Paragraph(out, work)
p.r.BeginParagraph(out)
p.inline(out, data[beg:end])
p.r.EndParagraph(out)
}
func (p *parser) paragraph(out *bytes.Buffer, data []byte) int {

View File

@ -418,11 +418,12 @@ func (options *Html) ListItem(out *bytes.Buffer, text []byte, flags ListType) {
}
}
func (options *Html) Paragraph(out *bytes.Buffer, text func()) {
func (r *Html) BeginParagraph(out *bytes.Buffer) {
doubleSpace(out)
out.WriteString("<p>")
text()
}
func (r *Html) EndParagraph(out *bytes.Buffer) {
out.WriteString("</p>\n")
}

View File

@ -119,9 +119,11 @@ func (options *Latex) ListItem(out *bytes.Buffer, text []byte, flags ListType) {
out.Write(text)
}
func (options *Latex) Paragraph(out *bytes.Buffer, text func()) {
func (r *Latex) BeginParagraph(out *bytes.Buffer) {
out.WriteString("\n")
text()
}
func (r *Latex) EndParagraph(out *bytes.Buffer) {
out.WriteString("\n")
}

View File

@ -169,7 +169,8 @@ type Renderer interface {
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())
BeginParagraph(out *bytes.Buffer)
EndParagraph(out *bytes.Buffer)
Table(out *bytes.Buffer, header []byte, body []byte, columnData []int)
TableRow(out *bytes.Buffer, text []byte)
TableHeaderCell(out *bytes.Buffer, text []byte, flags int)