Skip to content

Commit

Permalink
Fixed the syntax highlighting for JSON and TypeScript with the new Pr…
Browse files Browse the repository at this point in the history
…isma renderer
  • Loading branch information
matt-aitken committed May 23, 2024
1 parent 3a1b0c4 commit ff3cd97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions apps/webapp/app/components/code/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { Clipboard, ClipboardCheck } from "lucide-react";
import type { Language, PrismTheme } from "prism-react-renderer";
import { Highlight } from "prism-react-renderer";
import { Highlight, Prism } from "prism-react-renderer";
import { forwardRef, useCallback, useState } from "react";
import { cn } from "~/utils/cn";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../primitives/Tooltip";
import { Paragraph } from "../primitives/Paragraph";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../primitives/Tooltip";

//This is a fork of https://github.com/mantinedev/mantine/blob/master/src/mantine-prism/src/Prism/Prism.tsx
//it didn't support highlighting lines by dimming the rest of the code, or animations on the highlighting

async function setup() {
(typeof global !== "undefined" ? global : window).Prism = Prism;
//@ts-ignore
await import("prismjs/components/prism-json");
//@ts-ignore
await import("prismjs/components/prism-typescript");
}
setup();

type CodeBlockProps = {
/** Code which will be highlighted */
code: string;
Expand Down
2 changes: 2 additions & 0 deletions apps/webapp/remix.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module.exports = {
"highlight.run",
"random-words",
"superjson",
"prismjs/components/prism-json",
"prismjs/components/prism-typescript",
],
browserNodeBuiltinsPolyfill: { modules: { path: true, os: true, crypto: true } },
watchPaths: async () => {
Expand Down

0 comments on commit ff3cd97

Please sign in to comment.