diff options
Diffstat (limited to 'format.c')
| -rw-r--r-- | format.c | 9 |
1 files changed, 6 insertions, 3 deletions
| @@ -44,9 +44,12 @@ d_char *not_really_markdown(char *content, d_char **f_content) | |||
| 44 | char *p, *v; | 44 | char *p, *v; |
| 45 | xs *wrk = xs_str_new(NULL); | 45 | xs *wrk = xs_str_new(NULL); |
| 46 | 46 | ||
| 47 | /* some preparation to avoid writing very kludgy code */ | ||
| 48 | xs *p_content = xs_replace(content, "```", "@pre@"); | ||
| 49 | |||
| 47 | { | 50 | { |
| 48 | /* split by special markup */ | 51 | /* split by special markup */ |
| 49 | xs *sm = xs_regex_split(content, | 52 | xs *sm = xs_regex_split(p_content, |
| 50 | "(`[^`]+`|\\*\\*?[^\\*]+\\*?\\*|https?:/" "/[^[:space:]]+)"); | 53 | "(`[^`]+`|\\*\\*?[^\\*]+\\*?\\*|https?:/" "/[^[:space:]]+)"); |
| 51 | int n = 0; | 54 | int n = 0; |
| 52 | 55 | ||
| @@ -54,7 +57,7 @@ d_char *not_really_markdown(char *content, d_char **f_content) | |||
| 54 | while (xs_list_iter(&p, &v)) { | 57 | while (xs_list_iter(&p, &v)) { |
| 55 | if ((n & 0x1)) { | 58 | if ((n & 0x1)) { |
| 56 | /* markup */ | 59 | /* markup */ |
| 57 | if (xs_startswith(v, "`") && v[1] != '\n') { | 60 | if (xs_startswith(v, "`")) { |
| 58 | xs *s1 = xs_crop(xs_dup(v), 1, -1); | 61 | xs *s1 = xs_crop(xs_dup(v), 1, -1); |
| 59 | xs *s2 = xs_fmt("<code>%s</code>", s1); | 62 | xs *s2 = xs_fmt("<code>%s</code>", s1); |
| 60 | wrk = xs_str_cat(wrk, s2); | 63 | wrk = xs_str_cat(wrk, s2); |
| @@ -95,7 +98,7 @@ d_char *not_really_markdown(char *content, d_char **f_content) | |||
| 95 | while (xs_list_iter(&p, &v)) { | 98 | while (xs_list_iter(&p, &v)) { |
| 96 | xs *ss = xs_strip(xs_dup(v)); | 99 | xs *ss = xs_strip(xs_dup(v)); |
| 97 | 100 | ||
| 98 | if (xs_startswith(ss, "```")) { | 101 | if (xs_startswith(ss, "@pre@")) { |
| 99 | if (!in_pre) | 102 | if (!in_pre) |
| 100 | s = xs_str_cat(s, "<pre>"); | 103 | s = xs_str_cat(s, "<pre>"); |
| 101 | else | 104 | else |