feat: add @shikijs/twoslash-unocss package#1256
Open
khushthecoder wants to merge 1 commit intoshikijs:mainfrom
Open
feat: add @shikijs/twoslash-unocss package#1256khushthecoder wants to merge 1 commit intoshikijs:mainfrom
khushthecoder wants to merge 1 commit intoshikijs:mainfrom
Conversation
❌ Deploy Preview for shiki-next failed.
|
❌ Deploy Preview for shiki-matsu failed.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1256 +/- ##
==========================================
+ Coverage 89.53% 89.61% +0.07%
==========================================
Files 79 80 +1
Lines 3479 3514 +35
Branches 1009 1016 +7
==========================================
+ Hits 3115 3149 +34
- Misses 328 329 +1
Partials 36 36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add a new UnoCSS-backed twoslash runner that resolves utility classes to their generated CSS and surfaces them as hover info in Shiki code blocks, following the twoslash-eslint pattern. Closes shikijs#794
217857b to
6c9cae0
Compare
Member
|
Thanks for the PR! But I think this would be better to live in Uno's repo instead. Could you reopen a new PR there? Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a new UnoCSS-backed twoslash runner that resolves utility classes to their generated CSS and surfaces them as hover information in Shiki code blocks.
The goal is to provide UnoCSS utility hover support similar to how twoslash works for TypeScript. When hovering over a utility class inside a code block, the generated CSS is displayed inline via the twoslash hover protocol.
A new package
@shikijs/twoslash-unocssis introduced. The implementation follows thetwoslash-eslintpattern discussed in the issue. It:@unocss/core'screateGeneratorto generate CSSNodeHovernodes via the twoslash protocolSince UnoCSS v0.65+ is fully async (generator creation and CSS generation), the twoslasher function itself is async.
createTransformerFactoryhandles the returnedPromiseinternally, so no manual pre-resolution is required by users.Tests included:
All tests pass.
Linked Issues
fixes #794
Additional context
Reviewers may want to focus on: