summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-08-26 10:50:54 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-08-26 10:50:54 -0700
commit14ae4f33c47b015ff41a2b4d88b215841ce5eb57 (patch)
treec880e55605989097e20bbe65aeef7beb9e4cf94b /src
parent15a76ded8fe35cf2a8f30720ffdf6abf9e7ecc41 (diff)
Simplify code normalization, in line with spec change.
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] == ' ');
}
}