markdown: Fix codespan skip
Backport from Upskirt. Thanks Natacha!
This commit is contained in:
parent
03d2e3efa3
commit
a0b0a11d0e
1 changed files with 16 additions and 8 deletions
|
@ -399,20 +399,28 @@ find_emph_char(char *data, size_t size, char c)
|
||||||
i++; continue;
|
i++; continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skipping a code span */
|
|
||||||
if (data[i] == '`') {
|
if (data[i] == '`') {
|
||||||
|
size_t span_nb = 0, bt;
|
||||||
size_t tmp_i = 0;
|
size_t tmp_i = 0;
|
||||||
|
|
||||||
i++;
|
/* counting the number of opening backticks */
|
||||||
while (i < size && data[i] != '`') {
|
while (i < size && data[i] == '`') {
|
||||||
if (!tmp_i && data[i] == c) tmp_i = i;
|
i++; span_nb++;
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= size)
|
if (i >= size) return 0;
|
||||||
return tmp_i;
|
|
||||||
|
|
||||||
i++;
|
/* finding the matching closing sequence */
|
||||||
|
bt = 0;
|
||||||
|
while (i < size && bt < span_nb) {
|
||||||
|
if (!tmp_i && data[i] == c) tmp_i = i;
|
||||||
|
if (data[i] == '`') bt++;
|
||||||
|
else bt = 0;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= size) return tmp_i;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
/* skipping a link */
|
/* skipping a link */
|
||||||
else if (data[i] == '[') {
|
else if (data[i] == '[') {
|
||||||
|
|
Loading…
Reference in a new issue