Skip to content

Commit

Permalink
Merge pull request #300 from planetlabs/shikiji
Browse files Browse the repository at this point in the history
Updated syntax highlighter
  • Loading branch information
tschaub authored Oct 19, 2023
2 parents 3f394bc + daaaaf3 commit b03a88d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 36 deletions.
32 changes: 1 addition & 31 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"remark-parse": "^11.0.0",
"semapro": "^1.1.0",
"semver": "^7.3.7",
"shiki": "^0.14.1",
"shikiji": "^0.6.10",
"unified": "^11.0.2",
"vite": "^4.0.4",
"vitest": "^0.34.1",
Expand Down
12 changes: 8 additions & 4 deletions site/src/util/highlight.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import shiki from 'shiki';
import {getHighlighter} from 'shikiji';

const highlighterPromise = shiki.getHighlighter({
theme: 'github-light',
const highlighterPromise = getHighlighter({
themes: ['github-light'],
langs: ['javascript'],
});

export async function highlight(code) {
const highlighter = await highlighterPromise;
return highlighter.codeToHtml(code, {lang: 'js'});
return highlighter.codeToHtml(code, {
lang: 'javascript',
theme: 'github-light',
});
}

0 comments on commit b03a88d

Please sign in to comment.