-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(plugin-shiki): code and test refactor (#302)
- Loading branch information
1 parent
356e1a2
commit 8acd640
Showing
10 changed files
with
160 additions
and
130 deletions.
There are no files selected for viewing
This file contains 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
27 changes: 27 additions & 0 deletions
27
plugins/markdown/plugin-shiki/src/node/markdown/highlighter/createShikiHighlighter.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { BundledLanguage, BundledTheme, HighlighterGeneric } from 'shiki' | ||
import { createHighlighter } from 'shiki' | ||
import { bundledLanguageNames } from '../../shiki.js' | ||
import type { ShikiHighlightOptions } from '../../types.js' | ||
|
||
export const createShikiHighlighter = async ({ | ||
langs = bundledLanguageNames, | ||
langAlias = {}, | ||
defaultLang, | ||
shikiSetup, | ||
...options | ||
}: ShikiHighlightOptions = {}): Promise< | ||
HighlighterGeneric<BundledLanguage, BundledTheme> | ||
> => { | ||
const shikiHighlighter = await createHighlighter({ | ||
langs, | ||
langAlias, | ||
themes: | ||
'themes' in options | ||
? Object.values(options.themes) | ||
: [options.theme ?? 'nord'], | ||
}) | ||
|
||
await shikiSetup?.(shikiHighlighter) | ||
|
||
return shikiHighlighter | ||
} |
This file contains 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
This file contains 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
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
plugins/markdown/plugin-shiki/src/node/markdown/highlighter/index.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './createMarkdownFilePathGetter.js' | ||
export * from './createShikiHighlighter.js' | ||
export * from './getHighLightFunction.js' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './applyHighlighter/index.js' | ||
export * from './highlighter/index.js' | ||
export * from './highlightLinesPlugin.js' | ||
export * from './preWrapperPlugin.js' |
This file contains 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
Oops, something went wrong.