mirror of
https://github.com/danog/blackfriday.git
synced 2025-01-23 05:41:27 +01:00
Fix bug parsing emphasis
Start searching for emphasis character at 0th index instead of 1st. Fixes a corner case with doubly emphasised code span followed by another code span on the same line. Changes interpretation of improperly nested emphasis, hence the change in TestEmphasisMix(). Closes #156.
This commit is contained in:
parent
8cec3a854e
commit
cc3cc10ef2
@ -910,7 +910,7 @@ func isMailtoAutoLink(data []byte) int {
|
|||||||
|
|
||||||
// look for the next emph char, skipping other constructs
|
// look for the next emph char, skipping other constructs
|
||||||
func helperFindEmphChar(data []byte, c byte) int {
|
func helperFindEmphChar(data []byte, c byte) int {
|
||||||
i := 1
|
i := 0
|
||||||
|
|
||||||
for i < len(data) {
|
for i < len(data) {
|
||||||
for i < len(data) && data[i] != c && data[i] != '`' && data[i] != '[' {
|
for i < len(data) && data[i] != c && data[i] != '`' && data[i] != '[' {
|
||||||
|
@ -263,6 +263,12 @@ func TestStrong(t *testing.T) {
|
|||||||
|
|
||||||
"mix of **markers__\n",
|
"mix of **markers__\n",
|
||||||
"<p>mix of **markers__</p>\n",
|
"<p>mix of **markers__</p>\n",
|
||||||
|
|
||||||
|
"**`/usr`** : this folder is named `usr`\n",
|
||||||
|
"<p><strong><code>/usr</code></strong> : this folder is named <code>usr</code></p>\n",
|
||||||
|
|
||||||
|
"**`/usr`** :\n\n this folder is named `usr`\n",
|
||||||
|
"<p><strong><code>/usr</code></strong> :</p>\n\n<p>this folder is named <code>usr</code></p>\n",
|
||||||
}
|
}
|
||||||
doTestsInline(t, tests)
|
doTestsInline(t, tests)
|
||||||
}
|
}
|
||||||
@ -291,7 +297,7 @@ func TestEmphasisMix(t *testing.T) {
|
|||||||
"<p><strong>improper *nesting</strong> is* bad</p>\n",
|
"<p><strong>improper *nesting</strong> is* bad</p>\n",
|
||||||
|
|
||||||
"*improper **nesting* is** bad\n",
|
"*improper **nesting* is** bad\n",
|
||||||
"<p><em>improper **nesting</em> is** bad</p>\n",
|
"<p>*improper <strong>nesting* is</strong> bad</p>\n",
|
||||||
}
|
}
|
||||||
doTestsInline(t, tests)
|
doTestsInline(t, tests)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user