summaryrefslogtreecommitdiff
path: root/extension/react-app/src/components/StyledCode.tsx
diff options
context:
space:
mode:
authorNate Sesti <33237525+sestinj@users.noreply.github.com>2023-06-26 17:19:07 -0700
committerGitHub <noreply@github.com>2023-06-26 17:19:07 -0700
commitf4beca92731a81c32aec9c692ec32b78024f5974 (patch)
tree763673980f98664dabb90f22dd7c0f433357e520 /extension/react-app/src/components/StyledCode.tsx
parent292d4d10ce28d720d61f97918c490b0d9cdae9e7 (diff)
parentf2a0ed0fbaf1b4495e76f85995875d7ff2dc8d6f (diff)
downloadsncontinue-f4beca92731a81c32aec9c692ec32b78024f5974.tar.gz
sncontinue-f4beca92731a81c32aec9c692ec32b78024f5974.tar.bz2
sncontinue-f4beca92731a81c32aec9c692ec32b78024f5974.zip
Merge pull request #115 from continuedev/styled-code
adding code syntax highlighting
Diffstat (limited to 'extension/react-app/src/components/StyledCode.tsx')
-rw-r--r--extension/react-app/src/components/StyledCode.tsx19
1 files changed, 19 insertions, 0 deletions
diff --git a/extension/react-app/src/components/StyledCode.tsx b/extension/react-app/src/components/StyledCode.tsx
new file mode 100644
index 00000000..485c70b6
--- /dev/null
+++ b/extension/react-app/src/components/StyledCode.tsx
@@ -0,0 +1,19 @@
+import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
+import { vscDarkPlus as highlightStyle } from "react-syntax-highlighter/dist/esm/styles/prism";
+
+interface StyledCodeProps {
+ children: string;
+ language?: string;
+}
+
+const StyledCode = (props: StyledCodeProps) => (
+ <SyntaxHighlighter
+ customStyle={{ margin: "0" }}
+ style={highlightStyle}
+ language={props.language || "python"}
+ >
+ {(props.children as any).props.children}
+ </SyntaxHighlighter>
+);
+
+export default StyledCode;