diff options
| author | 2023-07-23 14:55:06 +0700 | |
|---|---|---|
| committer | 2023-07-23 14:55:06 +0700 | |
| commit | 5672fe2cc664680ef3fc1ead9da23576ad9b0f1e (patch) | |
| tree | 2893ca8baef4615057346b8f1a21b8b0b1a02ff9 /format.c | |
| parent | default css: Set max width for video attachment (diff) | |
| download | penes-snac2-5672fe2cc664680ef3fc1ead9da23576ad9b0f1e.tar.gz penes-snac2-5672fe2cc664680ef3fc1ead9da23576ad9b0f1e.tar.xz penes-snac2-5672fe2cc664680ef3fc1ead9da23576ad9b0f1e.zip | |
format.c: Allow several tags
Signed-off-by: Yonle <yonle@lecturify.net>
Diffstat (limited to '')
| -rw-r--r-- | format.c | 16 |
1 files changed, 13 insertions, 3 deletions
| @@ -139,6 +139,16 @@ xs_str *not_really_markdown(const char *content, xs_list **attach) | |||
| 139 | else | 139 | else |
| 140 | ss = xs_strip_i(format_line(v, attach)); | 140 | ss = xs_strip_i(format_line(v, attach)); |
| 141 | 141 | ||
| 142 | if (xs_startswith(ss, "---")) { | ||
| 143 | /* delete the --- */ | ||
| 144 | ss = xs_strip_i(xs_crop_i(ss, 3, 0)); | ||
| 145 | s = xs_str_cat(s, "<hr>"); | ||
| 146 | |||
| 147 | s = xs_str_cat(s, ss); | ||
| 148 | |||
| 149 | continue; | ||
| 150 | } | ||
| 151 | |||
| 142 | if (xs_startswith(ss, ">")) { | 152 | if (xs_startswith(ss, ">")) { |
| 143 | /* delete the > and subsequent spaces */ | 153 | /* delete the > and subsequent spaces */ |
| 144 | ss = xs_strip_i(xs_crop_i(ss, 1, 0)); | 154 | 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) | |||
| 186 | 196 | ||
| 187 | 197 | ||
| 188 | const char *valid_tags[] = { | 198 | const char *valid_tags[] = { |
| 189 | "a", "p", "br", "br/", "blockquote", "ul", "ol", "li", "cite", | 199 | "a", "p", "br", "br/", "blockquote", "ul", "ol", "li", "cite", "small", |
| 190 | "span", "i", "b", "u", "pre", "code", "em", "strong", NULL | 200 | "span", "i", "b", "u", "pre", "code", "em", "strong", "hr", "img", "del", NULL |
| 191 | }; | 201 | }; |
| 192 | 202 | ||
| 193 | xs_str *sanitize(const char *content) | 203 | xs_str *sanitize(const char *content) |
| @@ -219,7 +229,7 @@ xs_str *sanitize(const char *content) | |||
| 219 | 229 | ||
| 220 | if (valid_tags[i]) { | 230 | if (valid_tags[i]) { |
| 221 | /* accepted tag: rebuild it with only the accepted elements */ | 231 | /* accepted tag: rebuild it with only the accepted elements */ |
| 222 | xs *el = xs_regex_match(v, "(href|rel|class|target)=\"[^\"]*\""); | 232 | xs *el = xs_regex_match(v, "(src|href|rel|class|target)=\"[^\"]*\""); |
| 223 | xs *s3 = xs_join(el, " "); | 233 | xs *s3 = xs_join(el, " "); |
| 224 | 234 | ||
| 225 | s2 = xs_fmt("<%s%s%s%s>", | 235 | s2 = xs_fmt("<%s%s%s%s>", |