-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat: migrate to shikiji #3237
feat: migrate to shikiji #3237
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Rest looks good to me. I'm fine with introducing some breaking changes this once, as long as we can mention the migration path here, so that we can just redirect users to visit this PR for solutions. |
Co-authored-by: Divyansh Singh <[email protected]>
Yes, it support custom langs. But Edit: Updated https://github.com/antfu/shikiji/blob/main/docs/languages.md#migrate-from-shiki |
Should be good to go now |
Just curious, const vineGrammar = JSON.parse(fs.readFileSync(join(__dirname, './vine-ts.tmLanguage.json'), 'utf8')) how is this different from |
No, both would work. Tho in real ESM you can't directly import |
Yeah I meant with |
Also, in https://github.com/antfu/shikiji/blob/main/docs/languages.md#migrate-from-shiki I don't think For vue-vine guys, they need to change |
released in v1.0.0-rc.30 🎉 |
The way we used to import lang definitions from shiki was through
I noticed there are no What shall we use here? |
@husayt Hi, what's your use case for that? |
it is for me to add more aliases
|
Can you try if this works: export const markdown: MarkdownOptions = {
languageAlias: {
'myHtml': 'html',
'html:preview': 'html',
'html:preview:expanded:no-codepen': 'html',
}
} |
@brc-dd @antfu Can you please clarify how to migrate the following (proposed migration guides don't cover types and themes): import { defineConfig, MarkdownOptions } from "vitepress";
import { ILanguageRegistration } from "shiki";
export default defineConfig({
...
markdown: md
});
const md: MarkdownOptions = {
languages: [mylang],
theme: {
light: "./mylang-theme-light.json",
dark: "./mylang-theme-dark.json"
}
};
const mylang: ILanguageRegistration = {
id: "mylang",
aliases: ["mylang-alias"],
scopeName: "source.mylang",
path: "./mylang-textmate.json"
}; |
import { defineConfig } from "vitepress";
import { MarkdownOptions } from "vitepress";
import { LanguageRegistration } from "shikiji";
import grammar from "./mylang-textmate.json"
import themeDark from "./mylang-theme-dark.json"
import themeLight from "./mylang-theme-light.json"
export default defineConfig({
...
markdown: md
});
const md: MarkdownOptions = {
languages: [mylang],
theme: {
light: themeDark,
dark: themeLight,
}
};
const mylang: LanguageRegistration = {
id: "mylang",
aliases: ["mylang-alias"],
scopeName: "source.mylang",
...grammar,
}; |
Thank you, that seem to be working fine. Had type errors for imported grammar and theme jsons, but I didn't type-check them previously, so it's probably an issue on my side. At runtime everything seem to work same as before. |
Benefits:
shikiji-transformers
is created to mimic the behavior ofshiki-processor
. It also allows users to provide their own transformers.fs
This should be quite compatible with the previous behavior. The only change users might notice is that
.vp-code-dark
and.vp-code-light
are no longer used, instead, a single.vp-code
takes over.In general, I think this PR is good to do, marking it as draft as I need to handle some details onShould be ready :)shikiji
side and release a stable version before this gets merged.