Repository navigation
refactor(editor): land shared Markdown scanners on main - #21565
Conversation
* refactor(editor): add shared Markdown scanners * test(editor): verify standalone scanner boundaries
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughAdds Markdown fence and inline code span scanners. The scanners handle fence markers, block boundaries, escaped backticks, matching run lengths, table delimiters, and CR, CRLF, and LF line endings. Adds range helpers for fenced blocks and inline spans. Adds Priority: ⬇️ Low 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: a0c08017-dc77-4b1c-8669-76f32803f512
📒 Files selected for processing (5)
src/renderer/src/components/editor/markdown-code-span-scanner.tssrc/renderer/src/components/editor/markdown-code-stripping.tssrc/renderer/src/components/editor/markdown-fence-scanner.tssrc/renderer/src/components/editor/markdown-scan-ranges.tssrc/renderer/src/components/editor/markdown-scanner-boundaries.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
Important
markdown-code-span-scanner.ts drops multi-line code spans that follow a bare --- line: TABLE_DELIMITER_ROW accepts a delimiter row the parser rejects, so insideTable latches and every following line becomes its own inline block. One inline comment below with a repro and a suggested fix.
Reviewed changes
Reviewed the scanner layer at the current head 23aab08. The run's event payload and checkout_pr pointed at the earlier c6f12e0, whose diff predates the 23aab08 fixes, so the fix commit was read from the API and the differential checks were rerun against 23aab08.
markdown-fence-scanner.ts— line iteration, a fence tracker that now matches the parser's closer rules (at most three spaces, mixed-marker trailers), fence-range extraction, and a linear cursor for non-decreasing probes.markdown-code-span-scanner.ts— a one-pass backtick-run index with a block-boundary heuristic and binary-searchfindSpanEnd.markdown-code-stripping.ts—stripMarkdownCode, which erases fence and inline-code ranges while preserving the original line terminators.markdown-scan-ranges.ts— themarkdownFenceRanges/markdownCodeSpanRanges/isInsideRangeextraction with the invalid-info-string fix.markdown-scanner-boundaries.test.ts— six boundary tests: invalid fence info, escaped openers, CR-only lines, fenced content, terminator preservation, and mixed-marker closers.
ℹ️ Nitpicks
markdown-scan-ranges.ts:37still requires the opening marker for a closer, somarkdownFenceRanges('```\ncode\n```~~~\n')leaves the fence unterminated where marked (andmarkdown-fence-scanner.ts) closes it. The existing thread already raised this and it is unresolved at23aab08; if the stricter rule is deliberate for thedetailsconsumer, a one-line note would keep it from reading as parser parity.- The span scanner indexes backtick runs inside HTML blocks, so
'<div>\nx'yields a span while marked treats the block as raw HTML with no inline parsing. Low impact, since the HTML block is detected regardless. markdown-scan-ranges.ts'smarkdownCodeSpanRangespairs spans across blank lines and leaf-block starts ('foo\n\nbar'→ one span) where marked returns none, while the sibling scanner treats those as boundaries. If this loose behavior intentionally mirrorsraw-markdown-html.ts, a word to that effect would avoid it being read as a marked-parity claim.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior pullfrog review (23aab08 → 695f4c4): a one-line fix to TABLE_DELIMITER_ROW plus regression tests.
- Bare dash lines no longer latch table mode —
TABLE_DELIMITER_ROWgained a(?=[^\n]*[:|])lookahead, mirroring marked'stableDelimiter: /[:|]/check against the delimiter row, so-,--, and---are no longer treated as delimiter rows and no longer suppress multi-line code spans that follow them. - Regression coverage — three bare-dash cases assert the scanner pairs
`code\nspan`where marked does, and two valid delimiter rows (| --- |,:---) assert table rows stay separate.
The lookahead is equivalent to marked's rule: the line matched by the pattern contains only spaces, |, -, and :, so requiring [:|] anywhere in the line matches marked's test of the captured delimiter row. Verified against the installed marked 17.0.6.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Provides reusable code-boundary scanners before integrating them into editing.
What Changed
Adds fence, code-span, code-stripping, and range scanners. Rejects invalid fence info and escaped openers; supports CR-only lines. Existing callers switch in the next layer.
Why
Reviewing boundary rules separately makes the later integration easier to assess.
Linked Issue
Related to #9858; this stack is a partial compatibility improvement and does not close the full request.
Visual Proof
N/A — no renderer or existing call-site behavior changes in this layer.
Testing
Merged head 695f4c4: 14 standalone scanner tests passed, full local typecheck and changed-code quality passed, full CI run 35417005003 succeeded. Bare dash/setext lines no longer latch table mode; three failing-before regressions and two real-table controls cover the correction.
Final stack bd17fae:
All launches used ORCA_BACKGROUND_LAUNCH=1. Paired-client coverage runs on macOS; live SSH/network failures and Windows/Linux Electron UI were not exercised. Latest CI reruns are separate from these local results.
Review
Low direct runtime risk: adds scanners before existing production callers switch. Follow-up to #21554, which merged into the old stack base rather than main.
Independent readiness reviews covered #21527 and #21531. Later preview/scanner findings were fixed with regressions. The fence tracker retains mixed-marker closers to match the installed parser; over-indented closers are rejected.
Remaining stack: #21527 → #21530 → #21531. #21565 merged to main. #21529 merged into #21527; #21532 merged into #21531. The two stack merges have not landed on main. #9858 remains open; full GFM support is broader than this stack.
Agent skill upstream boundary
Checklist