Skip to content

feat: add GitHub-style Markdown alert rendering#12274

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/github-markdown-alerts
Draft

feat: add GitHub-style Markdown alert rendering#12274
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/github-markdown-alerts

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 Bot commented May 5, 2026

Related GitHub Issue

Closes: #12267

Description

This PR attempts to address Issue #12267 by implementing GitHub-style Markdown alert rendering as a local remark plugin, per the feedback in the issue discussion.

Key implementation details:

  • Local remark plugin (remarkGithubAlerts.ts): Visits blockquote nodes in the AST, detects [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], and [!CAUTION] markers, strips the marker text, and annotates nodes with data-alert-type and CSS classes via hProperties.
  • Custom blockquote component in MarkdownBlock.tsx: Checks for the data-alert-type prop. Alert blockquotes render as styled <div> elements with a title label; normal blockquotes pass through unchanged.
  • VS Code theme variable styling: Each alert type gets a distinct left-border color using theme variables (--vscode-textLink-foreground, --vscode-testing-iconPassed, --vscode-editorInfo-foreground, --vscode-editorWarning-foreground, --vscode-editorError-foreground) with sensible fallbacks for light, dark, and high-contrast themes.
  • No new dependencies added -- uses existing unist-util-visit and the remark plugin interface already in the codebase.
  • No rehype-raw required.

Trade-off note: The local plugin is straightforward (~110 lines) and avoids adding remark-github-alerts (v0.1.1, limited adoption). The alert syntax is simple enough that a local implementation is robust without significant complexity.

Test Procedure

  • 21 unit tests for extractAlertType covering all alert types, case insensitivity, malformed markers, unsupported types, marker removal, break node handling, and edge cases.
  • 11 integration tests in MarkdownBlock.spec.tsx covering all five alert types rendering, normal blockquotes unchanged, multiline content, inline formatting, same-line content, and fallback for unsupported markers.

Run tests:

cd webview-ui && npx vitest run src/utils/__tests__/remarkGithubAlerts.spec.ts
cd webview-ui && npx vitest run src/components/common/__tests__/MarkdownBlock.spec.tsx

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue.
  • Scope: Changes are focused on the linked issue.
  • Self-Review: Self-reviewed.
  • Testing: 32 new tests added covering unit and integration scenarios.
  • Documentation Impact: No documentation updates needed.
  • Contribution Guidelines: Read and agreed.

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

Implements a local remark plugin that detects [!NOTE], [!TIP],
[!IMPORTANT], [!WARNING], and [!CAUTION] markers in blockquotes
and renders them as visually distinct alert blocks.

- Local remarkGithubAlerts plugin visits blockquote nodes
- Adds data attributes and CSS classes for alert styling
- Custom blockquote component renders alert title and content
- Styles use VS Code theme variables for light/dark/HC themes
- Normal blockquotes remain unchanged
- No new dependencies added
- 32 tests covering unit and integration scenarios
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.

[ENHANCEMENT] Add GitHub-style Markdown alert rendering

1 participant