Skip to content

refactor(editor): land shared Markdown scanners on main - #21565

Merged
nwparker merged 3 commits into
mainfrom
nwparker/markdown-scanners-main
Sep 19, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/markdown-scanners-main

Conversation

@nwparker

@nwparker nwparker commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​550 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​550

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

  • Not applicable; no skill-installer source is included.

Checklist

  • User-visible behavior and implementation rationale explained.
  • Automated checks recorded with their scope.
  • Cross-platform, SSH/folder-workspace, and source-data effects considered.
  • Full PR Checks passed on the merged head; all review threads resolved.

* refactor(editor): add shared Markdown scanners

* test(editor): verify standalone scanner boundaries
@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: e700a939-e208-43cf-8b73-26fa225bef68

📥 Commits

Reviewing files that changed from the base of the PR and between 23aab08 and 695f4c4.

📒 Files selected for processing (2)
  • src/renderer/src/components/editor/markdown-code-span-scanner.ts
  • src/renderer/src/components/editor/markdown-scanner-boundaries.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

Adds 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 stripMarkdownCode, which removes fenced and closed inline code while preserving non-code content and original line terminators. Adds boundary tests for fence info strings, escaped backticks, divider lines, table delimiters, over-indented closers, and fenced content.

Priority: ⬇️ Low

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: adding shared Markdown scanners to the main branch. It is concise and related to the changeset.
Description check ✅ Passed The description is mostly complete. It includes the change summary, rationale, linked issue, visual-proof statement, extensive testing details, review notes, and relevant checklist items. The AI Discl…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a0c08017-dc77-4b1c-8669-76f32803f512

📥 Commits

Reviewing files that changed from the base of the PR and between e2afb5e and c6f12e0.

📒 Files selected for processing (5)
  • src/renderer/src/components/editor/markdown-code-span-scanner.ts
  • src/renderer/src/components/editor/markdown-code-stripping.ts
  • src/renderer/src/components/editor/markdown-fence-scanner.ts
  • src/renderer/src/components/editor/markdown-scan-ranges.ts
  • src/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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-search findSpanEnd.
  • markdown-code-stripping.ts — stripMarkdownCode, which erases fence and inline-code ranges while preserving the original line terminators.
  • markdown-scan-ranges.ts — the markdownFenceRanges/markdownCodeSpanRanges/isInsideRange extraction 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:37 still requires the opening marker for a closer, so markdownFenceRanges('```\ncode\n```~~~\n') leaves the fence unterminated where marked (and markdown-fence-scanner.ts) closes it. The existing thread already raised this and it is unresolved at 23aab08; if the stricter rule is deliberate for the details consumer, 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's markdownCodeSpanRanges pairs 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 mirrors raw-markdown-html.ts, a word to that effect would avoid it being read as a marked-parity claim.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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_ROW gained a (?=[^\n]*[:|]) lookahead, mirroring marked's tableDelimiter: /[:|]/ 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 545f526 into main Sep 19, 2026
29 checks passed
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