Skip to content

Commit

Permalink
Add syntax highlighting for bash
Browse files Browse the repository at this point in the history
  • Loading branch information
yen223 committed Nov 6, 2024
1 parent 16ba918 commit 17a0842
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
11 changes: 9 additions & 2 deletions app/lib/markdown/syntaxHighlight.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { Highlight, themes } from "prism-react-renderer"

import { Prism } from 'prism-react-renderer'
import bashLang from 'refractor/lang/bash';

type FenceProps = {
children: string;
language?: string;
};

export function Fence({ children, language }: FenceProps) {
bashLang(Prism)
return (
<Highlight code={children.trim()} language={language || ""} theme={themes.vsDark}>
<Highlight
prism={Prism}
code={children.trim()}
language={language || ""}
theme={themes.vsDark}
>
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre style={style}>
{tokens.map((line, i) => (
Expand Down
54 changes: 53 additions & 1 deletion package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
"@remix-run/cloudflare": "2.13.1",
"@remix-run/cloudflare-pages": "2.13.1",
"@remix-run/react": "2.13.1",
"@types/refractor": "3.4.1",
"clsx": "2.1.1",
"headlessui": "0.0.0",
"isbot": "4.1.0",
"js-yaml": "4.1.0",
"prism-react-renderer": "2.4.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"refractor": "4.8.1",
"zod": "3.23.8"
},
"devDependencies": {
Expand Down

0 comments on commit 17a0842

Please sign in to comment.