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,19 +399,27 @@ 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] == '`') {
|
||||||
|
i++; span_nb++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= size) return 0;
|
||||||
|
|
||||||
|
/* finding the matching closing sequence */
|
||||||
|
bt = 0;
|
||||||
|
while (i < size && bt < span_nb) {
|
||||||
if (!tmp_i && data[i] == c) tmp_i = i;
|
if (!tmp_i && data[i] == c) tmp_i = i;
|
||||||
|
if (data[i] == '`') bt++;
|
||||||
|
else bt = 0;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= size)
|
if (i >= size) return tmp_i;
|
||||||
return tmp_i;
|
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
/* skipping a link */
|
/* skipping a link */
|
||||||
|
|
Loading…
Reference in a new issue