From 5672fe2cc664680ef3fc1ead9da23576ad9b0f1e Mon Sep 17 00:00:00 2001 From: Yonle Date: Sun, 23 Jul 2023 14:55:06 +0700 Subject: [PATCH] format.c: Allow several tags Signed-off-by: Yonle --- format.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/format.c b/format.c index 8c6c02a..0f5f368 100644 --- a/format.c +++ b/format.c @@ -139,6 +139,16 @@ xs_str *not_really_markdown(const char *content, xs_list **attach) else ss = xs_strip_i(format_line(v, attach)); + if (xs_startswith(ss, "---")) { + /* delete the --- */ + ss = xs_strip_i(xs_crop_i(ss, 3, 0)); + s = xs_str_cat(s, "
"); + + s = xs_str_cat(s, ss); + + continue; + } + if (xs_startswith(ss, ">")) { /* delete the > and subsequent spaces */ ss = xs_strip_i(xs_crop_i(ss, 1, 0)); @@ -186,8 +196,8 @@ xs_str *not_really_markdown(const char *content, xs_list **attach) const char *valid_tags[] = { - "a", "p", "br", "br/", "blockquote", "ul", "ol", "li", "cite", - "span", "i", "b", "u", "pre", "code", "em", "strong", NULL + "a", "p", "br", "br/", "blockquote", "ul", "ol", "li", "cite", "small", + "span", "i", "b", "u", "pre", "code", "em", "strong", "hr", "img", "del", NULL }; xs_str *sanitize(const char *content) @@ -219,7 +229,7 @@ xs_str *sanitize(const char *content) if (valid_tags[i]) { /* accepted tag: rebuild it with only the accepted elements */ - xs *el = xs_regex_match(v, "(href|rel|class|target)=\"[^\"]*\""); + xs *el = xs_regex_match(v, "(src|href|rel|class|target)=\"[^\"]*\""); xs *s3 = xs_join(el, " "); s2 = xs_fmt("<%s%s%s%s>",