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; 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] == '[') {