✨ feat(highlighter): add minimal shiki-based renderer#485
✨ feat(highlighter): add minimal shiki-based renderer#485
Conversation
- Add minimal syntax highlighter and export public API - Refactor shiki usage to dynamic imports for langs/themes and streaming Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👍 @Innei |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1a9b0f811
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import('@shikijs/transformers').then((mod) => { | ||
| setTransformers([ |
There was a problem hiding this comment.
Wait for transformers before caching highlighted HTML
When enableTransformer is true, this async import means the first highlight pass runs with transformers still undefined, but the result is cached under the normal cacheKey; once the module finishes loading, later renders hit that cached promise and return early, so notation transformers never get applied for that code block unless the cache entry is evicted. This makes transformer-enabled highlighting silently behave like transformer-disabled highlighting.
Useful? React with 👍 / 👎.
| export const getCodeLanguageByInput = (input: string): string => { | ||
| if (!input) { | ||
| return 'plaintext'; | ||
| } | ||
| const inputLang = input.toLocaleLowerCase(); | ||
|
|
||
| const matchLang = bundledLanguagesInfo.find( | ||
| (lang) => lang.id === inputLang || lang.aliases?.includes(inputLang), | ||
| ); | ||
| return matchLang?.id || 'plaintext'; | ||
| if (!input) return 'plaintext'; | ||
| return input.toLocaleLowerCase(); |
There was a problem hiding this comment.
Restore alias-to-id language normalization
This now returns the raw lowercased input instead of resolving aliases to canonical Shiki language IDs, so common fence aliases (for example js, ts, md, sh) can bypass normalization and fail to match the IDs the highlighter is loaded with, causing degraded or missing syntax highlighting paths that previously worked. The new helper file still contains the old resolution logic, which suggests this path was unintentionally simplified.
Useful? React with 👍 / 👎.
Summary
Test plan
npm test/ existing test suite if applicableMade with Cursor