Skip to content

Keep blanks after [ in link text - #165

Merged
bobzhang merged 1 commit into
mainfrom
conformance/link-text-leading-blanks
Oct 2, 2026
Merged

bobzhang merged 1 commit into
mainfrom
conformance/link-text-leading-blanks

Conversation

@bobzhang

@bobzhang bobzhang commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Split out of #152. Found by differential fuzzing against markdown-it-py (commonmark preset).

Bug: the last inline pass strips the leading blanks of each line of a paragraph. For link text it also stripped the blanks after the opening [, which are not at the start of a line.

Repro: [ foo](/u) gave <a href="/u">foo</a>. Expected <a href="/u"> foo</a>. Same for image alt text (![ baz](/i)).

Fix: last_pass and parse_tokens take an optional strip_first (default true). try_link passes strip_first=false for the link text. Blanks that start the following lines are still stripped.

Spec examples: none (the spec suite passes either way).

Tests: src/cmark_html/link_text_leading_blanks_test.mbt.

Depends on: nothing, independent of the other PRs.

The last pass strips the leading blanks of each line of a paragraph.
For link text it also stripped the blanks after the opening [, which
are not at the start of a line: `[ foo](/u)` gave <a href="/u">foo</a>
instead of <a href="/u"> foo</a>.
@bobzhang

bobzhang commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Automated review: Codex CLI (codex exec, model reasoning effort high, read-only sandbox), 1 round, on git diff against the base branch.

Verdict: signed off, no changes requested.

I sign off on this PR. No concrete correctness, regression, or code-quality problems found.

The change preserves blanks inside link text while retaining the required trimming around line breaks. Tests cover inline links, reference links, image alt text, and continuation-line indentation.

Codex could not run moon test in its read-only sandbox. The tests were run separately on native, js and wasm-gc and pass.

@bobzhang
bobzhang merged commit 39d94de into main Oct 2, 2026
9 checks passed
@bobzhang
bobzhang deleted the conformance/link-text-leading-blanks branch October 2, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant