mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
Remove 'out' parameter from renderer interface
This only removes the parameter from func declarations, not from their bodies, so obviously breaks everything. Will be restored in upcoming commits.
This commit is contained in:
parent
a78344809b
commit
6e42506fcc
72
html.go
72
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("<h1 class=\"title\">")
|
||||
|
@ -202,7 +202,7 @@ func (r *Html) TitleBlock(out *bytes.Buffer, text []byte) {
|
|||
out.WriteString("\n</h1>")
|
||||
}
|
||||
|
||||
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("</h%d>\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("<hr")
|
||||
out.WriteString(r.closeTag)
|
||||
out.WriteByte('\n')
|
||||
}
|
||||
|
||||
func (r *Html) BlockCode(out *bytes.Buffer, text []byte, lang string) {
|
||||
func (r *Html) BlockCode(text []byte, lang string) {
|
||||
doubleSpace(out)
|
||||
|
||||
// parse out the language names/classes
|
||||
|
@ -285,14 +285,14 @@ func (r *Html) BlockCode(out *bytes.Buffer, text []byte, lang string) {
|
|||
out.WriteString("</code></pre>\n")
|
||||
}
|
||||
|
||||
func (r *Html) BlockQuote(out *bytes.Buffer, text []byte) {
|
||||
func (r *Html) BlockQuote(text []byte) {
|
||||
doubleSpace(out)
|
||||
out.WriteString("<blockquote>\n")
|
||||
out.Write(text)
|
||||
out.WriteString("</blockquote>\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("<table>\n<thead>\n")
|
||||
out.Write(header)
|
||||
|
@ -301,7 +301,7 @@ func (r *Html) Table(out *bytes.Buffer, header []byte, body []byte, columnData [
|
|||
out.WriteString("</tbody>\n</table>\n")
|
||||
}
|
||||
|
||||
func (r *Html) TableRow(out *bytes.Buffer, text []byte) {
|
||||
func (r *Html) TableRow(text []byte) {
|
||||
doubleSpace(out)
|
||||
out.WriteString("<tr>\n")
|
||||
out.Write(text)
|
||||
|
@ -342,18 +342,18 @@ func (r *Html) TableCell(out *bytes.Buffer, text []byte, align int) {
|
|||
out.WriteString("</td>")
|
||||
}
|
||||
|
||||
func (r *Html) BeginFootnotes(out *bytes.Buffer) {
|
||||
func (r *Html) BeginFootnotes() {
|
||||
out.WriteString("<div class=\"footnotes\">\n")
|
||||
r.HRule(out)
|
||||
r.BeginList(out, ListTypeOrdered)
|
||||
}
|
||||
|
||||
func (r *Html) EndFootnotes(out *bytes.Buffer) {
|
||||
func (r *Html) EndFootnotes() {
|
||||
r.EndList(out, ListTypeOrdered)
|
||||
out.WriteString("</div>\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("</li>\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("</dl>\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("<p>")
|
||||
}
|
||||
|
||||
func (r *Html) EndParagraph(out *bytes.Buffer) {
|
||||
func (r *Html) EndParagraph() {
|
||||
out.WriteString("</p>\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("</a>")
|
||||
}
|
||||
|
||||
func (r *Html) CodeSpan(out *bytes.Buffer, text []byte) {
|
||||
func (r *Html) CodeSpan(text []byte) {
|
||||
out.WriteString("<code>")
|
||||
attrEscape(out, text)
|
||||
out.WriteString("</code>")
|
||||
}
|
||||
|
||||
func (r *Html) DoubleEmphasis(out *bytes.Buffer, text []byte) {
|
||||
func (r *Html) DoubleEmphasis(text []byte) {
|
||||
out.WriteString("<strong>")
|
||||
out.Write(text)
|
||||
out.WriteString("</strong>")
|
||||
}
|
||||
|
||||
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("</em>")
|
||||
}
|
||||
|
||||
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("<br")
|
||||
out.WriteString(r.closeTag)
|
||||
out.WriteByte('\n')
|
||||
}
|
||||
|
||||
func (r *Html) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) {
|
||||
func (r *Html) Link(link []byte, title []byte, content []byte) {
|
||||
if r.flags&SkipLinks != 0 {
|
||||
// write the link text out but don't link it, just mark it with typewriter font
|
||||
out.WriteString("<tt>")
|
||||
|
@ -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("<strong><em>")
|
||||
out.Write(text)
|
||||
out.WriteString("</em></strong>")
|
||||
}
|
||||
|
||||
func (r *Html) StrikeThrough(out *bytes.Buffer, text []byte) {
|
||||
func (r *Html) StrikeThrough(text []byte) {
|
||||
out.WriteString("<del>")
|
||||
out.Write(text)
|
||||
out.WriteString("</del>")
|
||||
}
|
||||
|
||||
func (r *Html) FootnoteRef(out *bytes.Buffer, ref []byte, id int) {
|
||||
func (r *Html) FootnoteRef(ref []byte, id int) {
|
||||
slug := slugify(ref)
|
||||
out.WriteString(`<sup class="footnote-ref" id="`)
|
||||
out.WriteString(`fnref:`)
|
||||
|
@ -627,11 +627,11 @@ func (r *Html) FootnoteRef(out *bytes.Buffer, ref []byte, id int) {
|
|||
out.WriteString(`</a></sup>`)
|
||||
}
|
||||
|
||||
func (r *Html) Entity(out *bytes.Buffer, entity []byte) {
|
||||
func (r *Html) Entity(entity []byte) {
|
||||
out.Write(entity)
|
||||
}
|
||||
|
||||
func (r *Html) NormalText(out *bytes.Buffer, text []byte) {
|
||||
func (r *Html) NormalText(text []byte) {
|
||||
if r.flags&UseSmartypants != 0 {
|
||||
r.Smartypants(out, text)
|
||||
} else {
|
||||
|
@ -639,7 +639,7 @@ func (r *Html) NormalText(out *bytes.Buffer, text []byte) {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Html) Smartypants(out *bytes.Buffer, text []byte) {
|
||||
func (r *Html) Smartypants(text []byte) {
|
||||
smrt := smartypantsData{false, false}
|
||||
|
||||
// first do normal entity escaping
|
||||
|
@ -668,7 +668,7 @@ func (r *Html) Smartypants(out *bytes.Buffer, text []byte) {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Html) DocumentHeader(out *bytes.Buffer) {
|
||||
func (r *Html) DocumentHeader() {
|
||||
if r.flags&CompletePage == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -708,7 +708,7 @@ func (r *Html) DocumentHeader(out *bytes.Buffer) {
|
|||
r.tocMarker = out.Len()
|
||||
}
|
||||
|
||||
func (r *Html) DocumentFooter(out *bytes.Buffer) {
|
||||
func (r *Html) DocumentFooter() {
|
||||
// finalize and insert the table of contents
|
||||
if r.flags&Toc != 0 {
|
||||
r.TocFinalize()
|
||||
|
|
67
latex.go
67
latex.go
|
@ -39,7 +39,7 @@ func (r *Latex) GetFlags() HtmlFlags {
|
|||
}
|
||||
|
||||
// render code chunks using verbatim, or listings if we have a language
|
||||
func (r *Latex) BlockCode(out *bytes.Buffer, text []byte, lang string) {
|
||||
func (r *Latex) BlockCode(text []byte, lang string) {
|
||||
if lang == "" {
|
||||
out.WriteString("\n\\begin{verbatim}\n")
|
||||
} else {
|
||||
|
@ -55,24 +55,24 @@ func (r *Latex) BlockCode(out *bytes.Buffer, text []byte, lang string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Latex) TitleBlock(out *bytes.Buffer, text []byte) {
|
||||
func (r *Latex) TitleBlock(text []byte) {
|
||||
|
||||
}
|
||||
|
||||
func (r *Latex) BlockQuote(out *bytes.Buffer, text []byte) {
|
||||
func (r *Latex) BlockQuote(text []byte) {
|
||||
out.WriteString("\n\\begin{quotation}\n")
|
||||
out.Write(text)
|
||||
out.WriteString("\n\\end{quotation}\n")
|
||||
}
|
||||
|
||||
func (r *Latex) BlockHtml(out *bytes.Buffer, text []byte) {
|
||||
func (r *Latex) BlockHtml(text []byte) {
|
||||
// a pretty lame thing to do...
|
||||
out.WriteString("\n\\begin{verbatim}\n")
|
||||
out.Write(text)
|
||||
out.WriteString("\n\\end{verbatim}\n")
|
||||
}
|
||||
|
||||
func (r *Latex) BeginHeader(out *bytes.Buffer, level int, id string) int {
|
||||
func (r *Latex) BeginHeader(level int, id string) int {
|
||||
switch level {
|
||||
case 1:
|
||||
out.WriteString("\n\\section{")
|
||||
|
@ -90,15 +90,15 @@ func (r *Latex) BeginHeader(out *bytes.Buffer, level int, id string) int {
|
|||
return out.Len()
|
||||
}
|
||||
|
||||
func (r *Latex) EndHeader(out *bytes.Buffer, level int, id string, tocMarker int) {
|
||||
func (r *Latex) EndHeader(level int, id string, tocMarker int) {
|
||||
out.WriteString("}\n")
|
||||
}
|
||||
|
||||
func (r *Latex) HRule(out *bytes.Buffer) {
|
||||
func (r *Latex) HRule() {
|
||||
out.WriteString("\n\\HRule\n")
|
||||
}
|
||||
|
||||
func (r *Latex) BeginList(out *bytes.Buffer, flags ListType) {
|
||||
func (r *Latex) BeginList(flags ListType) {
|
||||
if flags&ListTypeOrdered != 0 {
|
||||
out.WriteString("\n\\begin{enumerate}\n")
|
||||
} else {
|
||||
|
@ -106,7 +106,7 @@ func (r *Latex) BeginList(out *bytes.Buffer, flags ListType) {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Latex) EndList(out *bytes.Buffer, flags ListType) {
|
||||
func (r *Latex) EndList(flags ListType) {
|
||||
if flags&ListTypeOrdered != 0 {
|
||||
out.WriteString("\n\\end{enumerate}\n")
|
||||
} else {
|
||||
|
@ -114,20 +114,20 @@ func (r *Latex) EndList(out *bytes.Buffer, flags ListType) {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Latex) ListItem(out *bytes.Buffer, text []byte, flags ListType) {
|
||||
func (r *Latex) ListItem(text []byte, flags ListType) {
|
||||
out.WriteString("\n\\item ")
|
||||
out.Write(text)
|
||||
}
|
||||
|
||||
func (r *Latex) BeginParagraph(out *bytes.Buffer) {
|
||||
func (r *Latex) BeginParagraph() {
|
||||
out.WriteString("\n")
|
||||
}
|
||||
|
||||
func (r *Latex) EndParagraph(out *bytes.Buffer) {
|
||||
func (r *Latex) EndParagraph() {
|
||||
out.WriteString("\n")
|
||||
}
|
||||
|
||||
func (r *Latex) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int) {
|
||||
func (r *Latex) Table(header []byte, body []byte, columnData []int) {
|
||||
out.WriteString("\n\\begin{tabular}{")
|
||||
for _, elt := range columnData {
|
||||
switch elt {
|
||||
|
@ -146,7 +146,7 @@ func (r *Latex) Table(out *bytes.Buffer, header []byte, body []byte, columnData
|
|||
out.WriteString("\n\\end{tabular}\n")
|
||||
}
|
||||
|
||||
func (r *Latex) TableRow(out *bytes.Buffer, text []byte) {
|
||||
func (r *Latex) TableRow(text []byte) {
|
||||
if out.Len() > 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")
|
||||
}
|
||||
|
|
64
markdown.go
64
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user