File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -324,9 +324,11 @@ static bufsize_t scan_to_closing_backticks(subject *subj,
324
324
}
325
325
326
326
// Destructively modify string, converting newlines to
327
- // spaces, then removing a single leading + trailing space.
327
+ // spaces, then removing a single leading + trailing space,
328
+ // unless the code span consists entirely of space characters.
328
329
static void S_normalize_code (cmark_strbuf * s ) {
329
330
bufsize_t r , w ;
331
+ bool contains_nonspace = false;
330
332
331
333
for (r = 0 , w = 0 ; r < s -> size ; ++ r ) {
332
334
switch (s -> ptr [r ]) {
@@ -341,10 +343,14 @@ static void S_normalize_code(cmark_strbuf *s) {
341
343
default :
342
344
s -> ptr [w ++ ] = s -> ptr [r ];
343
345
}
346
+ if (s -> ptr [r ] != ' ' ) {
347
+ contains_nonspace = true;
348
+ }
344
349
}
345
350
346
351
// begins and ends with space?
347
- if (s -> ptr [0 ] == ' ' && s -> ptr [w - 1 ] == ' ' ) {
352
+ if (contains_nonspace &&
353
+ s -> ptr [0 ] == ' ' && s -> ptr [w - 1 ] == ' ' ) {
348
354
cmark_strbuf_drop (s , 1 );
349
355
cmark_strbuf_truncate (s , w - 2 );
350
356
} else {
You can’t perform that action at this time.
0 commit comments