diff options
| author | 2024-12-26 03:55:27 +0100 | |
|---|---|---|
| committer | 2024-12-26 03:55:27 +0100 | |
| commit | 2384a5409bc3a8a6ede4bf33bb1584a6bfae39af (patch) | |
| tree | c6ba32c4ae336091dbb6ad645e8173241622b67e /format.c | |
| parent | Accept 'Audio' as a valid entry type. (diff) | |
| download | penes-snac2-2384a5409bc3a8a6ede4bf33bb1584a6bfae39af.tar.gz penes-snac2-2384a5409bc3a8a6ede4bf33bb1584a6bfae39af.tar.xz penes-snac2-2384a5409bc3a8a6ede4bf33bb1584a6bfae39af.zip | |
Make xmpp and mailto URLs clickable.
Diffstat (limited to 'format.c')
| -rw-r--r-- | format.c | 13 |
1 files changed, 12 insertions, 1 deletions
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "xs_html.h" | 7 | #include "xs_html.h" |
| 8 | #include "xs_json.h" | 8 | #include "xs_json.h" |
| 9 | #include "xs_time.h" | 9 | #include "xs_time.h" |
| 10 | #include "xs_match.h" | ||
| 10 | 11 | ||
| 11 | #include "snac.h" | 12 | #include "snac.h" |
| 12 | 13 | ||
| @@ -93,7 +94,8 @@ static xs_str *format_line(const char *line, xs_list **attach) | |||
| 93 | "\\*\\*?\\*?[^\\*]+\\*?\\*?\\*" "|" | 94 | "\\*\\*?\\*?[^\\*]+\\*?\\*?\\*" "|" |
| 94 | "!\\[[^]]+\\]\\([^\\)]+\\)" "|" | 95 | "!\\[[^]]+\\]\\([^\\)]+\\)" "|" |
| 95 | "\\[[^]]+\\]\\([^\\)]+\\)" "|" | 96 | "\\[[^]]+\\]\\([^\\)]+\\)" "|" |
| 96 | "[a-z]+:/" "/[^[:space:]]+" | 97 | "[a-z]+:/" "/[^[:space:]]+" "|" |
| 98 | "(mailto|xmpp):[^@[:space:]]+@[^[:space:]]+" | ||
| 97 | ")"); | 99 | ")"); |
| 98 | int n = 0; | 100 | int n = 0; |
| 99 | 101 | ||
| @@ -230,6 +232,15 @@ static xs_str *format_line(const char *line, xs_list **attach) | |||
| 230 | } | 232 | } |
| 231 | } | 233 | } |
| 232 | else | 234 | else |
| 235 | if (xs_match(v, "mailto*|xmpp*")) { | ||
| 236 | xs *u = xs_replace_i(xs_replace(v, "#", "#"), "@", "@"); | ||
| 237 | |||
| 238 | xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)"); | ||
| 239 | |||
| 240 | xs *s1 = xs_fmt("<a href=\"%s\" target=\"_blank\">%s</a>", v2, u); | ||
| 241 | s = xs_str_cat(s, s1); | ||
| 242 | } | ||
| 243 | else | ||
| 233 | s = xs_str_cat(s, v); | 244 | s = xs_str_cat(s, v); |
| 234 | } | 245 | } |
| 235 | else | 246 | else |