mirror of
https://github.com/danog/blackfriday.git
synced 2024-12-02 09:27:49 +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) {
|
if i >= len(data) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if data[i] == c {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|
||||||
// do not count escaped chars
|
// do not count escaped chars
|
||||||
if i != 0 && data[i-1] == '\\' {
|
if i != 0 && data[i-1] == '\\' {
|
||||||
i++
|
i++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if data[i] == c {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
if data[i] == '`' {
|
if data[i] == '`' {
|
||||||
// skip a code span
|
// skip a code span
|
||||||
|
@ -153,6 +153,9 @@ func TestEmphasis(t *testing.T) {
|
|||||||
|
|
||||||
"mix of *markers_\n",
|
"mix of *markers_\n",
|
||||||
"<p>mix of *markers_</p>\n",
|
"<p>mix of *markers_</p>\n",
|
||||||
|
|
||||||
|
"*What is A\\* algorithm?*\n",
|
||||||
|
"<p><em>What is A* algorithm?</em></p>\n",
|
||||||
}
|
}
|
||||||
doTestsInline(t, tests)
|
doTestsInline(t, tests)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user