mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
fixed minor bugs uncovered by more testing
This commit is contained in:
parent
47c4852520
commit
9a0217f7aa
7
block.go
7
block.go
|
@ -335,7 +335,7 @@ func blockHtml(out *bytes.Buffer, rndr *render, data []byte, do_render bool) int
|
|||
|
||||
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) {
|
||||
|
|
|
@ -198,6 +198,9 @@ func TestUnderlineHeaders(t *testing.T) {
|
|||
|
||||
"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)
|
||||
}
|
||||
|
|
14
inline.go
14
inline.go
|
@ -123,9 +123,9 @@ func inlineCodeSpan(out *bytes.Buffer, rndr *render, data []byte, offset int) in
|
|||
}
|
||||
}
|
||||
|
||||
// no matching delimiter?
|
||||
if i < nb && end >= len(data) {
|
||||
out.WriteByte('`')
|
||||
return 0 // no matching delimiter
|
||||
return 0
|
||||
}
|
||||
|
||||
// trim outside whitespace
|
||||
|
@ -135,23 +135,17 @@ func inlineCodeSpan(out *bytes.Buffer, rndr *render, data []byte, offset int) in
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
return end
|
||||
|
||||
|
|
|
@ -16,19 +16,11 @@ import (
|
|||
|
||||
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user