-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change syntax highlighter from PrismJS to Shiki
- Loading branch information
Showing
13 changed files
with
370 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
package-lock.json | ||
pnpm-lock.yaml | ||
yarn.lock | ||
src/lib/components/ui/** | ||
src/lib/components/ui/** | ||
.github/*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,43 @@ | ||
<script lang="ts"> | ||
import Prism from 'prismjs'; | ||
import 'prism-svelte'; | ||
import { createHighlighterCoreSync, createJavaScriptRegexEngine } from 'shiki'; | ||
import svelte from 'shiki/langs/svelte.mjs'; | ||
import dark from 'shiki/themes/github-dark-default.mjs'; | ||
let { | ||
content, | ||
lang = 'svelte' | ||
content | ||
}: { | ||
content: string; | ||
lang: string; | ||
} = $props(); | ||
let highlighted = $derived(Prism.highlight(content, Prism.languages[lang], 'svelte')); | ||
const shiki = createHighlighterCoreSync({ | ||
themes: [dark], | ||
langs: [svelte], | ||
engine: createJavaScriptRegexEngine() | ||
}); | ||
const highlighted = $derived.by(() => { | ||
return shiki.codeToHtml(content.trim(), { lang: 'svelte', theme: 'github-dark-default' }); | ||
}); | ||
</script> | ||
|
||
<div class="my-6 text-[14px] subpixel-antialiased"> | ||
<pre class={`language-${lang}`}><code class={`language-${lang}`}>{@html highlighted}</code></pre> | ||
<div class="my-6 subpixel-antialiased"> | ||
{@html highlighted} | ||
</div> | ||
|
||
<style> | ||
:global(.shiki code) { | ||
tab-size: 2; | ||
counter-reset: step; | ||
counter-increment: step 0; | ||
} | ||
:global(.shiki code .line::before) { | ||
content: counter(step); | ||
counter-increment: step; | ||
width: 1rem; | ||
margin-right: 1.5rem; | ||
display: inline-block; | ||
text-align: right; | ||
color: rgba(115, 138, 148, 0.4); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ description: Plain map. | |
|
||
<Demo /> | ||
|
||
<CodeBlock content={demoRaw} /> | ||
<CodeBlock content={demoRaw} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ description: Synchronize two maps. | |
|
||
<Demo /> | ||
|
||
<CodeBlock content={demoRaw} /> | ||
<CodeBlock content={demoRaw} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ description: 3D terrain and sky. | |
|
||
<Demo /> | ||
|
||
<CodeBlock content={demoRaw} /> | ||
<CodeBlock content={demoRaw} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ description: Display a video. | |
|
||
<Demo /> | ||
|
||
<CodeBlock content={demoRaw} /> | ||
<CodeBlock content={demoRaw} /> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters