diff --git a/cmarkdown.c b/cmarkdown.c
index e134cac..ae71bf0 100644
--- a/cmarkdown.c
+++ b/cmarkdown.c
@@ -142,35 +142,37 @@ dolineprefix(const char *begin, const char *end) {
unsigned int
dolink(const char *begin, const char *end) {
int img;
- const char *desc, *link, *p;
- unsigned int desclen, linklen;
+ const char *desc, *link, *p, *q, *r, *descend, *linkend;
- if(*begin != '[' && strncmp(begin,") || p > end)
return 0;
- desclen = p - desc;
+ for(q = strstr(desc, ") || p > end)
+ return 0;
+ descend = p;
link = p + 2;
if(!(p = strstr(link, ")")) || p > end)
return 0;
- linklen = p - link;
-
+ linkend = p;
if(img) {
fputs("
",stdout);
}
else {
fputs("",stdout);
- process(desc,desc+desclen);
+ process(desc,descend);
fputs("",stdout);
}
return p + 1 - begin;