diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-08-08 23:31:54 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-08-08 23:33:01 -0700 |
commit | f2ac8b6aa69a4765e44f815a031b7aa574d44b57 (patch) | |
tree | d9cfdd4a4f1ebcbba87bf745234e37081960035f /src | |
parent | a4f61e832fa9f99e04d05ab4b4768538ba076c84 (diff) |
Improved cmark_strbuf_normalize_whitespace.
Now all characters that satisfy cmark_isspace are
recognized as whitespace. Previously CR and TAB
(and others) weren't included.
Partially addresses #73.
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer.c | 17 |
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; } |