mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-28 10:03:36 +00:00
Make xmpp and mailto URLs clickable.
This commit is contained in:
parent
ea0c128cf0
commit
2384a5409b
2 changed files with 13 additions and 2 deletions
13
format.c
13
format.c
|
@ -7,6 +7,7 @@
|
|||
#include "xs_html.h"
|
||||
#include "xs_json.h"
|
||||
#include "xs_time.h"
|
||||
#include "xs_match.h"
|
||||
|
||||
#include "snac.h"
|
||||
|
||||
|
@ -93,7 +94,8 @@ static xs_str *format_line(const char *line, xs_list **attach)
|
|||
"\\*\\*?\\*?[^\\*]+\\*?\\*?\\*" "|"
|
||||
"!\\[[^]]+\\]\\([^\\)]+\\)" "|"
|
||||
"\\[[^]]+\\]\\([^\\)]+\\)" "|"
|
||||
"[a-z]+:/" "/[^[:space:]]+"
|
||||
"[a-z]+:/" "/[^[:space:]]+" "|"
|
||||
"(mailto|xmpp):[^@[:space:]]+@[^[:space:]]+"
|
||||
")");
|
||||
int n = 0;
|
||||
|
||||
|
@ -229,6 +231,15 @@ static xs_str *format_line(const char *line, xs_list **attach)
|
|||
s = xs_str_cat(s, s1);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (xs_match(v, "mailto*|xmpp*")) {
|
||||
xs *u = xs_replace_i(xs_replace(v, "#", "#"), "@", "@");
|
||||
|
||||
xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)");
|
||||
|
||||
xs *s1 = xs_fmt("<a href=\"%s\" target=\"_blank\">%s</a>", v2, u);
|
||||
s = xs_str_cat(s, s1);
|
||||
}
|
||||
else
|
||||
s = xs_str_cat(s, v);
|
||||
}
|
||||
|
|
2
html.c
2
html.c
|
@ -934,7 +934,7 @@ static xs_html *html_user_body(snac *user, int read_only)
|
|||
}
|
||||
}
|
||||
else
|
||||
if (xs_startswith(v, "gemini:/")) {
|
||||
if (xs_startswith(v, "gemini:/") || xs_startswith(v, "xmpp:")) {
|
||||
value = xs_html_tag("a",
|
||||
xs_html_attr("rel", "me"),
|
||||
xs_html_attr("href", v),
|
||||
|
|
Loading…
Reference in a new issue