mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-12 21:10:22 +03:00
format.c: Allow several tags
Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
parent
11aafbc46f
commit
5672fe2cc6
16
format.c
16
format.c
@ -139,6 +139,16 @@ xs_str *not_really_markdown(const char *content, xs_list **attach)
|
|||||||
else
|
else
|
||||||
ss = xs_strip_i(format_line(v, attach));
|
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, ">")) {
|
if (xs_startswith(ss, ">")) {
|
||||||
/* delete the > and subsequent spaces */
|
/* delete the > and subsequent spaces */
|
||||||
ss = xs_strip_i(xs_crop_i(ss, 1, 0));
|
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[] = {
|
const char *valid_tags[] = {
|
||||||
"a", "p", "br", "br/", "blockquote", "ul", "ol", "li", "cite",
|
"a", "p", "br", "br/", "blockquote", "ul", "ol", "li", "cite", "small",
|
||||||
"span", "i", "b", "u", "pre", "code", "em", "strong", NULL
|
"span", "i", "b", "u", "pre", "code", "em", "strong", "hr", "img", "del", NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
xs_str *sanitize(const char *content)
|
xs_str *sanitize(const char *content)
|
||||||
@ -219,7 +229,7 @@ xs_str *sanitize(const char *content)
|
|||||||
|
|
||||||
if (valid_tags[i]) {
|
if (valid_tags[i]) {
|
||||||
/* accepted tag: rebuild it with only the accepted elements */
|
/* 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, " ");
|
xs *s3 = xs_join(el, " ");
|
||||||
|
|
||||||
s2 = xs_fmt("<%s%s%s%s>",
|
s2 = xs_fmt("<%s%s%s%s>",
|
||||||
|
Loading…
Reference in New Issue
Block a user