Skip to content

Commit

Permalink
fix(core): fix the incorrect parameter when using a single theme (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
il-1337 authored Jul 25, 2024
1 parent 4111b03 commit 5e2a69e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/src/code-to-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function codeToTokens(
rootStyle = defaultColor ? undefined : [fg, bg].join(';')
}
else if ('theme' in options) {
const colorReplacements = resolveColorReplacements(options.theme, options.colorReplacements)
const colorReplacements = resolveColorReplacements(options.theme, options)

tokens = codeToTokensBase(
internal,
Expand Down
14 changes: 14 additions & 0 deletions packages/shiki/test/color-replacement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ it('flat colorReplacements', async () => {
`)
})

it('single theme colorReplacements', async () => {
const result = await codeToHtml('console.log("hi")', {
lang: 'js',
theme: 'vitesse-light',
colorReplacements: {
'#393a34': 'var(---replaced-1)',
'#b07d48': 'var(---replaced-2)',
},
})

expect(result).toContain('var(---replaced-1)')
expect(result).toContain('var(---replaced-2)')
})

it('scoped colorReplacements', async () => {
const customLightTheme: ThemeRegistrationResolved = {
name: 'custom-light',
Expand Down

0 comments on commit 5e2a69e

Please sign in to comment.