From 1793559632596f3c8e587553f1d7c87036437fb7 Mon Sep 17 00:00:00 2001 From: Karl Bartel Date: Sun, 29 Sep 2019 17:36:35 +0200 Subject: [PATCH] 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. --- smu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/smu.c b/smu.c index da9b652..01ef239 100644 --- a/smu.c +++ b/smu.c @@ -506,6 +506,14 @@ dosurround(const char *begin, const char *end, int newblock) { if(!stop || stop < start || stop >= end) continue; fputs(surround[i].before, stdout); + + /* Single space at start and end are ignored */ + if (*start == ' ' && *(stop - 1) == ' ') { + start++; + stop--; + l++; + } + if(surround[i].process) process(start, stop, 0); else