Skip to content

Commit

Permalink
custom highlighter.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradgarropy committed Nov 29, 2023
1 parent bb55e8e commit dc5fd31
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
8 changes: 7 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
"shiki": "^0.14.5",
"slugify": "^1.6.6",
"unified": "^10.1.1",
"unist-util-visit": "^4.1.2"
"unist-util-visit": "^4.1.2",
"vscode-textmate": "^9.0.0"
},
"devDependencies": {
"@babel/preset-env": "^7.20.2",
Expand Down
6 changes: 0 additions & 6 deletions remix.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ const config = {
appDirectory: "src",
ignoredRouteFiles: ["**/.*"],
future: {},
serverDependenciesToBundle: [
"shiki",
"shiki/**/*",
"shiki/languages/**/*",
"shiki/themes/**/*",
],
serverModuleFormat: "esm",
}

Expand Down
9 changes: 9 additions & 0 deletions src/utils/markdown.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import remarkInlineLinks from "remark-inline-links"
import remarkParse from "remark-parse"
import remarkRehype from "remark-rehype"
import remarkUnwrapImages from "remark-unwrap-images"
import {getHighlighter} from "shiki"
import {unified} from "unified"

import {codesandboxTransformer} from "~/transformers/codesandbox"
Expand Down Expand Up @@ -51,6 +52,14 @@ const transformMarkdown = async (markdown: string): Promise<string> => {
const options: Options = {
theme: json5.parse(theme),
keepBackground: true,
getHighlighter: () =>
getHighlighter({
theme: json5.parse(theme),
paths: {
languages: path.join(process.cwd(), "src/shiki/languages"),
themes: path.join(process.cwd(), "src/shiki/themes"),
},
}),
}

const processor = unified()
Expand Down

0 comments on commit dc5fd31

Please sign in to comment.