diff --git a/src/inlines.c b/src/inlines.c index bf765eab5..abaeb96e1 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -342,8 +342,10 @@ static bufsize_t scan_to_closing_backticks(subject *subj, advance(subj); numticks++; } - // store position of ender - if (numticks <= MAXBACKTICKS) { + // store position of ender (keep the last one: a scan that resumes after + // an earlier full scan must not replace a later position) + if (numticks <= MAXBACKTICKS && + subj->backticks[numticks] < subj->pos - numticks) { subj->backticks[numticks] = subj->pos - numticks; } if (numticks == openticklength) { diff --git a/test/regression.txt b/test/regression.txt index 1426617ab..6456ccbf8 100644 --- a/test/regression.txt +++ b/test/regression.txt @@ -257,6 +257,19 @@ x <- 1 ```````````````````````````````` +Code spans after an unmatched backtick string of a different length. +The failed scan for the closer of ``` `` ``` must not hide the second +single-backtick span. +```````````````````````````````` example +``x +`i` +`j` +. +
``x
+i
+j