- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: use Shiki shorthand #2026
base: main
Are you sure you want to change the base?
Changes from all commits
6380df9
72dc762
a40c3e3
3db0647
7189db9
163fa70
00f9ce4
510e40b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import type { Awaitable } from '@antfu/utils' | |
import type { KatexOptions } from 'katex' | ||
import type { MermaidConfig } from 'mermaid' | ||
import type * as monaco from 'monaco-editor' | ||
import type { BuiltinLanguage, BuiltinTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, Highlighter, LanguageInput } from 'shiki' | ||
import type { BuiltinLanguage, BuiltinTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, LanguageInput, LanguageRegistration, MaybeArray } from 'shiki' | ||
import type { VitePluginConfig as UnoCssConfig } from 'unocss/vite' | ||
import type { App, ComputedRef, Ref } from 'vue' | ||
import type { Router, RouteRecordRaw } from 'vue-router' | ||
|
@@ -57,8 +57,7 @@ export type ShikiSetupReturn = | |
& CodeOptionsThemes<BuiltinTheme> | ||
& CodeOptionsMeta | ||
& { | ||
setup: (highlighter: Highlighter) => Awaitable<void> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that this function is never called. And I don't know how to support it because there's no longer a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can get the highlighter with: const shiki = createSingletonShorthands<string, string>(createHighlighter)
const highlighter = await shiki.getSingletonHighlighter() But I don't mind removing it if no one uses it |
||
langs: (LanguageInput | BuiltinLanguage)[] | ||
langs: (MaybeArray<LanguageRegistration> | BuiltinLanguage)[] | Record<string, LanguageInput> | ||
} | ||
> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an ugly workaround 🥲
I tried passing
lang
andlangAlias
totransformerTwoslash
, but it either complains "language not loaded" or doesn't transform the code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to work on that to have
codeToHast
able to load grammars on demand - but that would requires quote some changes to the codebase to provide an async version of shiki - which I not yet have time to work on it properly 😇