summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 9d31881..26dfb8e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -282,17 +282,12 @@ void cmark_strbuf_normalize_whitespace(cmark_strbuf *s) {
bufsize_t r, w;
for (r = 0, w = 0; r < s->size; ++r) {
- switch (s->ptr[r]) {
- case ' ':
- case '\n':
- if (last_char_was_space)
- break;
-
- s->ptr[w++] = ' ';
- last_char_was_space = true;
- break;
-
- default:
+ if (cmark_isspace(s->ptr[r])) {
+ if (!last_char_was_space) {
+ s->ptr[w++] = ' ';
+ last_char_was_space = true;
+ }
+ } else {
s->ptr[w++] = s->ptr[r];
last_char_was_space = false;
}