Skip to content

fix(markdown): preserve trailing inline-code whitespace - #134451

Merged
steipete merged 1 commit into
mainfrom
codex/qa-20260831-markdown-inline-code-whitespace
Aug 31, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-20260831-markdown-inline-code-whitespace

Conversation

@steipete

Copy link
Copy Markdown
Contributor
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 name became name, 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

  • The same six focused IR cases changed from 3 failures / 3 controls passing to all 6 passing, covering terminal code, linked code, one-space code, followed-by-prose, plain prose trimming, and fenced code.
  • 85 tests passed across the full IR owner and four sibling suites, including links, block metadata, nested lists, and blockquote spacing. This includes the six focused cases above.
  • A separate original-source renderer run produced 2 failures / 1 control passing; after the repair, all 7 renderer tests passed, including four existing crossing-span controls. The actual marker renderer now retains the space in Copy <code>name </code> and <a href="https://example.com"><code>name </code></a>.
  • Normal formatting completed. Full P0–P2 managed source review found no actionable findings. The canonical changed-path gate completed all 28 checks, including core and core-test type checks, changed-file lint, formatting, and dead-export scans. This is local proof on the recorded base, not CI or current-main validation.

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 markdownToIR finalization; downstream chunk whitespace policy remains a separate follow-up.

Fixes #134450

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.
@steipete steipete self-assigned this Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 31, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 5:41 PM ET / 21:41 UTC.

ClawSweeper review

What this changes

The PR preserves terminal whitespace inside inline-code spans in shared Markdown IR and adds focused IR and marker-renderer regression coverage.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep 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
Reviewed head: 23238146e53516c62facf27c72dfc96c1806a975

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a clean net-negative owner-boundary fix with behavior-focused regressions; remaining CI is a merge gate rather than a patch-quality defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR includes supplied owner-level after-fix IR and marker-renderer evidence; the external-contributor real-behavior gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR includes supplied owner-level after-fix IR and marker-renderer evidence; the external-contributor real-behavior gate does not apply.
Evidence reviewed 7 items Introduced owner-boundary repair: The finalizer now floors retained text length at the end of either inline or block code spans, so trimEnd cannot discard authored terminal inline-code content.
Producer and consumer boundary: Inline-code rendering records a code style span covering the exact content, and the marker renderer consumes those text/style/link ranges to produce correctly nested output.
Current-main behavior remains unfixed: The fetched current-main revision still computes its retention floor from code_block spans only, so it does not implement this PR's inline-code preservation.
Findings None None.
Security None None.

How this fits together

Markdown 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]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI remains in progress, so this review does not establish merge readiness.
  • Resolve merge risk (P1) - The dependency-less checkout and unavailable network prevented direct inspection of markdown-it's locked parser implementation; this is a reviewer limitation, not missing contributor proof.
  • Complete next step (P2) - No repair lane is needed: there are no actionable findings, and this maintainer-owned protected-label PR should proceed through normal review once exact-head CI completes.
Agent review details

Security

None.

PR surface

Source -1, Tests +90. Total +89 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 6 -1
Tests 2 90 0 +90
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 95 6 +89

Review metrics

Metric Value Why it matters
Production versus regression coverage production +5/-6 (net -1); tests +90/-0 The bug fix absorbs the behavior at its owner boundary with net-negative production code and focused coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #134450
Summary: This PR is the explicit candidate repair for the open report about terminal inline-code whitespace loss.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    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.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This fixes a bounded shared Markdown formatting regression without evidence of message loss, availability failure, or a security boundary impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR includes supplied owner-level after-fix IR and marker-renderer evidence; the external-contributor real-behavior gate does not apply.

Evidence

What I checked:

  • Introduced owner-boundary repair: The finalizer now floors retained text length at the end of either inline or block code spans, so trimEnd cannot discard authored terminal inline-code content. (packages/markdown-core/src/ir.ts:1673, 23238146e535)
  • Producer and consumer boundary: Inline-code rendering records a code style span covering the exact content, and the marker renderer consumes those text/style/link ranges to produce correctly nested output. (packages/markdown-core/src/ir.ts:712, 23238146e535)
  • Current-main behavior remains unfixed: The fetched current-main revision still computes its retention floor from code_block spans only, so it does not implement this PR's inline-code preservation. (packages/markdown-core/src/ir.ts:1673, 34df33ea21dd)
  • Regression coverage is behavior-focused: The new table covers terminal inline code, linked code, a one-space span, unchanged prose trimming, and existing fenced-code preservation; renderer tests verify emitted marker placement. (packages/markdown-core/src/ir.test.ts:221, 23238146e535)
  • Public consumer surface: The plugin SDK exports markdownToIR and marker rendering primitives, while Telegram and LINE call markdownToIRWithMeta; preserving the canonical IR payload is therefore the correct shared boundary rather than a channel-specific trim exception. (src/plugin-sdk/text-chunking.ts:35, 23238146e535)
  • History and provenance limit: Blame identifies qingminlong as the last visible carrier of the old finalizer lines, but the boundary marker and raw-parent comparison do not establish feature introduction; no regression predecessor is attributed. (packages/markdown-core/src/ir.ts:1675, 346fae9a762d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • qingminlong: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the exact-head required CI results before merging.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-31T21:16:18.506Z sha 2323814 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review August 31, 2026 21:34
@steipete
steipete merged commit c0f1cbf into main Aug 31, 2026
207 checks passed
@steipete
steipete deleted the codex/qa-20260831-markdown-inline-code-whitespace branch August 31, 2026 23:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Terminal inline code loses literal trailing whitespace

1 participant