diff --git a/html.go b/html.go
index b5aacab..2820c4d 100644
--- a/html.go
+++ b/html.go
@@ -163,7 +163,7 @@ func escapeSingleChar(char byte) (string, bool) {
return "", false
}
-func attrEscape(out *bytes.Buffer, src []byte) {
+func attrEscape(src []byte) {
org := 0
for i, ch := range src {
if entity, ok := escapeSingleChar(ch); ok {
@@ -180,7 +180,7 @@ func attrEscape(out *bytes.Buffer, src []byte) {
}
}
-func entityEscapeWithSkip(out *bytes.Buffer, src []byte, skipRanges [][]int) {
+func entityEscapeWithSkip(src []byte, skipRanges [][]int) {
end := 0
for _, rang := range skipRanges {
attrEscape(out, src[end:rang[0]])
@@ -194,7 +194,7 @@ func (r *Html) GetFlags() HtmlFlags {
return r.flags
}
-func (r *Html) TitleBlock(out *bytes.Buffer, text []byte) {
+func (r *Html) TitleBlock(text []byte) {
text = bytes.TrimPrefix(text, []byte("% "))
text = bytes.Replace(text, []byte("\n% "), []byte("\n"), -1)
out.WriteString("
")
@@ -202,7 +202,7 @@ func (r *Html) TitleBlock(out *bytes.Buffer, text []byte) {
out.WriteString("\n
")
}
-func (r *Html) BeginHeader(out *bytes.Buffer, level int, id string) int {
+func (r *Html) BeginHeader(level int, id string) int {
doubleSpace(out)
if id == "" && r.flags&Toc != 0 {
@@ -228,7 +228,7 @@ func (r *Html) BeginHeader(out *bytes.Buffer, level int, id string) int {
return out.Len()
}
-func (r *Html) EndHeader(out *bytes.Buffer, level int, id string, tocMarker int) {
+func (r *Html) EndHeader(level int, id string, tocMarker int) {
// are we building a table of contents?
if r.flags&Toc != 0 {
r.TocHeaderWithAnchor(out.Bytes()[tocMarker:], level, id)
@@ -237,7 +237,7 @@ func (r *Html) EndHeader(out *bytes.Buffer, level int, id string, tocMarker int)
out.WriteString(fmt.Sprintf("\n", level))
}
-func (r *Html) BlockHtml(out *bytes.Buffer, text []byte) {
+func (r *Html) BlockHtml(text []byte) {
if r.flags&SkipHTML != 0 {
return
}
@@ -247,14 +247,14 @@ func (r *Html) BlockHtml(out *bytes.Buffer, text []byte) {
out.WriteByte('\n')
}
-func (r *Html) HRule(out *bytes.Buffer) {
+func (r *Html) HRule() {
doubleSpace(out)
out.WriteString("
\n")
}
-func (r *Html) BlockQuote(out *bytes.Buffer, text []byte) {
+func (r *Html) BlockQuote(text []byte) {
doubleSpace(out)
out.WriteString("\n")
out.Write(text)
out.WriteString("
\n")
}
-func (r *Html) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int) {
+func (r *Html) Table(header []byte, body []byte, columnData []int) {
doubleSpace(out)
out.WriteString("\n\n")
out.Write(header)
@@ -301,7 +301,7 @@ func (r *Html) Table(out *bytes.Buffer, header []byte, body []byte, columnData [
out.WriteString("\n
\n")
}
-func (r *Html) TableRow(out *bytes.Buffer, text []byte) {
+func (r *Html) TableRow(text []byte) {
doubleSpace(out)
out.WriteString("\n")
out.Write(text)
@@ -342,18 +342,18 @@ func (r *Html) TableCell(out *bytes.Buffer, text []byte, align int) {
out.WriteString("")
}
-func (r *Html) BeginFootnotes(out *bytes.Buffer) {
+func (r *Html) BeginFootnotes() {
out.WriteString("\n")
}
-func (r *Html) FootnoteItem(out *bytes.Buffer, name, text []byte, flags ListType) {
+func (r *Html) FootnoteItem(name, text []byte, flags ListType) {
if flags&ListItemContainsBlock != 0 || flags&ListItemBeginningOfList != 0 {
doubleSpace(out)
}
@@ -376,7 +376,7 @@ func (r *Html) FootnoteItem(out *bytes.Buffer, name, text []byte, flags ListType
out.WriteString("\n")
}
-func (r *Html) BeginList(out *bytes.Buffer, flags ListType) {
+func (r *Html) BeginList(flags ListType) {
doubleSpace(out)
if flags&ListTypeDefinition != 0 {
@@ -388,7 +388,7 @@ func (r *Html) BeginList(out *bytes.Buffer, flags ListType) {
}
}
-func (r *Html) EndList(out *bytes.Buffer, flags ListType) {
+func (r *Html) EndList(flags ListType) {
if flags&ListTypeDefinition != 0 {
out.WriteString("\n")
} else if flags&ListTypeOrdered != 0 {
@@ -398,7 +398,7 @@ func (r *Html) EndList(out *bytes.Buffer, flags ListType) {
}
}
-func (r *Html) ListItem(out *bytes.Buffer, text []byte, flags ListType) {
+func (r *Html) ListItem(text []byte, flags ListType) {
if (flags&ListItemContainsBlock != 0 && flags&ListTypeDefinition == 0) ||
flags&ListItemBeginningOfList != 0 {
doubleSpace(out)
@@ -420,16 +420,16 @@ func (r *Html) ListItem(out *bytes.Buffer, text []byte, flags ListType) {
}
}
-func (r *Html) BeginParagraph(out *bytes.Buffer) {
+func (r *Html) BeginParagraph() {
doubleSpace(out)
out.WriteString("")
}
-func (r *Html) EndParagraph(out *bytes.Buffer) {
+func (r *Html) EndParagraph() {
out.WriteString("
\n")
}
-func (r *Html) AutoLink(out *bytes.Buffer, link []byte, kind LinkType) {
+func (r *Html) AutoLink(link []byte, kind LinkType) {
skipRanges := htmlEntity.FindAllIndex(link, -1)
if r.flags&Safelink != 0 && !isSafeLink(link) && kind != LinkTypeEmail {
// mark it but don't link it if it is not a safe link: no smartypants
@@ -481,19 +481,19 @@ func (r *Html) AutoLink(out *bytes.Buffer, link []byte, kind LinkType) {
out.WriteString("")
}
-func (r *Html) CodeSpan(out *bytes.Buffer, text []byte) {
+func (r *Html) CodeSpan(text []byte) {
out.WriteString("")
attrEscape(out, text)
out.WriteString("
")
}
-func (r *Html) DoubleEmphasis(out *bytes.Buffer, text []byte) {
+func (r *Html) DoubleEmphasis(text []byte) {
out.WriteString("")
out.Write(text)
out.WriteString("")
}
-func (r *Html) Emphasis(out *bytes.Buffer, text []byte) {
+func (r *Html) Emphasis(text []byte) {
if len(text) == 0 {
return
}
@@ -502,7 +502,7 @@ func (r *Html) Emphasis(out *bytes.Buffer, text []byte) {
out.WriteString("")
}
-func (r *Html) maybeWriteAbsolutePrefix(out *bytes.Buffer, link []byte) {
+func (r *Html) maybeWriteAbsolutePrefix(link []byte) {
if r.parameters.AbsolutePrefix != "" && isRelativeLink(link) && link[0] != '.' {
out.WriteString(r.parameters.AbsolutePrefix)
if link[0] != '/' {
@@ -511,7 +511,7 @@ func (r *Html) maybeWriteAbsolutePrefix(out *bytes.Buffer, link []byte) {
}
}
-func (r *Html) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) {
+func (r *Html) Image(link []byte, title []byte, alt []byte) {
if r.flags&SkipImages != 0 {
return
}
@@ -532,13 +532,13 @@ func (r *Html) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) {
out.WriteString(r.closeTag)
}
-func (r *Html) LineBreak(out *bytes.Buffer) {
+func (r *Html) LineBreak() {
out.WriteString("
")
@@ -584,7 +584,7 @@ func (r *Html) Link(out *bytes.Buffer, link []byte, title []byte, content []byte
return
}
-func (r *Html) RawHtmlTag(out *bytes.Buffer, text []byte) {
+func (r *Html) RawHtmlTag(text []byte) {
if r.flags&SkipHTML != 0 {
return
}
@@ -600,19 +600,19 @@ func (r *Html) RawHtmlTag(out *bytes.Buffer, text []byte) {
out.Write(text)
}
-func (r *Html) TripleEmphasis(out *bytes.Buffer, text []byte) {
+func (r *Html) TripleEmphasis(text []byte) {
out.WriteString("")
out.Write(text)
out.WriteString("")
}
-func (r *Html) StrikeThrough(out *bytes.Buffer, text []byte) {
+func (r *Html) StrikeThrough(text []byte) {
out.WriteString("")
out.Write(text)
out.WriteString("")
}
-func (r *Html) FootnoteRef(out *bytes.Buffer, ref []byte, id int) {
+func (r *Html) FootnoteRef(ref []byte, id int) {
slug := slugify(ref)
out.WriteString(` 0 {
out.WriteString(" \\\\\n")
}
@@ -168,18 +168,18 @@ func (r *Latex) TableCell(out *bytes.Buffer, text []byte, align int) {
}
// TODO: this
-func (r *Latex) BeginFootnotes(out *bytes.Buffer) {
+func (r *Latex) BeginFootnotes() {
}
// TODO: this
-func (r *Latex) EndFootnotes(out *bytes.Buffer) {
+func (r *Latex) EndFootnotes() {
}
-func (r *Latex) FootnoteItem(out *bytes.Buffer, name, text []byte, flags ListType) {
+func (r *Latex) FootnoteItem(name, text []byte, flags ListType) {
}
-func (r *Latex) AutoLink(out *bytes.Buffer, link []byte, kind LinkType) {
+func (r *Latex) AutoLink(link []byte, kind LinkType) {
out.WriteString("\\href{")
if kind == LinkTypeEmail {
out.WriteString("mailto:")
@@ -190,25 +190,25 @@ func (r *Latex) AutoLink(out *bytes.Buffer, link []byte, kind LinkType) {
out.WriteString("}")
}
-func (r *Latex) CodeSpan(out *bytes.Buffer, text []byte) {
+func (r *Latex) CodeSpan(text []byte) {
out.WriteString("\\texttt{")
escapeSpecialChars(out, text)
out.WriteString("}")
}
-func (r *Latex) DoubleEmphasis(out *bytes.Buffer, text []byte) {
+func (r *Latex) DoubleEmphasis(text []byte) {
out.WriteString("\\textbf{")
out.Write(text)
out.WriteString("}")
}
-func (r *Latex) Emphasis(out *bytes.Buffer, text []byte) {
+func (r *Latex) Emphasis(text []byte) {
out.WriteString("\\textit{")
out.Write(text)
out.WriteString("}")
}
-func (r *Latex) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) {
+func (r *Latex) Image(link []byte, title []byte, alt []byte) {
if bytes.HasPrefix(link, []byte("http://")) || bytes.HasPrefix(link, []byte("https://")) {
// treat it like a link
out.WriteString("\\href{")
@@ -223,11 +223,11 @@ func (r *Latex) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte)
}
}
-func (r *Latex) LineBreak(out *bytes.Buffer) {
+func (r *Latex) LineBreak() {
out.WriteString(" \\\\\n")
}
-func (r *Latex) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) {
+func (r *Latex) Link(link []byte, title []byte, content []byte) {
out.WriteString("\\href{")
out.Write(link)
out.WriteString("}{")
@@ -235,24 +235,23 @@ func (r *Latex) Link(out *bytes.Buffer, link []byte, title []byte, content []byt
out.WriteString("}")
}
-func (r *Latex) RawHtmlTag(out *bytes.Buffer, tag []byte) {
+func (r *Latex) RawHtmlTag(tag []byte) {
}
-func (r *Latex) TripleEmphasis(out *bytes.Buffer, text []byte) {
+func (r *Latex) TripleEmphasis(text []byte) {
out.WriteString("\\textbf{\\textit{")
out.Write(text)
out.WriteString("}}")
}
-func (r *Latex) StrikeThrough(out *bytes.Buffer, text []byte) {
+func (r *Latex) StrikeThrough(text []byte) {
out.WriteString("\\sout{")
out.Write(text)
out.WriteString("}")
}
// TODO: this
-func (r *Latex) FootnoteRef(out *bytes.Buffer, ref []byte, id int) {
-
+func (r *Latex) FootnoteRef(ref []byte, id int) {
}
func needsBackslash(c byte) bool {
@@ -264,7 +263,7 @@ func needsBackslash(c byte) bool {
return false
}
-func escapeSpecialChars(out *bytes.Buffer, text []byte) {
+func escapeSpecialChars(text []byte) {
for i := 0; i < len(text); i++ {
// directly copy normal characters
org := i
@@ -285,17 +284,17 @@ func escapeSpecialChars(out *bytes.Buffer, text []byte) {
}
}
-func (r *Latex) Entity(out *bytes.Buffer, entity []byte) {
+func (r *Latex) Entity(entity []byte) {
// TODO: convert this into a unicode character or something
out.Write(entity)
}
-func (r *Latex) NormalText(out *bytes.Buffer, text []byte) {
+func (r *Latex) NormalText(text []byte) {
escapeSpecialChars(out, text)
}
// header and footer
-func (r *Latex) DocumentHeader(out *bytes.Buffer) {
+func (r *Latex) DocumentHeader() {
out.WriteString("\\documentclass{article}\n")
out.WriteString("\n")
out.WriteString("\\usepackage{graphicx}\n")
@@ -324,6 +323,6 @@ func (r *Latex) DocumentHeader(out *bytes.Buffer) {
out.WriteString("\\begin{document}\n")
}
-func (r *Latex) DocumentFooter(out *bytes.Buffer) {
+func (r *Latex) DocumentFooter() {
out.WriteString("\n\\end{document}\n")
}
diff --git a/markdown.go b/markdown.go
index 7ee51a3..4ad3f3a 100644
--- a/markdown.go
+++ b/markdown.go
@@ -160,46 +160,46 @@ var blockTags = map[string]struct{}{
// Currently Html and Latex implementations are provided
type Renderer interface {
// block-level callbacks
- BlockCode(out *bytes.Buffer, text []byte, lang string)
- BlockQuote(out *bytes.Buffer, text []byte)
- BlockHtml(out *bytes.Buffer, text []byte)
- BeginHeader(out *bytes.Buffer, level int, id string) int
- EndHeader(out *bytes.Buffer, level int, id string, tocMarker int)
- HRule(out *bytes.Buffer)
- BeginList(out *bytes.Buffer, flags ListType)
- EndList(out *bytes.Buffer, flags ListType)
- ListItem(out *bytes.Buffer, text []byte, flags ListType)
- BeginParagraph(out *bytes.Buffer)
- EndParagraph(out *bytes.Buffer)
- Table(out *bytes.Buffer, header []byte, body []byte, columnData []int)
- TableRow(out *bytes.Buffer, text []byte)
+ BlockCode(text []byte, lang string)
+ BlockQuote(text []byte)
+ BlockHtml(text []byte)
+ BeginHeader(level int, id string) int
+ EndHeader(level int, id string, tocMarker int)
+ HRule()
+ BeginList(flags ListType)
+ EndList(flags ListType)
+ ListItem(text []byte, flags ListType)
+ BeginParagraph()
+ EndParagraph()
+ Table(header []byte, body []byte, columnData []int)
+ TableRow(text []byte)
TableHeaderCell(out *bytes.Buffer, text []byte, flags int)
TableCell(out *bytes.Buffer, text []byte, flags int)
- BeginFootnotes(out *bytes.Buffer)
- EndFootnotes(out *bytes.Buffer)
- FootnoteItem(out *bytes.Buffer, name, text []byte, flags ListType)
- TitleBlock(out *bytes.Buffer, text []byte)
+ BeginFootnotes()
+ EndFootnotes()
+ FootnoteItem(name, text []byte, flags ListType)
+ TitleBlock(text []byte)
// Span-level callbacks
- AutoLink(out *bytes.Buffer, link []byte, kind LinkType)
- CodeSpan(out *bytes.Buffer, text []byte)
- DoubleEmphasis(out *bytes.Buffer, text []byte)
- Emphasis(out *bytes.Buffer, text []byte)
- Image(out *bytes.Buffer, link []byte, title []byte, alt []byte)
- LineBreak(out *bytes.Buffer)
- Link(out *bytes.Buffer, link []byte, title []byte, content []byte)
- RawHtmlTag(out *bytes.Buffer, tag []byte)
- TripleEmphasis(out *bytes.Buffer, text []byte)
- StrikeThrough(out *bytes.Buffer, text []byte)
- FootnoteRef(out *bytes.Buffer, ref []byte, id int)
+ AutoLink(link []byte, kind LinkType)
+ CodeSpan(text []byte)
+ DoubleEmphasis(text []byte)
+ Emphasis(text []byte)
+ Image(link []byte, title []byte, alt []byte)
+ LineBreak()
+ Link(link []byte, title []byte, content []byte)
+ RawHtmlTag(tag []byte)
+ TripleEmphasis(text []byte)
+ StrikeThrough(text []byte)
+ FootnoteRef(ref []byte, id int)
// Low-level callbacks
- Entity(out *bytes.Buffer, entity []byte)
- NormalText(out *bytes.Buffer, text []byte)
+ Entity(entity []byte)
+ NormalText(text []byte)
// Header and footer
- DocumentHeader(out *bytes.Buffer)
- DocumentFooter(out *bytes.Buffer)
+ DocumentHeader()
+ DocumentFooter()
GetFlags() HtmlFlags
}