commit c31a4ae

default  ·  2024-05-05 09:27:24 +0000 UTC
parent ddd2af7
Minor RSS title beautifying.
1 files changed,  +11, -4
M html.c
M html.c
+11, -4
 1@@ -3330,12 +3330,19 @@ xs_str *timeline_to_rss(snac *user, const xs_list *timeline, char *title, char *
 2             continue;
 3 
 4         /* create a title with the first line of the content */
 5-        xs *es_title = xs_replace(content, "<br>", "\n");
 6-        xs *title    = xs_str_new(NULL);
 7+        xs *title = xs_replace(content, "<br>", "\n");
 8+        title = xs_regex_replace_i(title, "<[^>]+>", " ");
 9+        title = xs_regex_replace_i(title, "&[^;]+;", " ");
10         int i;
11 
12-        for (i = 0; es_title[i] && es_title[i] != '\n' && es_title[i] != '&' && i < 50; i++)
13-            title = xs_append_m(title, &es_title[i], 1);
14+        for (i = 0; title[i] && title[i] != '\n' && i < 50; i++);
15+
16+        if (title[i] != '\0') {
17+            title[i] = '\0';
18+            title = xs_str_cat(title, "...");
19+        }
20+
21+        title = xs_strip_i(title);
22 
23         xs_html_add(channel,
24             xs_html_tag("item",