summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYonle <yonle@lecturify.net>2023-07-23 20:20:15 +0700
committerYonle <yonle@lecturify.net>2023-07-23 20:20:15 +0700
commit7710ca76a04432c2dbd3a3f4c1f8e3f1f145e97f (patch)
tree9eddf3be6a9d964d5eb3db7bd86dfc9e6bf71db1
parent5672fe2cc664680ef3fc1ead9da23576ad9b0f1e (diff)
format.c: Encode all HTML characters when we're in pre element until we are out.
Signed-off-by: Yonle <yonle@lecturify.net>
-rw-r--r--format.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/format.c b/format.c
index 0f5f368..fe71996 100644
--- a/format.c
+++ b/format.c
@@ -56,7 +56,8 @@ static xs_str *format_line(const char *line, xs_list **attach)
/* markup */
if (xs_startswith(v, "`")) {
xs *s1 = xs_crop_i(xs_dup(v), 1, -1);
- xs *s2 = xs_fmt("<code>%s</code>", s1);
+ xs *e1 = encode_html(s1);
+ xs *s2 = xs_fmt("<code>%s</code>", e1);
s = xs_str_cat(s, s2);
}
else
@@ -134,8 +135,15 @@ xs_str *not_really_markdown(const char *content, xs_list **attach)
continue;
}
- if (in_pre)
- ss = xs_dup(v);
+ if (in_pre) {
+ // Encode all HTML characters when we're in pre element until we are out.
+ ss = encode_html(xs_dup(v));
+
+ s = xs_str_cat(s, ss);
+ s = xs_str_cat(s, "<br>");
+ continue;
+ }
+
else
ss = xs_strip_i(format_line(v, attach));