Support inline code diff notation - #2
Conversation
📝 WalkthroughWalkthroughInline ChangesInline code diff notation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant MarkdownInput
participant parseCodeDiffNotation
participant renderCodeFence
participant TanStackMarkdownHighlighter
MarkdownInput->>parseCodeDiffNotation: Provide code with inline diff directives
parseCodeDiffNotation-->>renderCodeFence: Return cleaned code and line decorations
renderCodeFence->>TanStackMarkdownHighlighter: Pass cleaned code and merged decorations
TanStackMarkdownHighlighter-->>MarkdownInput: Return highlighted markup without directives
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/markdown.ts`:
- Around line 149-155: Update the decoration assembly in the markdown rendering
flow around parseCodeDiffNotation and parseCodeFenceMeta to preserve mappings
for stripped directive spans and rebase caller-provided range decorations from
the original code onto the cleaned text before combining them. Keep parsed and
annotated decorations intact, and add coverage for a range on a line following a
removed directive to verify it renders at the corrected offset.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 26c77796-82ab-4ef8-ac32-972ff4f9a8c2
📒 Files selected for processing (4)
docs/guides/annotations.mddocs/reference/markdown.mdsrc/markdown.tstest/adapters.test.ts
| const annotated = parseCodeDiffNotation(code) | ||
| const parsed = parseCodeFenceMeta(meta) | ||
| const resolvedDecorations = [...parsed.decorations, ...(decorations || [])] | ||
| const resolvedDecorations = [ | ||
| ...annotated.decorations, | ||
| ...parsed.decorations, | ||
| ...(decorations || []), | ||
| ] |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Rebase range decorations after stripping directives.
decorations can contain character-range offsets for the original code. Removing a directive shifts all later offsets, so caller-provided range decorations render on the wrong text. Preserve removed-span mappings and rebase range decorations before rendering; add coverage for a range on a line after a directive.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/markdown.ts` around lines 149 - 155, Update the decoration assembly in
the markdown rendering flow around parseCodeDiffNotation and parseCodeFenceMeta
to preserve mappings for stripped directive spans and rebase caller-provided
range decorations from the original code onto the cleaned text before combining
them. Keep parsed and annotated decorations intact, and add coverage for a range
on a line following a removed directive to verify it renders at the corrected
offset.
What changed
[!code ++]and[!code --]directives at the Markdown adapter boundary.th-line--insertedandth-line--deleteddecorations.Why
TanStack docs already use Shiki's inline diff notation. The new Highlight renderer treated those directives as literal source, leaking them into rendered and copied code.
Validation
pnpm run verifySummary by CodeRabbit
[!code ++]and[!code --]markers.