commit 7710ca7
Yonle
·
2023-07-23 13:20:15 +0000 UTC
parent 5672fe2
format.c: Encode all HTML characters when we're in pre element until we are out. Signed-off-by: Yonle <yonle@lecturify.net>
1 files changed,
+11,
-3
M
format.c
M
format.c
+11,
-3
1@@ -56,7 +56,8 @@ static xs_str *format_line(const char *line, xs_list **attach)
2 /* markup */
3 if (xs_startswith(v, "`")) {
4 xs *s1 = xs_crop_i(xs_dup(v), 1, -1);
5- xs *s2 = xs_fmt("<code>%s</code>", s1);
6+ xs *e1 = encode_html(s1);
7+ xs *s2 = xs_fmt("<code>%s</code>", e1);
8 s = xs_str_cat(s, s2);
9 }
10 else
11@@ -134,8 +135,15 @@ xs_str *not_really_markdown(const char *content, xs_list **attach)
12 continue;
13 }
14
15- if (in_pre)
16- ss = xs_dup(v);
17+ if (in_pre) {
18+ // Encode all HTML characters when we're in pre element until we are out.
19+ ss = encode_html(xs_dup(v));
20+
21+ s = xs_str_cat(s, ss);
22+ s = xs_str_cat(s, "<br>");
23+ continue;
24+ }
25+
26 else
27 ss = xs_strip_i(format_line(v, attach));
28