diff options
| author | 2025-05-21 21:11:47 +0200 | |
|---|---|---|
| committer | 2025-05-21 21:11:47 +0200 | |
| commit | 979718e3cc5489efdce2acc6f8c86f6d00bb91c7 (patch) | |
| tree | 7b4936bdb5ea07c7dd617d508c487d70020f0146 /format.c | |
| parent | po/de_DE.po aktualisiert (diff) | |
| parent | Merge pull request 'make greetings theme adaptive; define style in header' (#... (diff) | |
| download | snac2-979718e3cc5489efdce2acc6f8c86f6d00bb91c7.tar.gz snac2-979718e3cc5489efdce2acc6f8c86f6d00bb91c7.tar.xz snac2-979718e3cc5489efdce2acc6f8c86f6d00bb91c7.zip | |
Merge pull request 'master refresh' (#8) from grunfink/snac2:master into master
Reviewed-on: https://codeberg.org/zen/snac2/pulls/8
Diffstat (limited to 'format.c')
| -rw-r--r-- | format.c | 12 |
1 files changed, 8 insertions, 4 deletions
| @@ -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, "#", "#"), "@", "@"); | 214 | xs *u = xs_replace_i(xs_replace(v, "#", "#"), "@", "@"); |
| 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(); |