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,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 */