Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): migrate to shiki #683

Merged
merged 5 commits into from
Feb 21, 2025
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
2 changes: 1 addition & 1 deletion packages/histoire-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@histoire/shared": "workspace:^",
"@histoire/vendors": "workspace:^",
"fuse.js": "^7.0.0",
"shiki-es": "^0.14.0"
"shiki": "^3.0.0"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.15",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts" setup>
import type { Highlighter } from 'shiki-es'
import type { Highlighter } from 'shiki'
import type { Story, Variant } from '../../types'
import { HstCopyIcon } from '@histoire/controls'
import { unindent } from '@histoire/shared'
import { Icon } from '@iconify/vue'
import { getHighlighter } from 'shiki-es'
import { createHighlighter } from 'shiki'
import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
import { computed, markRaw, nextTick, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'
import { isDark } from '../../util/dark'
Expand Down Expand Up @@ -87,7 +87,7 @@ const displayedSourceCode = computed(() => {
// HTML render

onMounted(async () => {
highlighter.value = await getHighlighter({
highlighter.value = await createHighlighter({
langs: [
'html',
'jsx',
Expand Down
2 changes: 1 addition & 1 deletion packages/histoire/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"pathe": "^1.1.2",
"picocolors": "^1.1.1",
"sade": "^1.8.1",
"shiki-es": "^0.14.0",
"shiki": "^3.0.0",
"sirv": "^3.0.0",
"vite-node": "0.34.7"
},
Expand Down
11 changes: 5 additions & 6 deletions packages/histoire/src/node/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { full as emoji } from 'markdown-it-emoji'
import micromatch from 'micromatch'
import path from 'pathe'
import pc from 'picocolors'
import { getHighlighter } from 'shiki-es'
import { bundledLanguages, createHighlighter } from 'shiki'
import { addStory, notifyStoryChange, removeStory } from './stories.js'
import { slugify } from './util/slugify.js'

Expand All @@ -29,14 +29,13 @@ function notifyMarkdownListChange() {
}

export async function createMarkdownRenderer(ctx: Context) {
const highlighter = await getHighlighter({
theme: 'github-dark',
const highlighter = await createHighlighter({
themes: ['github-dark'],
langs: Object.keys(bundledLanguages), // not ideal but markdown-it does not provide async highlight
})

const md = new MarkdownIt({
highlight: (code, lang) => `<div class="htw-relative htw-not-prose __histoire-code"><div class="htw-absolute htw-top-0 htw-right-0 htw-text-xs htw-text-white/40">${lang}</div>${highlighter.codeToHtml(code, {
lang,
})}</div>`,
highlight: (code, lang) => `<div class="htw-relative htw-not-prose __histoire-code"><div class="htw-absolute htw-top-0 htw-right-0 htw-text-xs htw-text-white/40">${lang}</div>${highlighter.codeToHtml(code, { theme: 'github-dark', lang })}</div>`,
linkify: true,
html: true,
breaks: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/histoire/src/node/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
],
include: optimizeDeps([
'flexsearch',
'shiki-es',
'shiki',
// Shiki dependencies
'vscode-oniguruma',
'vscode-textmate',
Expand Down
Loading
Loading