Skip to content

Commit

Permalink
fix: allow nullish color for colorReplacement, fix ansi highlighting …
Browse files Browse the repository at this point in the history
…with dark-plus, fix #597 (#598)
  • Loading branch information
chwzr authored Feb 21, 2024
1 parent b6d40a3 commit ccb5833
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function splitTokens<
}

export function applyColorReplacements(color: string, replacements?: Record<string, string>): string {
return replacements?.[color.toLowerCase()] || color
return replacements?.[color?.toLowerCase()] || color
}

export function getTokenStyleObject(token: TokenStyles) {
Expand Down
13 changes: 13 additions & 0 deletions packages/shiki/test/ansi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ Packages: +1038

expect(out).toMatchFileSnapshot('./out/ansi-background.html')
})

// https://github.com/shikijs/shiki/issues/597
it('renders ansi to html with theme dark-plus', async () => {
const out = await codeToHtml(` WARN  using --force I sure hope you know what you are doing
Scope: all 6 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +952
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 952, reused 910, downloaded 42, added 952, done
Done in 15.7s`, { theme: 'dark-plus', lang: 'ansi' })

expect(out).toMatchFileSnapshot('./out/ansi-dark-plus.html')
})
7 changes: 7 additions & 0 deletions packages/shiki/test/out/ansi-dark-plus.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ccb5833

Please sign in to comment.