ext/redcarpet/markdown.c in redcarpet-1.15.0 vs ext/redcarpet/markdown.c in redcarpet-1.15.1
- old
+ new
@@ -146,26 +146,16 @@
{ "ol", 2 },
{ "ul", 2 },
/*10*/ { "del", 3 },
{ "div", 3 },
/*12*/ { "ins", 3 },
- { "nav", 3 },
{ "pre", 3 },
- { "abbr", 4 },
{ "form", 4 },
{ "math", 4 },
- { "aside", 5 },
{ "table", 5 },
- { "canvas", 6 },
- { "figure", 6 },
- { "footer", 6 },
- { "header", 6 },
- { "hgroup", 6 },
{ "iframe", 6 },
{ "script", 6 },
- { "article", 7 },
- { "section", 7 },
{ "fieldset", 8 },
{ "noscript", 8 },
{ "blockquote", 10 }
};
@@ -741,11 +731,11 @@
}
static size_t
autolink_delim(char *data, size_t link_end, size_t offset, size_t size)
{
- char copen = 0;
+ char cclose, copen = 0;
/* See if the link finishes with a punctuation sign that can be skipped. */
switch (data[link_end - 1]) {
case '?':
case '!':
@@ -777,22 +767,24 @@
return 0;
break;
}
- switch (data[link_end - 1]) {
+ cclose = data[link_end - 1];
+
+ switch (cclose) {
case '"': copen = '"'; break;
case '\'': copen = '\''; break;
case ')': copen = '('; break;
case ']': copen = '['; break;
case '}': copen = '{'; break;
}
if (copen != 0) {
- char *buf_start = data - offset;
- char *buf_end = data + link_end - 2;
- char *open_delim = NULL;
+ size_t closing = 0;
+ size_t opening = 0;
+ size_t i = 0;
/* Try to close the final punctuation sign in this same line;
* if we managed to close it outside of the URL, that means that it's
* not part of the URL. If it closes inside the URL, that means it
* is part of the URL.
@@ -810,18 +802,20 @@
*
* (foo http://www.pokemon.com/Pikachu_(Electric)) bar
* => foo http://www.pokemon.com/Pikachu_(Electric)
*/
- while (buf_end >= buf_start && *buf_end != '\n') {
- if (*buf_end == copen)
- open_delim = buf_end;
+ while (i < link_end) {
+ if (data[i] == copen)
+ opening++;
+ else if (data[i] == cclose)
+ closing++;
- buf_end--;
+ i++;
}
- if (open_delim != NULL && open_delim < data)
+ if (closing != opening)
link_end--;
}
return link_end;
}
@@ -923,10 +917,10 @@
unscape_text(u_link, &work);
ob->size -= rewind;
rndr->make.autolink(ob, u_link, MKDA_EMAIL, rndr->make.opaque);
rndr_popbuf(rndr, BUFFER_SPAN);
- }
+ }
return link_end;
}
static size_t