From 9a9b9e346027fbeb6463b76d6b7b26e3b3589eaf Mon Sep 17 00:00:00 2001 From: "gottox@rootkit.lan" Date: Tue, 11 Dec 2007 11:55:47 +0100 Subject: [PATCH] replaced desclen and linklen by descend and linkend images are now stackable into links. --- cmarkdown.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) 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,"![",2) != 0) - return 0; - img = 1; if(*begin == '[') img = 0; - desc = begin + 1 + img; + else if(strncmp(begin,"![",2) == 0) + img = 1; + else + return 0; + p = desc = begin + 1 + img; if(!(p = strstr(desc, "](")) || p > end) return 0; - desclen = p - desc; + for(q = strstr(desc, "!["); q && q < end && q < p; q = strstr(q+1,"![")) + if(!(p = strstr(p+1, "](")) || 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);",stdout); } else { fputs("",stdout); - process(desc,desc+desclen); + process(desc,descend); fputs("",stdout); } return p + 1 - begin;