summaryrefslogtreecommitdiff
path: root/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'format.c')
-rw-r--r--format.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/format.c b/format.c
index b2b585d..2f30a0d 100644
--- a/format.c
+++ b/format.c
@@ -154,8 +154,10 @@ static xs_str *format_line(const char *line, xs_list **attach)
154 xs *l = xs_split_n(w, "](", 1); 154 xs *l = xs_split_n(w, "](", 1);
155 155
156 if (xs_list_len(l) == 2) { 156 if (xs_list_len(l) == 2) {
157 xs *link = xs_fmt("<a href=\"%s\">%s</a>", 157 const char *name = xs_list_get(l, 0);
158 xs_list_get(l, 1), xs_list_get(l, 0)); 158 const char *url = xs_list_get(l, 1);
159
160 xs *link = xs_fmt("<a href=\"%s\">%s</a>", url, name);
159 161
160 s = xs_str_cat(s, link); 162 s = xs_str_cat(s, link);
161 } 163 }
@@ -208,6 +210,7 @@ static xs_str *format_line(const char *line, xs_list **attach)
208 } 210 }
209 else 211 else
210 if (xs_str_in(v, ":/" "/") != -1) { 212 if (xs_str_in(v, ":/" "/") != -1) {
213 /* direct URLs in the post body */
211 xs *u = xs_replace_i(xs_replace(v, "#", "&#35;"), "@", "&#64;"); 214 xs *u = xs_replace_i(xs_replace(v, "#", "&#35;"), "@", "&#64;");
212 215
213 xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)"); 216 xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)");
@@ -382,10 +385,11 @@ xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag
382 const char *k, *v; 385 const char *k, *v;
383 386
384 while (xs_dict_next(d, &k, &v, &c)) { 387 while (xs_dict_next(d, &k, &v, &c)) {
385 const char *t = NULL; 388 const char *t = xs_mime_by_ext(v);
386 389
387 /* is it an URL to an image? */ 390 /* is it an URL to an image? */
388 if (xs_startswith(v, "https:/" "/") && xs_startswith((t = xs_mime_by_ext(v)), "image/")) { 391 if (xs_startswith(v, "https:/" "/") &&
392 (xs_startswith(t, "image/") || strcmp(t, "application/octet-stream") == 0)) {
389 if (tag && xs_str_in(s, k) != -1) { 393 if (tag && xs_str_in(s, k) != -1) {
390 /* add the emoji to the tag list */ 394 /* add the emoji to the tag list */
391 xs *e = xs_dict_new(); 395 xs *e = xs_dict_new();