export all names from Renderer struct

This enables new back-ends that are not part of the package
Basically a big search-and-replace for this commit
This commit is contained in:
Russ Ross 2011-05-30 21:44:52 -06:00
parent 679e1686db
commit 9d23b68fa5
6 changed files with 218 additions and 218 deletions

View File

@ -52,8 +52,8 @@ All features of upskirt are supported, including:
errors that were present in the C code). errors that were present in the C code).
* Good performance. I have not done rigorous benchmarking, but * Good performance. I have not done rigorous benchmarking, but
informal testing suggests it is around 8x slower than upskirt. informal testing suggests it is around 3.5x slower than upskirt.
This is still an ugly, direct translation from the C code, so This is an ugly, direct translation from the C code, so
the difference is unlikely to be related to differences in the difference is unlikely to be related to differences in
coding style. There is a lot of bounds checking that is coding style. There is a lot of bounds checking that is
duplicated (by user code for the application and again by code duplicated (by user code for the application and again by code

View File

@ -26,7 +26,7 @@ func parseBlock(out *bytes.Buffer, rndr *render, data []byte) {
data = data[blockPrefixHeader(out, rndr, data):] data = data[blockPrefixHeader(out, rndr, data):]
continue continue
} }
if data[0] == '<' && rndr.mk.blockhtml != nil { if data[0] == '<' && rndr.mk.BlockHtml != nil {
if i := blockHtml(out, rndr, data, true); i > 0 { if i := blockHtml(out, rndr, data, true); i > 0 {
data = data[i:] data = data[i:]
continue continue
@ -36,9 +36,9 @@ func parseBlock(out *bytes.Buffer, rndr *render, data []byte) {
data = data[i:] data = data[i:]
continue continue
} }
if isHrule(data) { if isHRule(data) {
if rndr.mk.hrule != nil { if rndr.mk.HRule != nil {
rndr.mk.hrule(out, rndr.mk.opaque) rndr.mk.HRule(out, rndr.mk.Opaque)
} }
var i int var i int
for i = 0; i < len(data) && data[i] != '\n'; i++ { for i = 0; i < len(data) && data[i] != '\n'; i++ {
@ -118,8 +118,8 @@ func blockPrefixHeader(out *bytes.Buffer, rndr *render, data []byte) int {
if end > i { if end > i {
work := bytes.NewBuffer(nil) work := bytes.NewBuffer(nil)
parseInline(work, rndr, data[i:end]) parseInline(work, rndr, data[i:end])
if rndr.mk.header != nil { if rndr.mk.Header != nil {
rndr.mk.header(out, work.Bytes(), level, rndr.mk.opaque) rndr.mk.Header(out, work.Bytes(), level, rndr.mk.Opaque)
} }
} }
return skip return skip
@ -186,8 +186,8 @@ func blockHtml(out *bytes.Buffer, rndr *render, data []byte, do_render bool) int
if j > 0 { if j > 0 {
size := i + j size := i + j
if do_render && rndr.mk.blockhtml != nil { if do_render && rndr.mk.BlockHtml != nil {
rndr.mk.blockhtml(out, data[:size], rndr.mk.opaque) rndr.mk.BlockHtml(out, data[:size], rndr.mk.Opaque)
} }
return size return size
} }
@ -205,8 +205,8 @@ func blockHtml(out *bytes.Buffer, rndr *render, data []byte, do_render bool) int
j = isEmpty(data[i:]) j = isEmpty(data[i:])
if j > 0 { if j > 0 {
size := i + j size := i + j
if do_render && rndr.mk.blockhtml != nil { if do_render && rndr.mk.BlockHtml != nil {
rndr.mk.blockhtml(out, data[:size], rndr.mk.opaque) rndr.mk.BlockHtml(out, data[:size], rndr.mk.Opaque)
} }
return size return size
} }
@ -251,8 +251,8 @@ func blockHtml(out *bytes.Buffer, rndr *render, data []byte, do_render bool) int
} }
// the end of the block has been found // the end of the block has been found
if do_render && rndr.mk.blockhtml != nil { if do_render && rndr.mk.BlockHtml != nil {
rndr.mk.blockhtml(out, data[:i], rndr.mk.opaque) rndr.mk.BlockHtml(out, data[:i], rndr.mk.Opaque)
} }
return i return i
@ -317,7 +317,7 @@ func isEmpty(data []byte) int {
return i + 1 return i + 1
} }
func isHrule(data []byte) bool { func isHRule(data []byte) bool {
// skip initial spaces // skip initial spaces
if len(data) < 3 { if len(data) < 3 {
return false return false
@ -478,13 +478,13 @@ func blockFencedCode(out *bytes.Buffer, rndr *render, data []byte) int {
work.WriteByte('\n') work.WriteByte('\n')
} }
if rndr.mk.blockcode != nil { if rndr.mk.BlockCode != nil {
syntax := "" syntax := ""
if lang != nil { if lang != nil {
syntax = *lang syntax = *lang
} }
rndr.mk.blockcode(out, work.Bytes(), syntax, rndr.mk.opaque) rndr.mk.BlockCode(out, work.Bytes(), syntax, rndr.mk.Opaque)
} }
return beg return beg
@ -513,8 +513,8 @@ func blockTable(out *bytes.Buffer, rndr *render, data []byte) int {
i++ i++
} }
if rndr.mk.table != nil { if rndr.mk.Table != nil {
rndr.mk.table(out, header_work.Bytes(), body_work.Bytes(), col_data, rndr.mk.opaque) rndr.mk.Table(out, header_work.Bytes(), body_work.Bytes(), col_data, rndr.mk.Opaque)
} }
} }
@ -635,12 +635,12 @@ func blockTableRow(out *bytes.Buffer, rndr *render, data []byte, columns int, co
cell_work := bytes.NewBuffer(nil) cell_work := bytes.NewBuffer(nil)
parseInline(cell_work, rndr, data[cell_start:cell_end+1]) parseInline(cell_work, rndr, data[cell_start:cell_end+1])
if rndr.mk.tableCell != nil { if rndr.mk.TableCell != nil {
cdata := 0 cdata := 0
if col < len(col_data) { if col < len(col_data) {
cdata = col_data[col] cdata = col_data[col]
} }
rndr.mk.tableCell(row_work, cell_work.Bytes(), cdata, rndr.mk.opaque) rndr.mk.TableCell(row_work, cell_work.Bytes(), cdata, rndr.mk.Opaque)
} }
i++ i++
@ -648,17 +648,17 @@ func blockTableRow(out *bytes.Buffer, rndr *render, data []byte, columns int, co
for ; col < columns; col++ { for ; col < columns; col++ {
empty_cell := []byte{} empty_cell := []byte{}
if rndr.mk.tableCell != nil { if rndr.mk.TableCell != nil {
cdata := 0 cdata := 0
if col < len(col_data) { if col < len(col_data) {
cdata = col_data[col] cdata = col_data[col]
} }
rndr.mk.tableCell(row_work, empty_cell, cdata, rndr.mk.opaque) rndr.mk.TableCell(row_work, empty_cell, cdata, rndr.mk.Opaque)
} }
} }
if rndr.mk.tableRow != nil { if rndr.mk.TableRow != nil {
rndr.mk.tableRow(out, row_work.Bytes(), rndr.mk.opaque) rndr.mk.TableRow(out, row_work.Bytes(), rndr.mk.Opaque)
} }
} }
@ -702,8 +702,8 @@ func blockQuote(out *bytes.Buffer, rndr *render, data []byte) int {
} }
parseBlock(block, rndr, work.Bytes()) parseBlock(block, rndr, work.Bytes())
if rndr.mk.blockquote != nil { if rndr.mk.BlockQuote != nil {
rndr.mk.blockquote(out, block.Bytes(), rndr.mk.opaque) rndr.mk.BlockQuote(out, block.Bytes(), rndr.mk.Opaque)
} }
return end return end
} }
@ -759,8 +759,8 @@ func blockCode(out *bytes.Buffer, rndr *render, data []byte) int {
work.WriteByte('\n') work.WriteByte('\n')
if rndr.mk.blockcode != nil { if rndr.mk.BlockCode != nil {
rndr.mk.blockcode(out, work.Bytes(), "", rndr.mk.opaque) rndr.mk.BlockCode(out, work.Bytes(), "", rndr.mk.Opaque)
} }
return beg return beg
@ -810,8 +810,8 @@ func blockList(out *bytes.Buffer, rndr *render, data []byte, flags int) int {
} }
} }
if rndr.mk.list != nil { if rndr.mk.List != nil {
rndr.mk.list(out, work.Bytes(), flags, rndr.mk.opaque) rndr.mk.List(out, work.Bytes(), flags, rndr.mk.Opaque)
} }
return i return i
} }
@ -883,7 +883,7 @@ func blockListItem(out *bytes.Buffer, rndr *render, data []byte, flags *int) int
// check for a new item // check for a new item
chunk := data[beg+i : end] chunk := data[beg+i : end]
if (blockUliPrefix(chunk) > 0 && !isHrule(chunk)) || blockOliPrefix(chunk) > 0 { if (blockUliPrefix(chunk) > 0 && !isHRule(chunk)) || blockOliPrefix(chunk) > 0 {
if in_empty { if in_empty {
has_inside_empty = true has_inside_empty = true
} }
@ -940,8 +940,8 @@ func blockListItem(out *bytes.Buffer, rndr *render, data []byte, flags *int) int
} }
// render li itself // render li itself
if rndr.mk.listitem != nil { if rndr.mk.ListItem != nil {
rndr.mk.listitem(out, inter.Bytes(), *flags, rndr.mk.opaque) rndr.mk.ListItem(out, inter.Bytes(), *flags, rndr.mk.Opaque)
} }
return beg return beg
@ -962,13 +962,13 @@ func blockParagraph(out *bytes.Buffer, rndr *render, data []byte) int {
} }
if rndr.flags&EXTENSION_LAX_HTML_BLOCKS != 0 { if rndr.flags&EXTENSION_LAX_HTML_BLOCKS != 0 {
if data[i] == '<' && rndr.mk.blockhtml != nil && blockHtml(out, rndr, data[i:], false) > 0 { if data[i] == '<' && rndr.mk.BlockHtml != nil && blockHtml(out, rndr, data[i:], false) > 0 {
end = i end = i
break break
} }
} }
if isPrefixHeader(rndr, data[i:]) || isHrule(data[i:]) { if isPrefixHeader(rndr, data[i:]) || isHRule(data[i:]) {
end = i end = i
break break
} }
@ -985,8 +985,8 @@ func blockParagraph(out *bytes.Buffer, rndr *render, data []byte) int {
if level == 0 { if level == 0 {
tmp := bytes.NewBuffer(nil) tmp := bytes.NewBuffer(nil)
parseInline(tmp, rndr, work[:size]) parseInline(tmp, rndr, work[:size])
if rndr.mk.paragraph != nil { if rndr.mk.Paragraph != nil {
rndr.mk.paragraph(out, tmp.Bytes(), rndr.mk.opaque) rndr.mk.Paragraph(out, tmp.Bytes(), rndr.mk.Opaque)
} }
} else { } else {
if size > 0 { if size > 0 {
@ -1006,8 +1006,8 @@ func blockParagraph(out *bytes.Buffer, rndr *render, data []byte) int {
if size > 0 { if size > 0 {
tmp := bytes.NewBuffer(nil) tmp := bytes.NewBuffer(nil)
parseInline(tmp, rndr, work[:size]) parseInline(tmp, rndr, work[:size])
if rndr.mk.paragraph != nil { if rndr.mk.Paragraph != nil {
rndr.mk.paragraph(out, tmp.Bytes(), rndr.mk.opaque) rndr.mk.Paragraph(out, tmp.Bytes(), rndr.mk.Opaque)
} }
work = work[beg:] work = work[beg:]
@ -1020,8 +1020,8 @@ func blockParagraph(out *bytes.Buffer, rndr *render, data []byte) int {
header_work := bytes.NewBuffer(nil) header_work := bytes.NewBuffer(nil)
parseInline(header_work, rndr, work[:size]) parseInline(header_work, rndr, work[:size])
if rndr.mk.header != nil { if rndr.mk.Header != nil {
rndr.mk.header(out, header_work.Bytes(), level, rndr.mk.opaque) rndr.mk.Header(out, header_work.Bytes(), level, rndr.mk.Opaque)
} }
} }

138
html.go
View File

@ -36,87 +36,87 @@ const (
type htmlOptions struct { type htmlOptions struct {
flags int flags int
close_tag string // how to end singleton tags: usually " />\n", possibly ">\n" closeTag string // how to end singleton tags: usually " />\n", possibly ">\n"
toc_data struct { tocData struct {
header_count int headerCount int
current_level int currentLevel int
} }
smartypants *SmartypantsRenderer smartypants *SmartypantsRenderer
} }
var xhtml_close = " />\n" var xhtmlClose = " />\n"
var html_close = ">\n" var htmlClose = ">\n"
func HtmlRenderer(flags int) *Renderer { func HtmlRenderer(flags int) *Renderer {
// configure the rendering engine // configure the rendering engine
r := new(Renderer) r := new(Renderer)
if flags&HTML_GITHUB_BLOCKCODE == 0 { if flags&HTML_GITHUB_BLOCKCODE == 0 {
r.blockcode = htmlBlockcode r.BlockCode = htmlBlockCode
} else { } else {
r.blockcode = htmlBlockcodeGithub r.BlockCode = htmlBlockCodeGithub
} }
r.blockquote = htmlBlockquote r.BlockQuote = htmlBlockQuote
if flags&HTML_SKIP_HTML == 0 { if flags&HTML_SKIP_HTML == 0 {
r.blockhtml = htmlRawBlock r.BlockHtml = htmlRawBlock
} }
r.header = htmlHeader r.Header = htmlHeader
r.hrule = htmlHrule r.HRule = htmlHRule
r.list = htmlList r.List = htmlList
r.listitem = htmlListitem r.ListItem = htmlListItem
r.paragraph = htmlParagraph r.Paragraph = htmlParagraph
r.table = htmlTable r.Table = htmlTable
r.tableRow = htmlTableRow r.TableRow = htmlTableRow
r.tableCell = htmlTableCell r.TableCell = htmlTableCell
r.autolink = htmlAutolink r.AutoLink = htmlAutoLink
r.codespan = htmlCodespan r.CodeSpan = htmlCodeSpan
r.doubleEmphasis = htmlDoubleEmphasis r.DoubleEmphasis = htmlDoubleEmphasis
r.emphasis = htmlEmphasis r.Emphasis = htmlEmphasis
if flags&HTML_SKIP_IMAGES == 0 { if flags&HTML_SKIP_IMAGES == 0 {
r.image = htmlImage r.Image = htmlImage
} }
r.linebreak = htmlLinebreak r.LineBreak = htmlLineBreak
if flags&HTML_SKIP_LINKS == 0 { if flags&HTML_SKIP_LINKS == 0 {
r.link = htmlLink r.Link = htmlLink
} }
r.rawHtmlTag = htmlRawTag r.RawHtmlTag = htmlRawTag
r.tripleEmphasis = htmlTripleEmphasis r.TripleEmphasis = htmlTripleEmphasis
r.strikethrough = htmlStrikethrough r.StrikeThrough = htmlStrikeThrough
var cb *SmartypantsRenderer var cb *SmartypantsRenderer
if flags&HTML_USE_SMARTYPANTS == 0 { if flags&HTML_USE_SMARTYPANTS == 0 {
r.normalText = htmlNormalText r.NormalText = htmlNormalText
} else { } else {
cb = Smartypants(flags) cb = Smartypants(flags)
r.normalText = htmlSmartypants r.NormalText = htmlSmartypants
} }
close_tag := html_close closeTag := htmlClose
if flags&HTML_USE_XHTML != 0 { if flags&HTML_USE_XHTML != 0 {
close_tag = xhtml_close closeTag = xhtmlClose
} }
r.opaque = &htmlOptions{flags: flags, close_tag: close_tag, smartypants: cb} r.Opaque = &htmlOptions{flags: flags, closeTag: closeTag, smartypants: cb}
return r return r
} }
func HtmlTocRenderer(flags int) *Renderer { func HtmlTocRenderer(flags int) *Renderer {
// configure the rendering engine // configure the rendering engine
r := new(Renderer) r := new(Renderer)
r.header = htmlTocHeader r.Header = htmlTocHeader
r.codespan = htmlCodespan r.CodeSpan = htmlCodeSpan
r.doubleEmphasis = htmlDoubleEmphasis r.DoubleEmphasis = htmlDoubleEmphasis
r.emphasis = htmlEmphasis r.Emphasis = htmlEmphasis
r.tripleEmphasis = htmlTripleEmphasis r.TripleEmphasis = htmlTripleEmphasis
r.strikethrough = htmlStrikethrough r.StrikeThrough = htmlStrikeThrough
r.documentFooter = htmlTocFinalize r.DocumentFooter = htmlTocFinalize
close_tag := ">\n" closeTag := ">\n"
if flags&HTML_USE_XHTML != 0 { if flags&HTML_USE_XHTML != 0 {
close_tag = " />\n" closeTag = " />\n"
} }
r.opaque = &htmlOptions{flags: flags | HTML_TOC, close_tag: close_tag} r.Opaque = &htmlOptions{flags: flags | HTML_TOC, closeTag: closeTag}
return r return r
} }
@ -156,8 +156,8 @@ func htmlHeader(out *bytes.Buffer, text []byte, level int, opaque interface{}) {
} }
if options.flags&HTML_TOC != 0 { if options.flags&HTML_TOC != 0 {
out.WriteString(fmt.Sprintf("<h%d id=\"toc_%d\">", level, options.toc_data.header_count)) out.WriteString(fmt.Sprintf("<h%d id=\"toc_%d\">", level, options.tocData.headerCount))
options.toc_data.header_count++ options.tocData.headerCount++
} else { } else {
out.WriteString(fmt.Sprintf("<h%d>", level)) out.WriteString(fmt.Sprintf("<h%d>", level))
} }
@ -185,17 +185,17 @@ func htmlRawBlock(out *bytes.Buffer, text []byte, opaque interface{}) {
out.WriteByte('\n') out.WriteByte('\n')
} }
func htmlHrule(out *bytes.Buffer, opaque interface{}) { func htmlHRule(out *bytes.Buffer, opaque interface{}) {
options := opaque.(*htmlOptions) options := opaque.(*htmlOptions)
if out.Len() > 0 { if out.Len() > 0 {
out.WriteByte('\n') out.WriteByte('\n')
} }
out.WriteString("<hr") out.WriteString("<hr")
out.WriteString(options.close_tag) out.WriteString(options.closeTag)
} }
func htmlBlockcode(out *bytes.Buffer, text []byte, lang string, opaque interface{}) { func htmlBlockCode(out *bytes.Buffer, text []byte, lang string, opaque interface{}) {
if out.Len() > 0 { if out.Len() > 0 {
out.WriteByte('\n') out.WriteByte('\n')
} }
@ -255,7 +255,7 @@ func htmlBlockcode(out *bytes.Buffer, text []byte, lang string, opaque interface
* E.g. * E.g.
* ~~~~ {.python .numbered} => <pre lang="python"><code> * ~~~~ {.python .numbered} => <pre lang="python"><code>
*/ */
func htmlBlockcodeGithub(out *bytes.Buffer, text []byte, lang string, opaque interface{}) { func htmlBlockCodeGithub(out *bytes.Buffer, text []byte, lang string, opaque interface{}) {
if out.Len() > 0 { if out.Len() > 0 {
out.WriteByte('\n') out.WriteByte('\n')
} }
@ -287,7 +287,7 @@ func htmlBlockcodeGithub(out *bytes.Buffer, text []byte, lang string, opaque int
} }
func htmlBlockquote(out *bytes.Buffer, text []byte, opaque interface{}) { func htmlBlockQuote(out *bytes.Buffer, text []byte, opaque interface{}) {
out.WriteString("<blockquote>\n") out.WriteString("<blockquote>\n")
out.Write(text) out.Write(text)
out.WriteString("</blockquote>") out.WriteString("</blockquote>")
@ -349,7 +349,7 @@ func htmlList(out *bytes.Buffer, text []byte, flags int, opaque interface{}) {
} }
} }
func htmlListitem(out *bytes.Buffer, text []byte, flags int, opaque interface{}) { func htmlListItem(out *bytes.Buffer, text []byte, flags int, opaque interface{}) {
out.WriteString("<li>") out.WriteString("<li>")
size := len(text) size := len(text)
for size > 0 && text[size-1] == '\n' { for size > 0 && text[size-1] == '\n' {
@ -396,7 +396,7 @@ func htmlParagraph(out *bytes.Buffer, text []byte, opaque interface{}) {
} }
out.WriteString("<br>") out.WriteString("<br>")
out.WriteString(options.close_tag) out.WriteString(options.closeTag)
i++ i++
} }
} else { } else {
@ -405,7 +405,7 @@ func htmlParagraph(out *bytes.Buffer, text []byte, opaque interface{}) {
out.WriteString("</p>\n") out.WriteString("</p>\n")
} }
func htmlAutolink(out *bytes.Buffer, link []byte, kind int, opaque interface{}) int { func htmlAutoLink(out *bytes.Buffer, link []byte, kind int, opaque interface{}) int {
options := opaque.(*htmlOptions) options := opaque.(*htmlOptions)
if len(link) == 0 { if len(link) == 0 {
@ -441,7 +441,7 @@ func htmlAutolink(out *bytes.Buffer, link []byte, kind int, opaque interface{})
return 1 return 1
} }
func htmlCodespan(out *bytes.Buffer, text []byte, opaque interface{}) int { func htmlCodeSpan(out *bytes.Buffer, text []byte, opaque interface{}) int {
out.WriteString("<code>") out.WriteString("<code>")
attrEscape(out, text) attrEscape(out, text)
out.WriteString("</code>") out.WriteString("</code>")
@ -485,14 +485,14 @@ func htmlImage(out *bytes.Buffer, link []byte, title []byte, alt []byte, opaque
} }
out.WriteByte('"') out.WriteByte('"')
out.WriteString(options.close_tag) out.WriteString(options.closeTag)
return 1 return 1
} }
func htmlLinebreak(out *bytes.Buffer, opaque interface{}) int { func htmlLineBreak(out *bytes.Buffer, opaque interface{}) int {
options := opaque.(*htmlOptions) options := opaque.(*htmlOptions)
out.WriteString("<br") out.WriteString("<br")
out.WriteString(options.close_tag) out.WriteString(options.closeTag)
return 1 return 1
} }
@ -547,7 +547,7 @@ func htmlTripleEmphasis(out *bytes.Buffer, text []byte, opaque interface{}) int
return 1 return 1
} }
func htmlStrikethrough(out *bytes.Buffer, text []byte, opaque interface{}) int { func htmlStrikeThrough(out *bytes.Buffer, text []byte, opaque interface{}) int {
if len(text) == 0 { if len(text) == 0 {
return 0 return 0
} }
@ -563,26 +563,26 @@ func htmlNormalText(out *bytes.Buffer, text []byte, opaque interface{}) {
func htmlTocHeader(out *bytes.Buffer, text []byte, level int, opaque interface{}) { func htmlTocHeader(out *bytes.Buffer, text []byte, level int, opaque interface{}) {
options := opaque.(*htmlOptions) options := opaque.(*htmlOptions)
for level > options.toc_data.current_level { for level > options.tocData.currentLevel {
if options.toc_data.current_level > 0 { if options.tocData.currentLevel > 0 {
out.WriteString("<li>") out.WriteString("<li>")
} }
out.WriteString("<ul>\n") out.WriteString("<ul>\n")
options.toc_data.current_level++ options.tocData.currentLevel++
} }
for level < options.toc_data.current_level { for level < options.tocData.currentLevel {
out.WriteString("</ul>") out.WriteString("</ul>")
if options.toc_data.current_level > 1 { if options.tocData.currentLevel > 1 {
out.WriteString("</li>\n") out.WriteString("</li>\n")
} }
options.toc_data.current_level-- options.tocData.currentLevel--
} }
out.WriteString("<li><a href=\"#toc_") out.WriteString("<li><a href=\"#toc_")
out.WriteString(strconv.Itoa(options.toc_data.header_count)) out.WriteString(strconv.Itoa(options.tocData.headerCount))
out.WriteString("\">") out.WriteString("\">")
options.toc_data.header_count++ options.tocData.headerCount++
if len(text) > 0 { if len(text) > 0 {
out.Write(text) out.Write(text)
@ -592,12 +592,12 @@ func htmlTocHeader(out *bytes.Buffer, text []byte, level int, opaque interface{}
func htmlTocFinalize(out *bytes.Buffer, opaque interface{}) { func htmlTocFinalize(out *bytes.Buffer, opaque interface{}) {
options := opaque.(*htmlOptions) options := opaque.(*htmlOptions)
for options.toc_data.current_level > 1 { for options.tocData.currentLevel > 1 {
out.WriteString("</ul></li>\n") out.WriteString("</ul></li>\n")
options.toc_data.current_level-- options.tocData.currentLevel--
} }
if options.toc_data.current_level > 0 { if options.tocData.currentLevel > 0 {
out.WriteString("</ul>\n") out.WriteString("</ul>\n")
} }
} }

View File

@ -32,8 +32,8 @@ func parseInline(out *bytes.Buffer, rndr *render, data []byte) {
end++ end++
} }
if rndr.mk.normalText != nil { if rndr.mk.NormalText != nil {
rndr.mk.normalText(out, data[i:end], rndr.mk.opaque) rndr.mk.NormalText(out, data[i:end], rndr.mk.Opaque)
} else { } else {
out.Write(data[i:end]) out.Write(data[i:end])
} }
@ -102,7 +102,7 @@ func inlineEmphasis(out *bytes.Buffer, rndr *render, data []byte, offset int) in
return 0 return 0
} }
func inlineCodespan(out *bytes.Buffer, rndr *render, data []byte, offset int) int { func inlineCodeSpan(out *bytes.Buffer, rndr *render, data []byte, offset int) int {
data = data[offset:] data = data[offset:]
nb := 0 nb := 0
@ -138,15 +138,15 @@ func inlineCodespan(out *bytes.Buffer, rndr *render, data []byte, offset int) in
} }
// real code span // real code span
if rndr.mk.codespan == nil { if rndr.mk.CodeSpan == nil {
return 0 return 0
} }
if f_begin < f_end { if f_begin < f_end {
if rndr.mk.codespan(out, data[f_begin:f_end], rndr.mk.opaque) == 0 { if rndr.mk.CodeSpan(out, data[f_begin:f_end], rndr.mk.Opaque) == 0 {
end = 0 end = 0
} }
} else { } else {
if rndr.mk.codespan(out, nil, rndr.mk.opaque) == 0 { if rndr.mk.CodeSpan(out, nil, rndr.mk.Opaque) == 0 {
end = 0 end = 0
} }
} }
@ -156,7 +156,7 @@ func inlineCodespan(out *bytes.Buffer, rndr *render, data []byte, offset int) in
} }
// '\n' preceded by two spaces // '\n' preceded by two spaces
func inlineLinebreak(out *bytes.Buffer, rndr *render, data []byte, offset int) int { func inlineLineBreak(out *bytes.Buffer, rndr *render, data []byte, offset int) int {
if offset < 2 || data[offset-1] != ' ' || data[offset-2] != ' ' { if offset < 2 || data[offset-1] != ' ' || data[offset-2] != ' ' {
return 0 return 0
} }
@ -169,10 +169,10 @@ func inlineLinebreak(out *bytes.Buffer, rndr *render, data []byte, offset int) i
} }
out.Truncate(end) out.Truncate(end)
if rndr.mk.linebreak == nil { if rndr.mk.LineBreak == nil {
return 0 return 0
} }
if rndr.mk.linebreak(out, rndr.mk.opaque) > 0 { if rndr.mk.LineBreak(out, rndr.mk.Opaque) > 0 {
return 1 return 1
} else { } else {
return 0 return 0
@ -192,7 +192,7 @@ func inlineLink(out *bytes.Buffer, rndr *render, data []byte, offset int) int {
text_has_nl := false text_has_nl := false
// check whether the correct renderer exists // check whether the correct renderer exists
if (isImg && rndr.mk.image == nil) || (!isImg && rndr.mk.link == nil) { if (isImg && rndr.mk.Image == nil) || (!isImg && rndr.mk.Link == nil) {
return 0 return 0
} }
@ -428,9 +428,9 @@ func inlineLink(out *bytes.Buffer, rndr *render, data []byte, offset int) int {
out.Truncate(outSize - 1) out.Truncate(outSize - 1)
} }
ret = rndr.mk.image(out, u_link, title, content.Bytes(), rndr.mk.opaque) ret = rndr.mk.Image(out, u_link, title, content.Bytes(), rndr.mk.Opaque)
} else { } else {
ret = rndr.mk.link(out, u_link, title, content.Bytes(), rndr.mk.opaque) ret = rndr.mk.Link(out, u_link, title, content.Bytes(), rndr.mk.Opaque)
} }
if ret > 0 { if ret > 0 {
@ -440,7 +440,7 @@ func inlineLink(out *bytes.Buffer, rndr *render, data []byte, offset int) int {
} }
// '<' when tags or autolinks are allowed // '<' when tags or autolinks are allowed
func inlineLangle(out *bytes.Buffer, rndr *render, data []byte, offset int) int { func inlineLAngle(out *bytes.Buffer, rndr *render, data []byte, offset int) int {
data = data[offset:] data = data[offset:]
altype := LINK_TYPE_NOT_AUTOLINK altype := LINK_TYPE_NOT_AUTOLINK
end := tagLength(data, &altype) end := tagLength(data, &altype)
@ -448,12 +448,12 @@ func inlineLangle(out *bytes.Buffer, rndr *render, data []byte, offset int) int
if end > 2 { if end > 2 {
switch { switch {
case rndr.mk.autolink != nil && altype != LINK_TYPE_NOT_AUTOLINK: case rndr.mk.AutoLink != nil && altype != LINK_TYPE_NOT_AUTOLINK:
u_link := bytes.NewBuffer(nil) u_link := bytes.NewBuffer(nil)
unescapeText(u_link, data[1:end+1-2]) unescapeText(u_link, data[1:end+1-2])
ret = rndr.mk.autolink(out, u_link.Bytes(), altype, rndr.mk.opaque) ret = rndr.mk.AutoLink(out, u_link.Bytes(), altype, rndr.mk.Opaque)
case rndr.mk.rawHtmlTag != nil: case rndr.mk.RawHtmlTag != nil:
ret = rndr.mk.rawHtmlTag(out, data[:end], rndr.mk.opaque) ret = rndr.mk.RawHtmlTag(out, data[:end], rndr.mk.Opaque)
} }
} }
@ -474,8 +474,8 @@ func inlineEscape(out *bytes.Buffer, rndr *render, data []byte, offset int) int
return 0 return 0
} }
if rndr.mk.normalText != nil { if rndr.mk.NormalText != nil {
rndr.mk.normalText(out, data[1:2], rndr.mk.opaque) rndr.mk.NormalText(out, data[1:2], rndr.mk.Opaque)
} else { } else {
out.WriteByte(data[1]) out.WriteByte(data[1])
} }
@ -526,8 +526,8 @@ func inlineEntity(out *bytes.Buffer, rndr *render, data []byte, offset int) int
return 0 // lone '&' return 0 // lone '&'
} }
if rndr.mk.entity != nil { if rndr.mk.Entity != nil {
rndr.mk.entity(out, data[:end], rndr.mk.opaque) rndr.mk.Entity(out, data[:end], rndr.mk.Opaque)
} else { } else {
out.Write(data[:end]) out.Write(data[:end])
} }
@ -535,7 +535,7 @@ func inlineEntity(out *bytes.Buffer, rndr *render, data []byte, offset int) int
return end return end
} }
func inlineAutolink(out *bytes.Buffer, rndr *render, data []byte, offset int) int { func inlineAutoLink(out *bytes.Buffer, rndr *render, data []byte, offset int) int {
// quick check to rule out most false hits on ':' // quick check to rule out most false hits on ':'
if len(data) < offset + 3 || data[offset+1] != '/' || data[offset+2] != '/' { if len(data) < offset + 3 || data[offset+1] != '/' || data[offset+2] != '/' {
return 0 return 0
@ -631,11 +631,11 @@ func inlineAutolink(out *bytes.Buffer, rndr *render, data []byte, offset int) in
out.Truncate(len(out.Bytes()) - rewind) out.Truncate(len(out.Bytes()) - rewind)
} }
if rndr.mk.autolink != nil { if rndr.mk.AutoLink != nil {
u_link := bytes.NewBuffer(nil) u_link := bytes.NewBuffer(nil)
unescapeText(u_link, data[:link_end]) unescapeText(u_link, data[:link_end])
rndr.mk.autolink(out, u_link.Bytes(), LINK_TYPE_NORMAL, rndr.mk.opaque) rndr.mk.AutoLink(out, u_link.Bytes(), LINK_TYPE_NORMAL, rndr.mk.Opaque)
} }
return link_end - rewind return link_end - rewind
@ -687,7 +687,7 @@ func tagLength(data []byte, autolink *int) int {
} }
if i > 1 && data[i] == '@' { if i > 1 && data[i] == '@' {
if j = isMailtoAutolink(data[i:]); j != 0 { if j = isMailtoAutoLink(data[i:]); j != 0 {
*autolink = LINK_TYPE_EMAIL *autolink = LINK_TYPE_EMAIL
return i + j return i + j
} }
@ -741,7 +741,7 @@ func tagLength(data []byte, autolink *int) int {
// look for the address part of a mail autolink and '>' // look for the address part of a mail autolink and '>'
// this is less strict than the original markdown e-mail address matching // this is less strict than the original markdown e-mail address matching
func isMailtoAutolink(data []byte) int { func isMailtoAutoLink(data []byte) int {
nb := 0 nb := 0
// address is assumed to be: [-@._a-zA-Z0-9]+ with exactly one '@' // address is assumed to be: [-@._a-zA-Z0-9]+ with exactly one '@'
@ -852,7 +852,7 @@ func inlineHelperFindEmphChar(data []byte, c byte) int {
func inlineHelperEmph1(out *bytes.Buffer, rndr *render, data []byte, c byte) int { func inlineHelperEmph1(out *bytes.Buffer, rndr *render, data []byte, c byte) int {
i := 0 i := 0
if rndr.mk.emphasis == nil { if rndr.mk.Emphasis == nil {
return 0 return 0
} }
@ -886,7 +886,7 @@ func inlineHelperEmph1(out *bytes.Buffer, rndr *render, data []byte, c byte) int
work := bytes.NewBuffer(nil) work := bytes.NewBuffer(nil)
parseInline(work, rndr, data[:i]) parseInline(work, rndr, data[:i])
r := rndr.mk.emphasis(out, work.Bytes(), rndr.mk.opaque) r := rndr.mk.Emphasis(out, work.Bytes(), rndr.mk.Opaque)
if r > 0 { if r > 0 {
return i + 1 return i + 1
} else { } else {
@ -899,9 +899,9 @@ func inlineHelperEmph1(out *bytes.Buffer, rndr *render, data []byte, c byte) int
} }
func inlineHelperEmph2(out *bytes.Buffer, rndr *render, data []byte, c byte) int { func inlineHelperEmph2(out *bytes.Buffer, rndr *render, data []byte, c byte) int {
render_method := rndr.mk.doubleEmphasis render_method := rndr.mk.DoubleEmphasis
if c == '~' { if c == '~' {
render_method = rndr.mk.strikethrough render_method = rndr.mk.StrikeThrough
} }
if render_method == nil { if render_method == nil {
@ -920,7 +920,7 @@ func inlineHelperEmph2(out *bytes.Buffer, rndr *render, data []byte, c byte) int
if i+1 < len(data) && data[i] == c && data[i+1] == c && i > 0 && !isspace(data[i-1]) { if i+1 < len(data) && data[i] == c && data[i+1] == c && i > 0 && !isspace(data[i-1]) {
work := bytes.NewBuffer(nil) work := bytes.NewBuffer(nil)
parseInline(work, rndr, data[:i]) parseInline(work, rndr, data[:i])
r := render_method(out, work.Bytes(), rndr.mk.opaque) r := render_method(out, work.Bytes(), rndr.mk.Opaque)
if r > 0 { if r > 0 {
return i + 2 return i + 2
} else { } else {
@ -950,12 +950,12 @@ func inlineHelperEmph3(out *bytes.Buffer, rndr *render, data []byte, offset int,
} }
switch { switch {
case (i+2 < len(data) && data[i+1] == c && data[i+2] == c && rndr.mk.tripleEmphasis != nil): case (i+2 < len(data) && data[i+1] == c && data[i+2] == c && rndr.mk.TripleEmphasis != nil):
// triple symbol found // triple symbol found
work := bytes.NewBuffer(nil) work := bytes.NewBuffer(nil)
parseInline(work, rndr, data[:i]) parseInline(work, rndr, data[:i])
r := rndr.mk.tripleEmphasis(out, work.Bytes(), rndr.mk.opaque) r := rndr.mk.TripleEmphasis(out, work.Bytes(), rndr.mk.Opaque)
if r > 0 { if r > 0 {
return i + 3 return i + 3
} else { } else {

View File

@ -19,40 +19,40 @@ import (
func LatexRenderer(flags int) *Renderer { func LatexRenderer(flags int) *Renderer {
// block-level rendering // block-level rendering
r := new(Renderer) r := new(Renderer)
r.blockcode = latexBlockcode r.BlockCode = latexBlockCode
r.blockquote = latexBlockquote r.BlockQuote = latexBlockQuote
//r.blockhtml = ? //r.BlockHtml = ?
r.header = latexHeader r.Header = latexHeader
r.hrule = latexHrule r.HRule = latexHRule
r.list = latexList r.List = latexList
r.listitem = latexListitem r.ListItem = latexListItem
r.paragraph = latexParagraph r.Paragraph = latexParagraph
r.table = latexTable r.Table = latexTable
r.tableRow = latexTableRow r.TableRow = latexTableRow
r.tableCell = latexTableCell r.TableCell = latexTableCell
// inline rendering // inline rendering
r.autolink = latexAutolink r.AutoLink = latexAutoLink
r.codespan = latexCodespan r.CodeSpan = latexCodeSpan
r.doubleEmphasis = latexDoubleEmphasis r.DoubleEmphasis = latexDoubleEmphasis
r.emphasis = latexEmphasis r.Emphasis = latexEmphasis
r.image = latexImage r.Image = latexImage
r.linebreak = latexLinebreak r.LineBreak = latexLineBreak
r.link = latexLink r.Link = latexLink
//r.rawHtmlTag = ? //r.rawHtmlTag = ?
r.strikethrough = latexStrikethrough r.StrikeThrough = latexStrikeThrough
r.normalText = latexNormalText r.NormalText = latexNormalText
r.documentHeader = latexDocumentHeader r.DocumentHeader = latexDocumentHeader
r.documentFooter = latexDocumentFooter r.DocumentFooter = latexDocumentFooter
r.opaque = nil r.Opaque = nil
return r return r
} }
// render code chunks using verbatim, or listings if we have a language // render code chunks using verbatim, or listings if we have a language
func latexBlockcode(out *bytes.Buffer, text []byte, lang string, opaque interface{}) { func latexBlockCode(out *bytes.Buffer, text []byte, lang string, opaque interface{}) {
if lang == "" { if lang == "" {
out.WriteString("\n\\begin{verbatim}\n") out.WriteString("\n\\begin{verbatim}\n")
} else { } else {
@ -68,13 +68,13 @@ func latexBlockcode(out *bytes.Buffer, text []byte, lang string, opaque interfac
} }
} }
func latexBlockquote(out *bytes.Buffer, text []byte, opaque interface{}) { func latexBlockQuote(out *bytes.Buffer, text []byte, opaque interface{}) {
out.WriteString("\n\\begin{quotation}\n") out.WriteString("\n\\begin{quotation}\n")
out.Write(text) out.Write(text)
out.WriteString("\n\\end{quotation}\n") out.WriteString("\n\\end{quotation}\n")
} }
//blockhtml func(out *bytes.Buffer, text []byte, opaque interface{}) //BlockHtml func(out *bytes.Buffer, text []byte, opaque interface{})
func latexHeader(out *bytes.Buffer, text []byte, level int, opaque interface{}) { func latexHeader(out *bytes.Buffer, text []byte, level int, opaque interface{}) {
switch level { switch level {
@ -95,7 +95,7 @@ func latexHeader(out *bytes.Buffer, text []byte, level int, opaque interface{})
out.WriteString("}\n") out.WriteString("}\n")
} }
func latexHrule(out *bytes.Buffer, opaque interface{}) { func latexHRule(out *bytes.Buffer, opaque interface{}) {
out.WriteString("\n\\HRule\n") out.WriteString("\n\\HRule\n")
} }
@ -113,7 +113,7 @@ func latexList(out *bytes.Buffer, text []byte, flags int, opaque interface{}) {
} }
} }
func latexListitem(out *bytes.Buffer, text []byte, flags int, opaque interface{}) { func latexListItem(out *bytes.Buffer, text []byte, flags int, opaque interface{}) {
out.WriteString("\n\\item ") out.WriteString("\n\\item ")
out.Write(text) out.Write(text)
} }
@ -157,7 +157,7 @@ func latexTableCell(out *bytes.Buffer, text []byte, align int, opaque interface{
out.Write(text) out.Write(text)
} }
func latexAutolink(out *bytes.Buffer, link []byte, kind int, opaque interface{}) int { func latexAutoLink(out *bytes.Buffer, link []byte, kind int, opaque interface{}) int {
out.WriteString("\\href{") out.WriteString("\\href{")
if kind == LINK_TYPE_EMAIL { if kind == LINK_TYPE_EMAIL {
out.WriteString("mailto:") out.WriteString("mailto:")
@ -169,7 +169,7 @@ func latexAutolink(out *bytes.Buffer, link []byte, kind int, opaque interface{})
return 1 return 1
} }
func latexCodespan(out *bytes.Buffer, text []byte, opaque interface{}) int { func latexCodeSpan(out *bytes.Buffer, text []byte, opaque interface{}) int {
out.WriteString("\\texttt{") out.WriteString("\\texttt{")
escapeSpecialChars(out, text) escapeSpecialChars(out, text)
out.WriteString("}") out.WriteString("}")
@ -206,7 +206,7 @@ func latexImage(out *bytes.Buffer, link []byte, title []byte, alt []byte, opaque
return 1 return 1
} }
func latexLinebreak(out *bytes.Buffer, opaque interface{}) int { func latexLineBreak(out *bytes.Buffer, opaque interface{}) int {
out.WriteString(" \\\\\n") out.WriteString(" \\\\\n")
return 1 return 1
} }
@ -231,7 +231,7 @@ func latexTripleEmphasis(out *bytes.Buffer, text []byte, opaque interface{}) int
return 1 return 1
} }
func latexStrikethrough(out *bytes.Buffer, text []byte, opaque interface{}) int { func latexStrikeThrough(out *bytes.Buffer, text []byte, opaque interface{}) int {
out.WriteString("\\sout{") out.WriteString("\\sout{")
out.Write(text) out.Write(text)
out.WriteString("}") out.WriteString("}")

View File

@ -95,40 +95,40 @@ var block_tags = map[string]bool{
// Most users will use the convenience functions to fill in this structure. // Most users will use the convenience functions to fill in this structure.
type Renderer struct { type Renderer struct {
// block-level callbacks---nil skips the block // block-level callbacks---nil skips the block
blockcode func(out *bytes.Buffer, text []byte, lang string, opaque interface{}) BlockCode func(out *bytes.Buffer, text []byte, lang string, opaque interface{})
blockquote func(out *bytes.Buffer, text []byte, opaque interface{}) BlockQuote func(out *bytes.Buffer, text []byte, opaque interface{})
blockhtml func(out *bytes.Buffer, text []byte, opaque interface{}) BlockHtml func(out *bytes.Buffer, text []byte, opaque interface{})
header func(out *bytes.Buffer, text []byte, level int, opaque interface{}) Header func(out *bytes.Buffer, text []byte, level int, opaque interface{})
hrule func(out *bytes.Buffer, opaque interface{}) HRule func(out *bytes.Buffer, opaque interface{})
list func(out *bytes.Buffer, text []byte, flags int, opaque interface{}) List func(out *bytes.Buffer, text []byte, 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 []byte, 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{})
// span-level callbacks---nil or return 0 prints the span verbatim // Span-level callbacks---nil or return 0 prints the span verbatim
autolink func(out *bytes.Buffer, link []byte, kind int, opaque interface{}) int AutoLink func(out *bytes.Buffer, link []byte, kind int, opaque interface{}) int
codespan func(out *bytes.Buffer, text []byte, opaque interface{}) int CodeSpan func(out *bytes.Buffer, text []byte, opaque interface{}) int
doubleEmphasis func(out *bytes.Buffer, text []byte, opaque interface{}) int DoubleEmphasis func(out *bytes.Buffer, text []byte, opaque interface{}) int
emphasis func(out *bytes.Buffer, text []byte, opaque interface{}) int Emphasis func(out *bytes.Buffer, text []byte, opaque interface{}) int
image func(out *bytes.Buffer, link []byte, title []byte, alt []byte, opaque interface{}) int Image func(out *bytes.Buffer, link []byte, title []byte, alt []byte, opaque interface{}) int
linebreak func(out *bytes.Buffer, opaque interface{}) int LineBreak func(out *bytes.Buffer, opaque interface{}) int
link func(out *bytes.Buffer, link []byte, title []byte, content []byte, opaque interface{}) int Link func(out *bytes.Buffer, link []byte, title []byte, content []byte, opaque interface{}) int
rawHtmlTag func(out *bytes.Buffer, tag []byte, opaque interface{}) int RawHtmlTag func(out *bytes.Buffer, tag []byte, opaque interface{}) int
tripleEmphasis func(out *bytes.Buffer, text []byte, opaque interface{}) int TripleEmphasis func(out *bytes.Buffer, text []byte, opaque interface{}) int
strikethrough func(out *bytes.Buffer, text []byte, opaque interface{}) int StrikeThrough func(out *bytes.Buffer, text []byte, opaque interface{}) int
// low-level callbacks---nil copies input directly into the output // Low-level callbacks---nil copies input directly into the output
entity func(out *bytes.Buffer, entity []byte, opaque interface{}) Entity func(out *bytes.Buffer, entity []byte, opaque interface{})
normalText func(out *bytes.Buffer, text []byte, opaque interface{}) NormalText func(out *bytes.Buffer, text []byte, opaque interface{})
// header and footer // Header and footer
documentHeader func(out *bytes.Buffer, opaque interface{}) DocumentHeader func(out *bytes.Buffer, opaque interface{})
documentFooter func(out *bytes.Buffer, opaque interface{}) DocumentFooter func(out *bytes.Buffer, opaque interface{})
// user data---passed back to every callback // User data---passed back to every callback
opaque interface{} Opaque interface{}
} }
type inlineParser func(out *bytes.Buffer, rndr *render, data []byte, offset int) int type inlineParser func(out *bytes.Buffer, rndr *render, data []byte, offset int) int
@ -166,28 +166,28 @@ func Markdown(input []byte, renderer *Renderer, extensions uint32) []byte {
rndr.maxNesting = 16 rndr.maxNesting = 16
// register inline parsers // register inline parsers
if rndr.mk.emphasis != nil || rndr.mk.doubleEmphasis != nil || rndr.mk.tripleEmphasis != nil { if rndr.mk.Emphasis != nil || rndr.mk.DoubleEmphasis != nil || rndr.mk.TripleEmphasis != nil {
rndr.inline['*'] = inlineEmphasis rndr.inline['*'] = inlineEmphasis
rndr.inline['_'] = inlineEmphasis rndr.inline['_'] = inlineEmphasis
if extensions&EXTENSION_STRIKETHROUGH != 0 { if extensions&EXTENSION_STRIKETHROUGH != 0 {
rndr.inline['~'] = inlineEmphasis rndr.inline['~'] = inlineEmphasis
} }
} }
if rndr.mk.codespan != nil { if rndr.mk.CodeSpan != nil {
rndr.inline['`'] = inlineCodespan rndr.inline['`'] = inlineCodeSpan
} }
if rndr.mk.linebreak != nil { if rndr.mk.LineBreak != nil {
rndr.inline['\n'] = inlineLinebreak rndr.inline['\n'] = inlineLineBreak
} }
if rndr.mk.image != nil || rndr.mk.link != nil { if rndr.mk.Image != nil || rndr.mk.Link != nil {
rndr.inline['['] = inlineLink rndr.inline['['] = inlineLink
} }
rndr.inline['<'] = inlineLangle rndr.inline['<'] = inlineLAngle
rndr.inline['\\'] = inlineEscape rndr.inline['\\'] = inlineEscape
rndr.inline['&'] = inlineEntity rndr.inline['&'] = inlineEntity
if extensions&EXTENSION_AUTOLINK != 0 { if extensions&EXTENSION_AUTOLINK != 0 {
rndr.inline[':'] = inlineAutolink rndr.inline[':'] = inlineAutoLink
} }
// first pass: look for references, copy everything else // first pass: look for references, copy everything else
@ -221,8 +221,8 @@ func Markdown(input []byte, renderer *Renderer, extensions uint32) []byte {
// second pass: actual rendering // second pass: actual rendering
output := bytes.NewBuffer(nil) output := bytes.NewBuffer(nil)
if rndr.mk.documentHeader != nil { if rndr.mk.DocumentHeader != nil {
rndr.mk.documentHeader(output, rndr.mk.opaque) rndr.mk.DocumentHeader(output, rndr.mk.Opaque)
} }
if text.Len() > 0 { if text.Len() > 0 {
@ -234,8 +234,8 @@ func Markdown(input []byte, renderer *Renderer, extensions uint32) []byte {
parseBlock(output, rndr, text.Bytes()) parseBlock(output, rndr, text.Bytes())
} }
if rndr.mk.documentFooter != nil { if rndr.mk.DocumentFooter != nil {
rndr.mk.documentFooter(output, rndr.mk.opaque) rndr.mk.DocumentFooter(output, rndr.mk.Opaque)
} }
if rndr.nesting != 0 { if rndr.nesting != 0 {