Repository navigation
feat(desktop): add markdown syntax highlighting for Monaco editor - #427
Conversation
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
WalkthroughThis change adds custom Markdown token styling support to the Monaco editor theme by introducing a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/desktop/src/renderer/stores/theme/utils/monaco-theme.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
apps/desktop/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)
apps/desktop/**/*.{ts,tsx,js,jsx}: For Electron interprocess communication, ALWAYS use trpc as defined insrc/lib/trpc
Use alias as defined intsconfig.jsonwhen possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
Files:
apps/desktop/src/renderer/stores/theme/utils/monaco-theme.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Avoid using any type in TypeScript - maintain type safety unless absolutely necessary
Files:
apps/desktop/src/renderer/stores/theme/utils/monaco-theme.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Run Biome for formatting, linting, import organization, and safe fixes at the root level using bun run lint:fix
Files:
apps/desktop/src/renderer/stores/theme/utils/monaco-theme.ts
apps/desktop/src/renderer/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Never import Node.js modules in renderer process or shared code - use only in main process (src/main/)
Files:
apps/desktop/src/renderer/stores/theme/utils/monaco-theme.ts
apps/desktop/src/{main,renderer,preload}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use type-safe IPC communication - define channel types in apps/desktop/src/shared/ipc-channels.ts before implementing handlers
Files:
apps/desktop/src/renderer/stores/theme/utils/monaco-theme.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
🔇 Additional comments (1)
apps/desktop/src/renderer/stores/theme/utils/monaco-theme.ts (1)
86-86: Clean integration of token rules.The integration correctly replaces the empty rules array with the new
createTokenRules(theme)function, enabling the markdown syntax highlighting feature.
| function createTokenRules(theme: Theme): editor.ITokenThemeRule[] { | ||
| const { terminal } = theme; | ||
| const hex = (color: string) => toHexAuto(color).slice(1); | ||
|
|
||
| return [ | ||
| // Markdown | ||
| { token: "keyword.md", foreground: hex(terminal.blue) }, | ||
| { token: "string.link.md", foreground: hex(terminal.cyan) }, | ||
| { token: "variable.md", foreground: hex(terminal.blue) }, | ||
| { token: "string.md", foreground: hex(terminal.green) }, | ||
| { token: "variable.source.md", foreground: hex(terminal.foreground) }, | ||
| { token: "markup.bold.md", fontStyle: "bold" }, | ||
| { token: "markup.italic.md", fontStyle: "italic" }, | ||
| { token: "markup.strikethrough.md", fontStyle: "strikethrough" }, | ||
| ]; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
find . -name "monaco-theme.ts" -o -name "*theme*" -type f | head -20Repository: superset-sh/superset
Length of output: 403
🏁 Script executed:
find . -name "*markdown*" -type f | grep -E "\.(ts|js|json)$" | head -10Repository: superset-sh/superset
Length of output: 46
🏁 Script executed:
cat -n apps/desktop/src/renderer/stores/theme/utils/monaco-theme.ts | head -100Repository: superset-sh/superset
Length of output: 4147
Token names in createTokenRules will not apply styling to markdown in Monaco Editor.
The token names defined for markdown styling (lines 71-77) do not match tokens generated by Monaco's built-in markdown language. Tokens like markup.bold, markup.italic, and markup.strike are TextMate grammar scopes, not Monaco Monarch tokens. The rules for string.link.md, variable.md, variable.source.md, markup.bold.md, markup.italic.md, and markup.strikethrough.md will have no effect because Monaco's markdown tokenizer does not generate these token names.
Only keyword.md (line 70) aligns with Monaco's actual markdown token output. To fix this, verify the actual token names using Monaco's Inspect Tokens tool in the editor (search via command palette), then update the rules to match.
🤖 Prompt for AI Agents
In apps/desktop/src/renderer/stores/theme/utils/monaco-theme.ts around lines
64–79, the token names used for markdown (e.g. string.link.md, variable.md,
markup.bold.md, markup.italic.md, markup.strikethrough.md) are TextMate scopes
and will not be emitted by Monaco's markdown tokenizer; replace them with the
actual Monaco token names (remove the .md suffix and use Monaco's tokens such as
`link`, `strong`/`bold`/`heading`/`emphasis`/`strike` or whatever your Monaco
Inspect Tokens tool reports) so the styles apply: open the editor, run “Inspect
Tokens” to confirm exact token names Monaco emits for links, bold, italic,
strikethrough, etc., then update each rule key to the matching Monaco token
(keeping the hex(...) foreground/fontStyle logic) and remove or rename any rules
that don’t match Monaco tokens.
Summary
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.