markdown: Fix codespan skip

Backport from Upskirt. Thanks Natacha!
This commit is contained in:
Vicent Marti 2011-08-08 12:35:50 -07:00
parent 03d2e3efa3
commit a0b0a11d0e

View file

@ -399,20 +399,28 @@ find_emph_char(char *data, size_t size, char c)
i++; continue;
}
/* skipping a code span */
if (data[i] == '`') {
size_t span_nb = 0, bt;
size_t tmp_i = 0;
i++;
while (i < size && data[i] != '`') {
if (!tmp_i && data[i] == c) tmp_i = i;
i++;
/* counting the number of opening backticks */
while (i < size && data[i] == '`') {
i++; span_nb++;
}
if (i >= size)
return tmp_i;
if (i >= size) return 0;
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 */
else if (data[i] == '[') {