Skip to content

Conversation

@namanrajpal
Copy link
Contributor

Feel free to comment and decline, just found it useful, hence opening a PR
Adds markdown rendering capability to the FilePreview component, allowing users to preview .md and .mdx files with proper syntax highlighting that respects the app's theme settings.

Features

  • Markdown Preview Toggle: Preview rendered markdown or view raw source with a toggle button
  • Theme-Aware Syntax Highlighting: Code blocks automatically adapt to light/dark/system theme
  • GitHub Flavored Markdown: Full GFM support (tables, task lists, strikethrough, etc.)
  • Large File Support: Works seamlessly with virtualized file viewing
  • Clean Architecture: Reusable components following project conventions

Technical Changes

New Files

  • MarkdownRenderer.tsx - Dedicated component for rendering markdown content
  • MarkdownComponents.tsx - Shared ReactMarkdown component configurations

Modified Files

  • FilePreview.tsx - Integrated markdown preview functionality
  • index.css - Added theme-aware syntax highlighting styles

Dependencies Used

  • react-markdown - Markdown to React conversion
  • remark-gfm - GitHub Flavored Markdown support
  • rehype-highlight - Syntax highlighting for code blocks
  • rehype-raw - Support for raw HTML in markdown
  • highlight.js - Syntax highlighting engine

📸 Preview

Users can now:

  • Click the eye/code icon to toggle between rendered and raw markdown
  • View code blocks with proper syntax highlighting
  • See markdown that adapts to their theme preference (light/dark/system)

Testing Notes

opencode recording
Screenshot 2026-01-12 235832

  • Test with .md and .mdx files
  • Verify theme switching (Settings → Theme → Light/Dark/System)
  • Check large markdown files with virtualization
  • Confirm syntax highlighting in code blocks

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