Skip to content

✨ feat(highlighter): add minimal shiki-based renderer#485

Open
Innei wants to merge 1 commit intomasterfrom
feat/shiki-dynamic-highlighter
Open

✨ feat(highlighter): add minimal shiki-based renderer#485
Innei wants to merge 1 commit intomasterfrom
feat/shiki-dynamic-highlighter

Conversation

@Innei
Copy link
Member

@Innei Innei commented Mar 10, 2026

Summary

  • Add minimal syntax highlighter component and hook for common languages
  • Refactor shiki integration to use dynamic imports for languages/themes and streaming
  • Export new minimal highlighter API from package entrypoint

Test plan

  • Run npm test / existing test suite if applicable
  • Manually verify minimal highlighter renders code for json/js/ts/tsx/md/bash/etc.
  • Verify existing highlighter and streaming highlighting still work as before

Made with Cursor

- Add minimal syntax highlighter and export public API
- Refactor shiki usage to dynamic imports for langs/themes and streaming

Made-with: Cursor
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Innei, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobe-ui Ready Ready Preview, Comment Mar 10, 2026 3:15pm

Request Review

@lobehubbot
Copy link
Member

👍 @Innei


Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +123 to +124
import('@shikijs/transformers').then((mod) => {
setTransformers([

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines 15 to +17
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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

2 participants