Ignore single space around code span

According to https://spec.commonmark.org/0.29/#code-spans :

> If the resulting string both begins and ends with a space character,
but does not consist entirely of space characters, a single space
character is removed from the front and back. This allows you to include
code that begins or ends with backtick characters, which must be
separated by whitespace from the opening or closing backtick strings.
This commit is contained in:
Karl Bartel 2019-09-29 17:36:35 +02:00 committed by Enno Boland
parent b76e431cc2
commit 1793559632

8
smu.c
View file

@ -506,6 +506,14 @@ dosurround(const char *begin, const char *end, int newblock) {
if(!stop || stop < start || stop >= end) if(!stop || stop < start || stop >= end)
continue; continue;
fputs(surround[i].before, stdout); fputs(surround[i].before, stdout);
/* Single space at start and end are ignored */
if (*start == ' ' && *(stop - 1) == ' ') {
start++;
stop--;
l++;
}
if(surround[i].process) if(surround[i].process)
process(start, stop, 0); process(start, stop, 0);
else else