eliminate a buffering level for paragraphs
This commit is contained in:
parent
ea3d80e2d0
commit
e22e43bf76
8
block.go
8
block.go
|
@ -1050,9 +1050,11 @@ func renderParagraph(out *bytes.Buffer, rndr *render, data []byte) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var work bytes.Buffer
|
work := func() bool {
|
||||||
parseInline(&work, rndr, data[beg:end])
|
parseInline(out, rndr, data[beg:end])
|
||||||
rndr.mk.Paragraph(out, work.Bytes(), rndr.mk.Opaque)
|
return true
|
||||||
|
}
|
||||||
|
rndr.mk.Paragraph(out, work, rndr.mk.Opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
func blockParagraph(out *bytes.Buffer, rndr *render, data []byte) int {
|
func blockParagraph(out *bytes.Buffer, rndr *render, data []byte) int {
|
||||||
|
|
10
html.go
10
html.go
|
@ -384,13 +384,17 @@ func htmlListItem(out *bytes.Buffer, text []byte, flags int, opaque interface{})
|
||||||
out.WriteString("</li>\n")
|
out.WriteString("</li>\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func htmlParagraph(out *bytes.Buffer, text []byte, opaque interface{}) {
|
func htmlParagraph(out *bytes.Buffer, text func() bool, opaque interface{}) {
|
||||||
if out.Len() > 0 {
|
marker := out.Len()
|
||||||
|
if marker > 0 {
|
||||||
out.WriteByte('\n')
|
out.WriteByte('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
out.WriteString("<p>")
|
out.WriteString("<p>")
|
||||||
out.Write(text)
|
if !text() {
|
||||||
|
out.Truncate(marker)
|
||||||
|
return
|
||||||
|
}
|
||||||
out.WriteString("</p>\n")
|
out.WriteString("</p>\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
latex.go
8
latex.go
|
@ -127,9 +127,13 @@ func latexListItem(out *bytes.Buffer, text []byte, flags int, opaque interface{}
|
||||||
out.Write(text)
|
out.Write(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
func latexParagraph(out *bytes.Buffer, text []byte, opaque interface{}) {
|
func latexParagraph(out *bytes.Buffer, text func() bool, opaque interface{}) {
|
||||||
|
marker := out.Len()
|
||||||
out.WriteString("\n")
|
out.WriteString("\n")
|
||||||
out.Write(text)
|
if !text() {
|
||||||
|
out.Truncate(marker)
|
||||||
|
return
|
||||||
|
}
|
||||||
out.WriteString("\n")
|
out.WriteString("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ type Renderer struct {
|
||||||
HRule func(out *bytes.Buffer, opaque interface{})
|
HRule func(out *bytes.Buffer, opaque interface{})
|
||||||
List func(out *bytes.Buffer, text func() bool, flags int, opaque interface{})
|
List func(out *bytes.Buffer, text func() bool, flags int, opaque interface{})
|
||||||
ListItem func(out *bytes.Buffer, text []byte, flags int, opaque interface{})
|
ListItem func(out *bytes.Buffer, text []byte, flags int, opaque interface{})
|
||||||
Paragraph func(out *bytes.Buffer, text []byte, opaque interface{})
|
Paragraph func(out *bytes.Buffer, text func() bool, opaque interface{})
|
||||||
Table func(out *bytes.Buffer, header []byte, body []byte, columnData []int, opaque interface{})
|
Table func(out *bytes.Buffer, header []byte, body []byte, columnData []int, opaque interface{})
|
||||||
TableRow func(out *bytes.Buffer, text []byte, opaque interface{})
|
TableRow func(out *bytes.Buffer, text []byte, opaque interface{})
|
||||||
TableCell func(out *bytes.Buffer, text []byte, flags int, opaque interface{})
|
TableCell func(out *bytes.Buffer, text []byte, flags int, opaque interface{})
|
||||||
|
|
Loading…
Reference in New Issue