summaryrefslogtreecommitdiff
path: root/src/inlines.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-04-04 22:05:12 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-04-04 22:05:12 -0700
commit4bb756a98c0982b8b39b4eee8091e1a5f60d7111 (patch)
treef01a5f4d35ff022722ef6102a3e1bc190aca1db1 /src/inlines.c
parentcffc51b19828d67b246cb367da3b8b45270e5a62 (diff)
Update code span normalization...
to conform with spec change.
Diffstat (limited to 'src/inlines.c')
-rw-r--r--src/inlines.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/inlines.c b/src/inlines.c
index 458ab72..e6b491f 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -324,9 +324,11 @@ static bufsize_t scan_to_closing_backticks(subject *subj,
}
// Destructively modify string, converting newlines to
-// spaces, then removing a single leading + trailing space.
+// spaces, then removing a single leading + trailing space,
+// unless the code span consists entirely of space characters.
static void S_normalize_code(cmark_strbuf *s) {
bufsize_t r, w;
+ bool contains_nonspace = false;
for (r = 0, w = 0; r < s->size; ++r) {
switch (s->ptr[r]) {
@@ -341,10 +343,14 @@ static void S_normalize_code(cmark_strbuf *s) {
default:
s->ptr[w++] = s->ptr[r];
}
+ if (s->ptr[r] != ' ') {
+ contains_nonspace = true;
+ }
}
// begins and ends with space?
- if (s->ptr[0] == ' ' && s->ptr[w - 1] == ' ') {
+ if (contains_nonspace &&
+ s->ptr[0] == ' ' && s->ptr[w - 1] == ' ') {
cmark_strbuf_drop(s, 1);
cmark_strbuf_truncate(s, w - 2);
} else {