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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -34,7 +34,7 @@
"@histoire/vendors": "workspace:^",
"@types/flexsearch": "^0.7.6",
"flexsearch": "0.7.21",
"shiki-es": "^0.2.0"
"shiki": "^1.1.2"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.10",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { computed, markRaw, nextTick, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'
import { Icon } from '@iconify/vue'
import { getHighlighter, Highlighter } from 'shiki-es'
import { getHighlighter, Highlighter } from 'shiki'
import { HstCopyIcon } from '@histoire/controls'
import { unindent } from '@histoire/shared'
import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
Expand Down
2 changes: 1 addition & 1 deletion packages/histoire/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"pathe": "^1.1.1",
"picocolors": "^1.0.0",
"sade": "^1.8.1",
"shiki-es": "^0.2.0",
"shiki": "^1.1.2",
"sirv": "^2.0.3",
"vite-node": "^0.34.6"
},
Expand Down
9 changes: 4 additions & 5 deletions packages/histoire/src/node/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MarkdownIt from 'markdown-it'
import matter from 'gray-matter'
import { getHighlighter } from 'shiki-es'
import { getHighlighter, bundledLanguages } from 'shiki'
import anchor from 'markdown-it-anchor'
import attrs from 'markdown-it-attrs'
import emoji from 'markdown-it-emoji'
Expand Down Expand Up @@ -29,13 +29,12 @@ function notifyMarkdownListChange () {

export async function createMarkdownRenderer (ctx: Context) {
const highlighter = await getHighlighter({
theme: 'github-dark',
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 @@ -104,7 +104,7 @@ export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context)
],
include: optimizeDeps([
'flexsearch',
'shiki-es',
'shiki',
// Shiki dependencies
'vscode-oniguruma',
'vscode-textmate',
Expand Down
26 changes: 16 additions & 10 deletions pnpm-lock.yaml

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

Loading