mirror of
https://github.com/danog/blackfriday.git
synced 2024-11-30 04:29:13 +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:
parent
af1b26fa04
commit
6d6be3d2b2
7
block.go
7
block.go
@ -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 {
|
||||
|
7
html.go
7
html.go
@ -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")
|
||||
}
|
||||
|
||||
|
6
latex.go
6
latex.go
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user