diff options
author | Louis Brauer <louis77@noreply.codeberg.org> | 2024-05-25 08:05:36 +0000 |
---|---|---|
committer | Louis Brauer <louis77@noreply.codeberg.org> | 2024-05-25 08:05:36 +0000 |
commit | 84a767dd0878013194ed7551b5ae6ef715e841a6 (patch) | |
tree | 9fb1b2b89e0bfbb4b8bf1e85d840c8653e646bb7 /format.c | |
parent | cf5718bf4dedb85d2e1a1495f05bfc7e66124022 (diff) | |
parent | a2920800007c291bdf2b5264622cbc713d4961ee (diff) |
Merge pull request 'master' (#1) from grunfink/snac2:master into master
Reviewed-on: https://codeberg.org/louis77/snac2/pulls/1
Diffstat (limited to 'format.c')
-rw-r--r-- | format.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -82,7 +82,8 @@ static xs_str *format_line(const char *line, xs_list **attach) /* formats a line */ { xs_str *s = xs_str_new(NULL); - char *p, *v; + char *p; + const char *v; /* split by markup */ xs *sm = xs_regex_split(line, @@ -155,7 +156,8 @@ xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag int in_pre = 0; int in_blq = 0; xs *list; - char *p, *v; + char *p; + const char *v; /* work by lines */ list = xs_split(content, "\n"); @@ -234,14 +236,14 @@ xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag /* traditional emoticons */ xs *d = emojis(); int c = 0; - char *k, *v; + const char *k, *v; while (xs_dict_next(d, &k, &v, &c)) { const char *t = NULL; /* is it an URL to an image? */ if (xs_startswith(v, "https:/" "/") && xs_startswith((t = xs_mime_by_ext(v)), "image/")) { - if (tag) { + if (tag && xs_str_in(s, k) != -1) { /* add the emoji to the tag list */ xs *e = xs_dict_new(); xs *i = xs_dict_new(); @@ -280,7 +282,8 @@ xs_str *sanitize(const char *content) xs_str *s = xs_str_new(NULL); xs *sl; int n = 0; - char *p, *v; + char *p; + const char *v; sl = xs_regex_split(content, "</?[^>]+>"); @@ -311,9 +314,9 @@ xs_str *sanitize(const char *content) s = xs_str_cat(s, s2); } else { - /* else? just show it with encoded code.. that's it. */ - xs *el = encode_html(v); - s = xs_str_cat(s, el); + /* treat end of divs as paragraph breaks */ + if (strcmp(v, "</div>")) + s = xs_str_cat(s, "<p>"); } } else { |