aboutsummaryrefslogtreecommitdiff
path: root/format.c
diff options
context:
space:
mode:
authorgrunfink <grunfink@noreply.codeberg.org>2025-02-05 09:17:02 +0000
committergrunfink <grunfink@noreply.codeberg.org>2025-02-05 09:17:02 +0000
commit6b4b3317e3ba5fb6570c43a307383b43cd609eb1 (patch)
tree793f15edf1695c4e9a5603b80e6fe647f62e19f2 /format.c
parent1d37e33e405975ce740be89fc02968cc7ec09b0f (diff)
parent52c45718208f076ba1e4a30d7d54655cb4dcc78c (diff)
Merge pull request 'Fix link detection. Fixes: #290' (#296) from inz/snac2:link-detect into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/296
Diffstat (limited to 'format.c')
-rw-r--r--format.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/format.c b/format.c
index e5934b8..4c8ed29 100644
--- a/format.c
+++ b/format.c
@@ -78,6 +78,8 @@ xs_dict *emojis(void)
return d;
}
+/* Non-whitespace without trailing comma, period or closing paren */
+#define NOSPACE "([^[:space:],.)]+|[,.)]+[^[:space:],.)])+"
static xs_str *format_line(const char *line, xs_list **attach)
/* formats a line */
@@ -96,8 +98,8 @@ static xs_str *format_line(const char *line, xs_list **attach)
"__[^_]+__" "|" //anzu
"!\\[[^]]+\\]\\([^\\)]+\\)" "|"
"\\[[^]]+\\]\\([^\\)]+\\)" "|"
- "[a-z]+:/" "/[^[:space:]]+" "|"
- "(mailto|xmpp):[^@[:space:]]+@[^[:space:]]+"
+ "[a-z]+:/" "/" NOSPACE "|"
+ "(mailto|xmpp):[^@[:space:]]+@" NOSPACE
")");
int n = 0;