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,
324324}
325325
326326// 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.
328329static void S_normalize_code (cmark_strbuf * s ) {
329330 bufsize_t r , w ;
331+ bool contains_nonspace = false;
330332
331333 for (r = 0 , w = 0 ; r < s -> size ; ++ r ) {
332334 switch (s -> ptr [r ]) {
@@ -341,10 +343,14 @@ static void S_normalize_code(cmark_strbuf *s) {
341343 default :
342344 s -> ptr [w ++ ] = s -> ptr [r ];
343345 }
346+ if (s -> ptr [r ] != ' ' ) {
347+ contains_nonspace = true;
348+ }
344349 }
345350
346351 // 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 ] == ' ' ) {
348354 cmark_strbuf_drop (s , 1 );
349355 cmark_strbuf_truncate (s , w - 2 );
350356 } else {
You can’t perform that action at this time.
0 commit comments