snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit 5672fe2cc664680ef3fc1ead9da23576ad9b0f1e
parent 11aafbc46f37b7c299a03a421a646cbcab8d5b79
Author: Yonle <yonle@lecturify.net>
Date:   Sun, 23 Jul 2023 14:55:06 +0700

format.c: Allow several tags

Signed-off-by: Yonle <yonle@lecturify.net>

Diffstat:
Mformat.c | 16+++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git 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, "<hr>"); + + 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>",