all repos — grayfriday @ 08233481ede4356a323c881b0b1e6bcc9639811d

blackfriday fork with a few changes

Fix Begin/EndHeader to use the new 'out'-less interface

Remove the 'out' parameter. Also, instead of returning and passing the
position of TOC, use CopyWrites to capture contents of the header and
pass that captured buffer instead.
Vytautas Ĺ altenis vytas@rtfb.lt
Wed, 04 Nov 2015 22:14:02 +0200
commit

08233481ede4356a323c881b0b1e6bcc9639811d

parent

dce6df90b9363579a8609fa70faef3a8b56b85b4

4 files changed, 17 insertions(+), 16 deletions(-)

jump to
M block.goblock.go

@@ -245,9 +245,11 @@ if end > i {

if id == "" && p.flags&AutoHeaderIDs != 0 { id = sanitized_anchor_name.Create(string(data[i:end])) } - tocMarker := p.r.BeginHeader(out, level, id) - p.inline(out, data[i:end]) - p.r.EndHeader(out, level, id, tocMarker) + p.r.BeginHeader(level, id) + header := p.r.CopyWrites(func() { + p.inline(data[i:end]) + }) + p.r.EndHeader(level, id, header) } return skip }

@@ -1320,9 +1322,11 @@ if p.flags&AutoHeaderIDs != 0 {

id = sanitized_anchor_name.Create(string(data[prev:eol])) } - tocMarker := p.r.BeginHeader(out, level, id) - p.inline(out, data[prev:eol]) - p.r.EndHeader(out, level, id, tocMarker) + p.r.BeginHeader(level, id) + header := p.r.CopyWrites(func() { + p.inline(data[prev:eol]) + }) + p.r.EndHeader(level, id, header) // find the end of the underline for data[i] != '\n' {
M html.gohtml.go

@@ -281,7 +281,7 @@ out.Write(text)

out.WriteString("\n</h1>") } -func (r *Html) BeginHeader(level int, id string) int { +func (r *Html) BeginHeader(level int, id string) { doubleSpace(out) if id == "" && r.flags&Toc != 0 {

@@ -303,14 +303,12 @@ out.WriteString(fmt.Sprintf("<h%d id=\"%s\">", level, id))

} else { out.WriteString(fmt.Sprintf("<h%d>", level)) } - - return out.Len() } -func (r *Html) EndHeader(level int, id string, tocMarker int) { +func (r *Html) EndHeader(level int, id string, header []byte) { // are we building a table of contents? if r.flags&Toc != 0 { - r.TocHeaderWithAnchor(out.Bytes()[tocMarker:], level, id) + r.TocHeaderWithAnchor(header, level, id) } out.WriteString(fmt.Sprintf("</h%d>\n", level))
M latex.golatex.go

@@ -72,7 +72,7 @@ out.Write(text)

out.WriteString("\n\\end{verbatim}\n") } -func (r *Latex) BeginHeader(level int, id string) int { +func (r *Latex) BeginHeader(level int, id string) { switch level { case 1: out.WriteString("\n\\section{")

@@ -87,10 +87,9 @@ out.WriteString("\n\\subparagraph{")

case 6: out.WriteString("\n\\textbf{") } - return out.Len() } -func (r *Latex) EndHeader(level int, id string, tocMarker int) { +func (r *Latex) EndHeader(level int, id string, header []byte) { out.WriteString("}\n") }
M markdown.gomarkdown.go

@@ -163,8 +163,8 @@ // block-level callbacks

BlockCode(text []byte, lang string) BlockQuote(text []byte) BlockHtml(text []byte) - BeginHeader(level int, id string) int - EndHeader(level int, id string, tocMarker int) + BeginHeader(level int, id string) + EndHeader(level int, id string, header []byte) HRule() BeginList(flags ListType) EndList(flags ListType)