1
0
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:
Vytautas Šaltenis 2015-10-13 19:57:07 +03:00
parent 8cec3a854e
commit f7510976a3
2 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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)
}