commit 5672fe2
Yonle
·
2023-07-23 07:55:06 +0000 UTC
parent 11aafbc
format.c: Allow several tags Signed-off-by: Yonle <yonle@lecturify.net>
1 files changed,
+13,
-3
M
format.c
M
format.c
+13,
-3
1@@ -139,6 +139,16 @@ xs_str *not_really_markdown(const char *content, xs_list **attach)
2 else
3 ss = xs_strip_i(format_line(v, attach));
4
5+ if (xs_startswith(ss, "---")) {
6+ /* delete the --- */
7+ ss = xs_strip_i(xs_crop_i(ss, 3, 0));
8+ s = xs_str_cat(s, "<hr>");
9+
10+ s = xs_str_cat(s, ss);
11+
12+ continue;
13+ }
14+
15 if (xs_startswith(ss, ">")) {
16 /* delete the > and subsequent spaces */
17 ss = xs_strip_i(xs_crop_i(ss, 1, 0));
18@@ -186,8 +196,8 @@ xs_str *not_really_markdown(const char *content, xs_list **attach)
19
20
21 const char *valid_tags[] = {
22- "a", "p", "br", "br/", "blockquote", "ul", "ol", "li", "cite",
23- "span", "i", "b", "u", "pre", "code", "em", "strong", NULL
24+ "a", "p", "br", "br/", "blockquote", "ul", "ol", "li", "cite", "small",
25+ "span", "i", "b", "u", "pre", "code", "em", "strong", "hr", "img", "del", NULL
26 };
27
28 xs_str *sanitize(const char *content)
29@@ -219,7 +229,7 @@ xs_str *sanitize(const char *content)
30
31 if (valid_tags[i]) {
32 /* accepted tag: rebuild it with only the accepted elements */
33- xs *el = xs_regex_match(v, "(href|rel|class|target)=\"[^\"]*\"");
34+ xs *el = xs_regex_match(v, "(src|href|rel|class|target)=\"[^\"]*\"");
35 xs *s3 = xs_join(el, " ");
36
37 s2 = xs_fmt("<%s%s%s%s>",