From c31a4ae73e9759cebda2a9cf8a34b352dc246314 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 5 May 2024 11:27:24 +0200 Subject: Minor RSS title beautifying. --- html.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index fe070c1..ee5c2cd 100644 --- a/html.c +++ b/html.c @@ -3330,12 +3330,19 @@ xs_str *timeline_to_rss(snac *user, const xs_list *timeline, char *title, char * continue; /* create a title with the first line of the content */ - xs *es_title = xs_replace(content, "
", "\n"); - xs *title = xs_str_new(NULL); + xs *title = xs_replace(content, "
", "\n"); + title = xs_regex_replace_i(title, "<[^>]+>", " "); + title = xs_regex_replace_i(title, "&[^;]+;", " "); int i; - for (i = 0; es_title[i] && es_title[i] != '\n' && es_title[i] != '&' && i < 50; i++) - title = xs_append_m(title, &es_title[i], 1); + for (i = 0; title[i] && title[i] != '\n' && i < 50; i++); + + if (title[i] != '\0') { + title[i] = '\0'; + title = xs_str_cat(title, "..."); + } + + title = xs_strip_i(title); xs_html_add(channel, xs_html_tag("item", -- cgit v1.2.3