all repos — grayfriday @ e22e43bf764e159538364a61a0a0d8c111599990

blackfriday fork with a few changes

eliminate a buffering level for paragraphs
Russ Ross russ@russross.com
Sun, 26 Jun 2011 17:21:11 -0600
commit

e22e43bf764e159538364a61a0a0d8c111599990

parent

ea3d80e2d0a45d833353ec54f28c4d74ce7aed5c

4 files changed, 19 insertions(+), 9 deletions(-)

jump to
M block.goblock.go

@@ -1050,9 +1050,11 @@ if end == beg || rndr.mk.Paragraph == nil {

return } - var work bytes.Buffer - parseInline(&work, rndr, data[beg:end]) - rndr.mk.Paragraph(out, work.Bytes(), rndr.mk.Opaque) + work := func() bool { + parseInline(out, rndr, data[beg:end]) + return true + } + rndr.mk.Paragraph(out, work, rndr.mk.Opaque) } func blockParagraph(out *bytes.Buffer, rndr *render, data []byte) int {
M html.gohtml.go

@@ -384,13 +384,17 @@ out.Write(text[:size])

out.WriteString("</li>\n") } -func htmlParagraph(out *bytes.Buffer, text []byte, opaque interface{}) { - if out.Len() > 0 { +func htmlParagraph(out *bytes.Buffer, text func() bool, opaque interface{}) { + marker := out.Len() + if marker > 0 { out.WriteByte('\n') } out.WriteString("<p>") - out.Write(text) + if !text() { + out.Truncate(marker) + return + } out.WriteString("</p>\n") }
M latex.golatex.go

@@ -127,9 +127,13 @@ out.WriteString("\n\\item ")

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.Write(text) + if !text() { + out.Truncate(marker) + return + } out.WriteString("\n") }
M markdown.gomarkdown.go

@@ -104,7 +104,7 @@ Header func(out *bytes.Buffer, text func() bool, level int, opaque interface{})

HRule func(out *bytes.Buffer, 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{}) - 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{}) TableRow func(out *bytes.Buffer, text []byte, opaque interface{}) TableCell func(out *bytes.Buffer, text []byte, flags int, opaque interface{})