summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/inlines.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/inlines.c b/src/inlines.c
index 0dc7864..bbda78f 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -324,27 +324,22 @@ static bufsize_t scan_to_closing_backticks(subject *subj,
}
// Destructively modify string, converting newlines to
-// spaces or removing them if they're adjacent to spaces,
-// then removing a single leading + trailing space.
+// spaces, then removing a single leading + trailing space.
static void S_normalize_code(cmark_strbuf *s) {
- bool last_char_was_space = false;
bufsize_t r, w;
for (r = 0, w = 0; r < s->size; ++r) {
switch (s->ptr[r]) {
case '\r':
+ if (s->ptr[r + 1] != '\n') {
+ s->ptr[w++] = ' ';
+ }
break;
case '\n':
- if (!last_char_was_space && !cmark_isspace(s->ptr[r + 1])) {
- s->ptr[w++] = ' ';
- last_char_was_space = true;
- } else {
- last_char_was_space = false;
- }
+ s->ptr[w++] = ' ';
break;
default:
s->ptr[w++] = s->ptr[r];
- last_char_was_space = (s->ptr[r] == ' ');
}
}