all repos — grayfriday @ 9a0217f7aa435282b4ba9139d9141bccca28ab05

blackfriday fork with a few changes

fixed minor bugs uncovered by more testing
Russ Ross russ@russross.com
Mon, 27 Jun 2011 14:35:11 -0600
commit

9a0217f7aa435282b4ba9139d9141bccca28ab05

parent

47c48525200b30e3ac433fae66d6f0bad7911953

4 files changed, 13 insertions(+), 23 deletions(-)

jump to
M block.goblock.go

@@ -335,7 +335,7 @@ }

func blockHtmlFindTag(data []byte) (string, bool) { i := 0 - for i < len(data) && ((data[i] >= '0' && data[i] <= '9') || (data[i] >= 'A' && data[i] <= 'Z') || (data[i] >= 'a' && data[i] <= 'z')) { + for i < len(data) && isalnum(data[i]) { i++ } if i >= len(data) {

@@ -352,11 +352,12 @@ func blockHtmlFindEnd(tag string, rndr *render, data []byte) int {

// assume data[0] == '<' && data[1] == '/' already tested // check if tag is a match - if len(tag)+3 >= len(data) || bytes.Compare(data[2:2+len(tag)], []byte(tag)) != 0 || data[len(tag)+2] != '>' { + if len(data) < len(tag)+3 || data[len(tag)+2] != '>' || + bytes.Compare(data[2:2+len(tag)], []byte(tag)) != 0 { return 0 } - // check white lines + // check for blank line/eof after the closing tag i := len(tag) + 3 w := 0 if i < len(data) {
M block_test.goblock_test.go

@@ -198,6 +198,9 @@ "<h1>Trailing space</h1>\n",

"Trailing spaces\n==== \n\n", "<h1>Trailing spaces</h1>\n", + + "Double underline\n=====\n=====\n", + "<h1>Double underline</h1>\n\n<p>=====</p>\n", } doTestsBlock(t, tests, 0) }
M inline.goinline.go

@@ -123,9 +123,9 @@ i = 0

} } + // no matching delimiter? if i < nb && end >= len(data) { - out.WriteByte('`') - return 0 // no matching delimiter + return 0 } // trim outside whitespace

@@ -135,22 +135,16 @@ f_begin++

} f_end := end - nb - for f_end > nb && (data[f_end-1] == ' ' || data[f_end-1] == '\t') { + for f_end > f_begin && (data[f_end-1] == ' ' || data[f_end-1] == '\t') { f_end-- } - // real code span + // render the code span if rndr.mk.CodeSpan == nil { return 0 } - if f_begin < f_end { - if rndr.mk.CodeSpan(out, data[f_begin:f_end], rndr.mk.Opaque) == 0 { - end = 0 - } - } else { - if rndr.mk.CodeSpan(out, nil, rndr.mk.Opaque) == 0 { - end = 0 - } + if rndr.mk.CodeSpan(out, data[f_begin:f_end], rndr.mk.Opaque) == 0 { + end = 0 } return end
M inline_test.goinline_test.go

@@ -16,19 +16,11 @@ )

func runMarkdownInline(input string) string { var extensions uint32 - extensions |= EXTENSION_NO_INTRA_EMPHASIS - extensions |= EXTENSION_TABLES - extensions |= EXTENSION_FENCED_CODE extensions |= EXTENSION_AUTOLINK extensions |= EXTENSION_STRIKETHROUGH - extensions |= EXTENSION_SPACE_HEADERS - extensions |= EXTENSION_LAX_HTML_BLOCKS html_flags := 0 html_flags |= HTML_USE_XHTML - html_flags |= HTML_USE_SMARTYPANTS - html_flags |= HTML_SMARTYPANTS_FRACTIONS - html_flags |= HTML_SMARTYPANTS_LATEX_DASHES renderer := HtmlRenderer(html_flags)