summaryrefslogtreecommitdiff
path: root/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'format.c')
-rw-r--r--format.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/format.c b/format.c
index 92901bb..b021f55 100644
--- a/format.c
+++ b/format.c
@@ -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 {