Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ button {
top: 0;
}

/* Shiki theme colors */
html.light .shiki,
html.light .shiki span {
color: var(--shiki-light) !important;
background-color: var(--shiki-light-bg) !important;
font-style: var(--shiki-light-font-style) !important;
font-weight: var(--shiki-light-font-weight) !important;
text-decoration: var(--shiki-light-text-decoration) !important;
}

/* README prose styling */
.readme-content {
color: var(--fg-muted);
Expand Down Expand Up @@ -238,7 +248,7 @@ button {
.readme-content pre,
.readme-content .shiki {
background: oklch(0.145 0 0) !important;
border: 1px solid oklch(0.2686 0 0);
border: 1px solid var(--border);
border-radius: 8px;
padding: 1rem;
overflow-x: auto;
Expand Down
3 changes: 2 additions & 1 deletion server/utils/code-highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ export async function highlightCode(
try {
let html = shiki.codeToHtml(code, {
lang: language,
theme: 'github-dark',
themes: { light: 'github-light', dark: 'github-dark' },
defaultColor: 'dark',
})

// Shiki doesn't encode > in text content (e.g., arrow functions)
Expand Down
5 changes: 3 additions & 2 deletions server/utils/shiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let highlighter: HighlighterCore | null = null
export async function getShikiHighlighter(): Promise<HighlighterCore> {
if (!highlighter) {
highlighter = await createHighlighterCore({
themes: [import('@shikijs/themes/github-dark')],
themes: [import('@shikijs/themes/github-dark'), import('@shikijs/themes/github-light')],
langs: [
// Core web languages
import('@shikijs/langs/javascript'),
Expand Down Expand Up @@ -66,7 +66,8 @@ export function highlightCodeSync(shiki: HighlighterCore, code: string, language
try {
let html = shiki.codeToHtml(code, {
lang: language,
theme: 'github-dark',
themes: { light: 'github-light', dark: 'github-dark' },
defaultColor: 'dark',
})
// Remove inline style from <pre> tag so CSS can control appearance
html = html.replace(/<pre([^>]*)\s+style="[^"]*"/, '<pre$1')
Expand Down
4 changes: 2 additions & 2 deletions test/unit/docs-text.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ describe('renderMarkdown', () => {
const input = '```ts\nconst a = 1\n```\n\nSome text\n\n```js\nconst b = 2\n```'
const result = await renderMarkdown(input, emptyLookup)
expect(result).toContain('Some text')
// Both code blocks should be highlighted
expect((result.match(/shiki/g) || []).length).toBe(2)
// Both code blocks should be highlighted, search for `shiki` class
expect((result.match(/["\s]shiki["\s]/g) || []).length).toBe(2)
})

it('should not confuse inline code with fenced code blocks', async () => {
Expand Down