Repository navigation
fix(markdown): preserve trailing inline-code whitespace - #134451
Conversation
Keep parser-normalized trailing spaces inside inline code when finalizing Markdown IR, including linked code and a code span containing one space. Use the existing code-span boundary floor for both inline and block code; ordinary trailing prose and generated separators still trim as before. Verified six focused cases, 85 IR owner/sibling checks, and seven pure renderer cases. The focused cases overlap the owner suite. Production changes are net -1 line; tests add 90 lines. Channel-specific trimming and post-IR chunk whitespace policies remain separate follow-ups.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 5:41 PM ET / 21:41 UTC. ClawSweeper reviewWhat this changesThe PR preserves terminal whitespace inside inline-code spans in shared Markdown IR and adds focused IR and marker-renderer regression coverage. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep this focused maintainer PR open for normal merge review. The repair is at the shared Markdown IR owner boundary, current main still has the reported inline-code loss, and no blocking patch defect was found; exact-head CI is still running. Priority: P2 Review scores
Verification
How this fits togetherMarkdown input is parsed into a shared intermediate representation used by format renderers and channel plugins. The IR finalizer removes generated terminal separators while preserving content covered by code spans before consumers render or chunk it. flowchart LR
A[Markdown input] --> B[Markdown parser]
B --> C[Shared Markdown IR]
C --> D[IR finalizer]
D --> E[Marker renderer]
D --> F[Channel plugins]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -1, Tests +90. Total +89 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the shared-finalizer repair after exact-head CI completes, retaining the focused IR and marker-renderer regressions rather than adding channel-specific trimming exceptions. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible with high confidence: current main's finalizer retains only code-block endpoints after trimEnd, while inline-code rendering records a separate code endpoint that the reported inputs expose. Is this the best way to solve the issue? Yes. Extending the existing retention floor at markdownToIRWithMeta is the narrow owner-boundary repair; downstream renderer or channel trim changes would be too late because the payload is already lost. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 34df33ea21dd. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
) Keep parser-normalized trailing spaces inside inline code when finalizing Markdown IR, including linked code and a code span containing one space. Use the existing code-span boundary floor for both inline and block code; ordinary trailing prose and generated separators still trim as before. Verified six focused cases, 85 IR owner/sibling checks, and seven pure renderer cases. The focused cases overlap the owner suite. Production changes are net -1 line; tests add 90 lines. Channel-specific trimming and post-IR chunk whitespace policies remain separate follow-ups.
Additional instructions
Keep Allow edits from maintainers enabled.
What Problem This Solves
Resolves a problem where Markdown ending in inline code lost a literal trailing space. For example, the code content
namebecamename, including when used as a link label; an inline-code span containing just one space disappeared entirely.Why This Change Was Made
The Markdown IR finalizer protected trailing content inside code blocks but omitted inline-code spans. It now uses the existing code-span boundaries for both forms, preserving parser-normalized code content and its style/link endpoints while still trimming generated trailing separators. No parser, renderer fallback, or new option is added.
User Impact
Consumers of the shared Markdown IR receive the complete terminal inline-code content. Ordinary trailing prose trimming remains unchanged. This does not alter channel-specific trim policies, table-cell cleanup, or downstream chunk whitespace policy.
Evidence
Copy <code>name </code>and<a href="https://example.com"><code>name </code></a>.Production: +5 / -6 (net -1). Tests: +90 / -0.
The renderer evidence exercises the shared IR-to-marker path with fixed ASCII inputs, not a live channel or general HTML escaping. Named follow-up: inspect post-IR chunk whitespace handling independently; Signal's explicit final trim, table-cell cleanup, and hidden list-content endpoints remain outside this repair.
Related: #82421 closed without merging and changes final chunk slicing/shared trimming. This repair preserves inline-code content earlier, during
markdownToIRfinalization; downstream chunk whitespace policy remains a separate follow-up.Fixes #134450