Skip to content

fix: preserve Markdown literals in replies containing tables - #139892

Merged
steipete merged 2 commits into
mainfrom
codex/qa30-31-markdown-table-literals-20260905
Sep 6, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa30-31-markdown-table-literals-20260905

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled so maintainers can help update the branch when needed.

What Problem This Solves

Fixes an issue where users reading replies with Markdown tables would see escaped literals or inline code change meaning when the table was converted to a text fallback. For example, adding a table after Keep \*stars\* and ``a`b`` literal. could turn the stars into emphasis and break the embedded-backtick code span. Headings and blockquotes elsewhere in the same reply could also lose their formatting.

Why This Change Was Made

The converter now replaces only the table ranges recognized by the existing MarkdownIt parser, preserving the original source everywhere else and retaining cell Markdown for bullet output. Native IR and Markdown fallbacks share table layout and newline emission, including the existing behavior for empty rows; the whole-message Markdown roundtrip and duplicate layout paths are removed.

User Impact

Replies containing tables retain their surrounding formatting, escaped literals and inline code. Bullet tables preserve authored cell markup and document reference links, and tables remain inside their original quote or list containers. Code-table alignment and the block-mode code fallback keep their existing behavior.

A separate pre-existing issue remains: unescaped standalone emphasis/backtick delimiters in cells can bind to generated bullet-formatting markers. That requires its own inline delimiter-ownership repair; authored escapes are preserved by this change.

Evidence

  • Captured the original failure before editing: 9 failing converter regressions and 3 passing controls.
  • Final focused verification: 138 tests passed across the converter, native bullet/code/block table renderers, and Discord formatter/chunker. Five row-spacing cases cover ordinary, empty-middle, empty-edge, all-empty and labeled rows; six standalone comparisons confirm that the complete native IR and converted Markdown match the original spacing behavior.
  • Scoped typed lint passed for all four changed files. Production code is 175 lines added / 179 removed (net −4); regression coverage adds 132 test lines.
  • Exercised the actual renderDiscordMarkdown caller locally with synthetic Markdown in code, bullets and block modes, then parsed the result with MarkdownIt. Escaped literals, multi-backtick code and reference links remained intact. Additional source-range checks covered nested quotes/lists, tabs, CRLF/bare CR, header-only tables and MarkdownIt's existing list-like-header recognition.
  • Independent Codex reviews of the row-spacing repair and the subsequent type-only correction are scoped-clean through P2, with no actionable findings.
  • The canonical assertion-safety ratchet passes with the existing per-file allowance of nine; no baseline was raised. Actual caller/declaration checks pass, and the type-only correction emits byte-identical JavaScript while keeping private table metadata out of serialized payloads.
  • Published head 1027f40156ef651e04cf733742e667ca2e974c49 contains only the four reviewed files relative to f4bde51ed1c0519631efec33e8aa2bc78b1e0d38. The complete tree and owned blobs were verified; the assertion correction preserves emitted JavaScript and native payloads.

Focused test command:

node scripts/run-vitest.mjs \
  packages/markdown-core/src/tables.test.ts \
  packages/markdown-core/src/ir.table-bullets.test.ts \
  packages/markdown-core/src/ir.table-code.test.ts \
  packages/markdown-core/src/ir.table-block.test.ts \
  extensions/discord/src/markdown.test.ts \
  extensions/discord/src/chunk.test.ts

The formatter proof was local; no external Discord message was sent. Broad local release gates were not rerun. Hosted exact-head CI remains required before native landing.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 07:24
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 3:53 AM ET / 07:53 UTC.

ClawSweeper review

What this changes

Preserve surrounding Markdown and authored table-cell markup while sharing bullet and code-table layout between reply conversion and native rendering.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary: current main and v2026.9.2 still round-trip the whole message when converting tables. No actionable introduced defect was found. The maintainer-authored, protected PR should remain open.

Priority: P2
Reviewed head: 1027f40156ef651e04cf733742e667ca2e974c49

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this formatter repair from the external-contributor proof gate. The body reports local production-caller checks through renderDiscordMarkdown for all converted modes, but provides no external Discord run; this review did not execute those checks.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this formatter repair from the external-contributor proof gate. The body reports local production-caller checks through renderDiscordMarkdown for all converted modes, but provides no external Discord run; this review did not execute those checks.
Evidence reviewed 8 items Current main still contains the defect mechanism: The converter parses the entire message and returns renderMarkdownWithMarkers with fixed code delimiters and identity text escaping whenever a table exists. This loses authored escaping and source formatting outside the table.
Latest release retains the same converter: The supplied latest release, v2026.9.2, contains the same whole-message conversion path; this repair is not already present there.
Introduced repair and compatibility boundary: The complete host-pinned introduction patch and checked-out files replace only parsed table ranges. Existing mode arguments remain unchanged, and source metadata uses non-enumerable properties so serialized native table payloads retain their existing shape.
Findings None None.
Security None None.

How this fits together

Markdown Core prepares replies for channel-specific formatters. Its table converter turns unsupported tables into bullets or code blocks before callers such as Discord format and send the reply.

flowchart LR
  A[Markdown reply] --> B[Existing Markdown parser]
  B --> C[Table source ranges]
  C --> D{Table mode}
  D --> E[Bullets or code table]
  A --> F[Preserved surrounding source]
  E --> G[Channel formatter]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -4, Tests +132. Total +128 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 175 179 -4
Tests 1 132 0 +132
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 307 179 +128

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net −4 lines; tests +132 lines Sharing table layout reduces production code while adding behavioral coverage for source preservation and existing spacing.

Technical review

Best possible solution:

Keep table conversion source-local while preserving existing modes, native payloads, cell whitespace, and shared layout semantics.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the failure path: adding a table causes escaped text and multi-backtick code elsewhere in the reply to pass through lossy Markdown reconstruction. This review did not execute a reproduction.

Is this the best way to solve the issue?

Yes. Replacing parser-recognized table ranges addresses the loss at its owner while reusing established layouts and preserving unrelated source.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1594ebfcb945.

Labels

Label justifications:

  • P2: This repairs reply formatting when tables are converted, with limited impact and no demonstrated delivery or availability failure.
  • 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: The supplied MEMBER association exempts this formatter repair from the external-contributor proof gate. The body reports local production-caller checks through renderDiscordMarkdown for all converted modes, but provides no external Discord run; this review did not execute those checks.

Evidence

What I checked:

  • Current main still contains the defect mechanism: The converter parses the entire message and returns renderMarkdownWithMarkers with fixed code delimiters and identity text escaping whenever a table exists. This loses authored escaping and source formatting outside the table. (packages/markdown-core/src/tables.ts:17, 1594ebfcb945)
  • Latest release retains the same converter: The supplied latest release, v2026.9.2, contains the same whole-message conversion path; this repair is not already present there. (packages/markdown-core/src/tables.ts:17, 3928bad9badf)
  • Introduced repair and compatibility boundary: The complete host-pinned introduction patch and checked-out files replace only parsed table ranges. Existing mode arguments remain unchanged, and source metadata uses non-enumerable properties so serialized native table payloads retain their existing shape. (packages/markdown-core/src/ir.ts:950, 1027f40156ef)
  • Regression coverage and production caller: Reviewed the complete converter tests and native bullet/code/block tests. Added cases protect surrounding bytes, escaped literals, embedded backticks, reference links, empty-row spacing, containers, and CRLF. Discord's production formatter directly calls convertMarkdownTables before normalizing bold markers. Tests were not executed during this read-only review. (extensions/discord/src/markdown.ts:320, 1027f40156ef)
  • Documented table contract: The documentation defines existing code, bullets, block, and off modes and requires preservation of code-owned cell whitespace. The patch retains these modes and the existing cell-trimming owner. Public docs: docs/concepts/markdown-formatting.md. (docs/concepts/markdown-formatting.md:57, 1027f40156ef)
  • Captured proof and review continuity: The supplied body reports 138 passing focused tests and a local run through renderDiscordMarkdown in code, bullets, and block modes; it explicitly says no external Discord message was sent. The previous completed review retained no findings or published rank-up moves. These are captured contributor claims, not reviewer-executed results. (1027f40156ef)

Likely related people:

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

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-09-06T07:36:22.603Z sha b9b40b8 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 5d1a419 into main Sep 6, 2026
133 checks passed
@steipete
steipete deleted the codex/qa30-31-markdown-table-literals-20260905 branch September 6, 2026 08:25
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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: M 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.

1 participant