From 218c34b11da536a2f607a59d5b5de586bc9a51ab Mon Sep 17 00:00:00 2001 From: yuxi-liu-wired <33951560+yuxi-liu-wired@users.noreply.github.com> Date: Sun, 4 Oct 2026 21:43:35 +0000 Subject: [PATCH] Skip the leading spaces of a lazy continuation line A paragraph line's leading spaces and tabs are not part of the paragraph's raw content (spec 4.8), and cmark skips them for a normal continuation line. A lazy continuation line was added from the current offset instead, so its leading space stayed in the content. That shows in a code span, where the line ending becomes a space: > `a b` rendered `a b` (two spaces); commonmark.js gives `a b`. The same in a list item (`- \`c\n d\``). Advance past the leading whitespace before adding the lazy line, as the non-lazy paragraph path does. --- src/blocks.c | 3 +++ test/regression.txt | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/blocks.c b/src/blocks.c index 8ff339ee4..b0db722cd 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -1196,6 +1196,9 @@ static void add_text_to_container(cmark_parser *parser, cmark_node *container, if (parser->current != last_matched_container && container == last_matched_container && !parser->blank && S_type(parser->current) == CMARK_NODE_PARAGRAPH) { + // Like any paragraph line, skip the leading spaces and tabs. + S_advance_offset(parser, input, parser->first_nonspace - parser->offset, + false); add_line(input, parser); } else { // not a lazy continuation // Finalize any blocks that were not matched and set cur to container: diff --git a/test/regression.txt b/test/regression.txt index 1426617ab..454be0cb8 100644 --- a/test/regression.txt +++ b/test/regression.txt @@ -108,6 +108,24 @@ City:

```````````````````````````````` +The leading spaces of a lazy continuation line are not part of the +paragraph content, as for any other paragraph line. + +```````````````````````````````` example +> `a + b` + +- `c + d` +. +
+

a b

+
+ +```````````````````````````````` + Issue #530 - link parsing corner cases ```````````````````````````````` example