summaryrefslogtreecommitdiff
path: root/format.c
diff options
context:
space:
mode:
authorGravatar default2023-01-12 09:28:02 +0100
committerGravatar default2023-01-12 09:28:02 +0100
commitbb0d8f2a2755af5e11b46d32be84155ba71ea534 (patch)
tree86eb998f66c875dc7d2d40ba3021a3e69ffe9400 /format.c
parentShow the More... link above the 'About this site'. (diff)
downloadsnac2-bb0d8f2a2755af5e11b46d32be84155ba71ea534.tar.gz
snac2-bb0d8f2a2755af5e11b46d32be84155ba71ea534.tar.xz
snac2-bb0d8f2a2755af5e11b46d32be84155ba71ea534.zip
Backport from xs.
Diffstat (limited to 'format.c')
-rw-r--r--format.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/format.c b/format.c
index 7ded83c..58b6c7d 100644
--- a/format.c
+++ b/format.c
@@ -53,19 +53,19 @@ static d_char *format_line(const char *line)
53 if ((n & 0x1)) { 53 if ((n & 0x1)) {
54 /* markup */ 54 /* markup */
55 if (xs_startswith(v, "`")) { 55 if (xs_startswith(v, "`")) {
56 xs *s1 = xs_crop(xs_dup(v), 1, -1); 56 xs *s1 = xs_crop_i(xs_dup(v), 1, -1);
57 xs *s2 = xs_fmt("<code>%s</code>", s1); 57 xs *s2 = xs_fmt("<code>%s</code>", s1);
58 s = xs_str_cat(s, s2); 58 s = xs_str_cat(s, s2);
59 } 59 }
60 else 60 else
61 if (xs_startswith(v, "**")) { 61 if (xs_startswith(v, "**")) {
62 xs *s1 = xs_crop(xs_dup(v), 2, -2); 62 xs *s1 = xs_crop_i(xs_dup(v), 2, -2);
63 xs *s2 = xs_fmt("<b>%s</b>", s1); 63 xs *s2 = xs_fmt("<b>%s</b>", s1);
64 s = xs_str_cat(s, s2); 64 s = xs_str_cat(s, s2);
65 } 65 }
66 else 66 else
67 if (xs_startswith(v, "*")) { 67 if (xs_startswith(v, "*")) {
68 xs *s1 = xs_crop(xs_dup(v), 1, -1); 68 xs *s1 = xs_crop_i(xs_dup(v), 1, -1);
69 xs *s2 = xs_fmt("<i>%s</i>", s1); 69 xs *s2 = xs_fmt("<i>%s</i>", s1);
70 s = xs_str_cat(s, s2); 70 s = xs_str_cat(s, s2);
71 } 71 }
@@ -117,11 +117,11 @@ d_char *not_really_markdown(const char *content)
117 if (in_pre) 117 if (in_pre)
118 ss = xs_dup(v); 118 ss = xs_dup(v);
119 else 119 else
120 ss = xs_strip(format_line(v)); 120 ss = xs_strip_i(format_line(v));
121 121
122 if (xs_startswith(ss, ">")) { 122 if (xs_startswith(ss, ">")) {
123 /* delete the > and subsequent spaces */ 123 /* delete the > and subsequent spaces */
124 ss = xs_strip(xs_crop(ss, 1, 0)); 124 ss = xs_strip_i(xs_crop_i(ss, 1, 0));
125 125
126 if (!in_blq) { 126 if (!in_blq) {
127 s = xs_str_cat(s, "<blockquote>"); 127 s = xs_str_cat(s, "<blockquote>");
@@ -184,9 +184,9 @@ d_char *sanitize(const char *content)
184 184
185 while (xs_list_iter(&p, &v)) { 185 while (xs_list_iter(&p, &v)) {
186 if (n & 0x1) { 186 if (n & 0x1) {
187 xs *s1 = xs_strip(xs_crop(xs_dup(v), v[1] == '/' ? 2 : 1, -1)); 187 xs *s1 = xs_strip_i(xs_crop_i(xs_dup(v), v[1] == '/' ? 2 : 1, -1));
188 xs *l1 = xs_split_n(s1, " ", 1); 188 xs *l1 = xs_split_n(s1, " ", 1);
189 xs *tag = xs_tolower(xs_dup(xs_list_get(l1, 0))); 189 xs *tag = xs_tolower_i(xs_dup(xs_list_get(l1, 0)));
190 xs *s2 = NULL; 190 xs *s2 = NULL;
191 int i; 191 int i;
192 192