-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add syntax highlighting to the docs (#49)
- Loading branch information
1 parent
5897c14
commit 1396a8a
Showing
6 changed files
with
235 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from "react"; | ||
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; | ||
import { xonokai } from "react-syntax-highlighter/dist/esm/styles/prism"; | ||
import ReactMarkdown from "react-markdown"; | ||
|
||
function StyledMarkdown(props: { content: string }) { | ||
return ( | ||
<ReactMarkdown | ||
components={{ | ||
code({ node, inline, className, children, ...props }) { | ||
return !inline ? ( | ||
<SyntaxHighlighter | ||
{...props} | ||
children={String(children).replace(/\n$/, "")} | ||
style={xonokai} | ||
language={"jsx"} | ||
PreTag="div" | ||
/> | ||
) : ( | ||
<code {...props} className={className}> | ||
{children} | ||
</code> | ||
); | ||
}, | ||
}} | ||
> | ||
{props.content} | ||
</ReactMarkdown> | ||
); | ||
} | ||
export default StyledMarkdown; |
Oops, something went wrong.