Skip to content

Commit

Permalink
feat: allow passing grammarStates to codeToTokensWithThemes
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Oct 6, 2024
1 parent ea4b8dd commit 6c3a2d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/core/src/highlight/code-to-tokens-themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function codeToTokensWithThemes(
const tokens = syncThemesTokenization(
...themes.map(t => codeToTokensBase(internal, code, {
...options,
grammarState: options.grammarStates?.[t.color],
theme: t.theme,
})),
)
Expand Down
3 changes: 3 additions & 0 deletions packages/types/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export interface CodeToTokensWithThemesOptions<Languages = string, Themes = stri
* ```
*/
themes: Partial<Record<string, Themes | ThemeRegistrationAny | SpecialTheme>>

// TODO:
grammarStates?: Partial<Record<string, GrammarState>>
}

export interface ThemedTokenScopeExplanation {
Expand Down

0 comments on commit 6c3a2d3

Please sign in to comment.