mirror of
https://github.com/danog/blackfriday.git
synced 2024-11-30 04:29:13 +01:00
Fix escaping asterisks within emphasis
First check for escaped character, *then* look if i-th character is an emphasis character. Closes #18.
This commit is contained in:
parent
8cec3a854e
commit
f7510976a3
@ -919,15 +919,14 @@ func helperFindEmphChar(data []byte, c byte) int {
|
||||
if i >= len(data) {
|
||||
return 0
|
||||
}
|
||||
if data[i] == c {
|
||||
return i
|
||||
}
|
||||
|
||||
// do not count escaped chars
|
||||
if i != 0 && data[i-1] == '\\' {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
if data[i] == c {
|
||||
return i
|
||||
}
|
||||
|
||||
if data[i] == '`' {
|
||||
// skip a code span
|
||||
|
@ -153,6 +153,9 @@ func TestEmphasis(t *testing.T) {
|
||||
|
||||
"mix of *markers_\n",
|
||||
"<p>mix of *markers_</p>\n",
|
||||
|
||||
"*What is A\\* algorithm?*\n",
|
||||
"<p><em>What is A* algorithm?</em></p>\n",
|
||||
}
|
||||
doTestsInline(t, tests)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user