all repos — grayfriday @ 6d7f5e1bcab8da61c61f85ae261fca17d3bdc5ed

blackfriday fork with a few changes

More lint: block.go
Vytautas Ĺ altenis vytas@rtfb.lt
Wed, 27 Jul 2016 21:40:45 +0300
commit

6d7f5e1bcab8da61c61f85ae261fca17d3bdc5ed

parent

cd2f07914086ce83562503391104a51d74a62106

2 files changed, 12 insertions(+), 15 deletions(-)

jump to
M block.goblock.go

@@ -22,13 +22,13 @@ "github.com/shurcooL/sanitized_anchor_name"

) const ( - Entity = "&(?:#x[a-f0-9]{1,8}|#[0-9]{1,8}|[a-z][a-z0-9]{1,31});" - Escapable = "[!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]" + charEntity = "&(?:#x[a-f0-9]{1,8}|#[0-9]{1,8}|[a-z][a-z0-9]{1,31});" + escapable = "[!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]" ) var ( reBackslashOrAmp = regexp.MustCompile("[\\&]") - reEntityOrEscapedChar = regexp.MustCompile("(?i)\\\\" + Escapable + "|" + Entity) + reEntityOrEscapedChar = regexp.MustCompile("(?i)\\\\" + escapable + "|" + charEntity) reTrailingWhitespace = regexp.MustCompile("(\n *)+$") )

@@ -279,9 +279,8 @@ i := skipChar(data, 1, '=')

i = skipChar(data, i, ' ') if data[i] == '\n' { return 1 - } else { - return 0 } + return 0 } // test of level 2 header

@@ -290,9 +289,8 @@ i := skipChar(data, 1, '-')

i = skipChar(data, i, ' ') if data[i] == '\n' { return 2 - } else { - return 0 } + return 0 } return 0

@@ -414,13 +412,13 @@ end := i

for end > 0 && data[end-1] == '\n' { end-- } - finalizeHtmlBlock(p.addBlock(HTMLBlock, data[:end])) + finalizeHTMLBlock(p.addBlock(HTMLBlock, data[:end])) } return i } -func finalizeHtmlBlock(block *Node) { +func finalizeHTMLBlock(block *Node) { block.Literal = reTrailingWhitespace.ReplaceAll(block.content, []byte{}) block.content = []byte{} }

@@ -438,7 +436,7 @@ for end > 0 && data[end-1] == '\n' {

end-- } block := p.addBlock(HTMLBlock, data[:end]) - finalizeHtmlBlock(block) + finalizeHTMLBlock(block) } return size }

@@ -470,7 +468,7 @@ end := size

for end > 0 && data[end-1] == '\n' { end-- } - finalizeHtmlBlock(p.addBlock(HTMLBlock, data[:end])) + finalizeHTMLBlock(p.addBlock(HTMLBlock, data[:end])) } return size }

@@ -729,9 +727,8 @@

func unescapeString(str []byte) []byte { if reBackslashOrAmp.Match(str) { return reEntityOrEscapedChar.ReplaceAllFunc(str, unescapeChar) - } else { - return str } + return str } func finalizeCodeBlock(block *Node) {
M markdown.gomarkdown.go

@@ -492,7 +492,7 @@ if p.flags&Footnotes == 0 || len(p.notes) == 0 {

return } p.tip = p.doc - finalizeHtmlBlock(p.addBlock(HTMLBlock, []byte(`<div class="footnotes">`))) + finalizeHTMLBlock(p.addBlock(HTMLBlock, []byte(`<div class="footnotes">`))) p.addBlock(HorizontalRule, nil) block := p.addBlock(List, nil) block.ListFlags = ListTypeOrdered

@@ -518,7 +518,7 @@ }

above := block.Parent finalizeList(block) p.tip = above - finalizeHtmlBlock(p.addBlock(HTMLBlock, []byte("</div>"))) + finalizeHTMLBlock(p.addBlock(HTMLBlock, []byte("</div>"))) block.Walk(func(node *Node, entering bool) WalkStatus { if node.Type == Paragraph || node.Type == Header { p.currBlock = node