({ node, className, children, ...props }: CodeProps)
| 35 | ); |
| 36 | }, |
| 37 | code({ node, className, children, ...props }: CodeProps) { |
| 38 | const match = /language-(\w+)/.exec(className || ""); |
| 39 | const multiline = typeof children === "string" && children.match(/\n/); |
| 40 | return ( |
| 41 | <> |
| 42 | {multiline && match && ( |
| 43 | <div className="markdown-code-block relative"> |
| 44 | <SyntaxHighlighter |
| 45 | className="code-viewer" |
| 46 | style={{ |
| 47 | ...defaultStyle, |
| 48 | 'code[class*="language-"]': { |
| 49 | ...defaultStyle['code[class*="language-"]'], |
| 50 | fontFamily: "'Fira Code', monospace", |
| 51 | whiteSpace: "pre", |
| 52 | background: "transparent", |
| 53 | }, |
| 54 | }} |
| 55 | customStyle={{ |
| 56 | padding: "28px 25px", |
| 57 | margin: "0 0 20px", |
| 58 | overflow: "auto", |
| 59 | background: "#252525", |
| 60 | borderRadius: "15px", |
| 61 | fontSize: "14px", |
| 62 | }} |
| 63 | language={match[1]} |
| 64 | PreTag="div" |
| 65 | {...props} |
| 66 | > |
| 67 | {String(children).replace(/\n$/, "")} |
| 68 | </SyntaxHighlighter> |
| 69 | <CopyButton |
| 70 | text={children} |
| 71 | sx={{ |
| 72 | position: "absolute", |
| 73 | top: ["13px", "22px"], |
| 74 | right: ["12px", "17px"], |
| 75 | color: "#fff", |
| 76 | }} |
| 77 | /> |
| 78 | </div> |
| 79 | )} |
| 80 | {multiline && !match && ( |
| 81 | <pre className={className} {...props}> |
| 82 | {children} |
| 83 | </pre> |
| 84 | )} |
| 85 | {!multiline && ( |
| 86 | <code className={clsx(className)} {...props}> |
| 87 | {children} |
| 88 | </code> |
| 89 | )} |
| 90 | </> |
| 91 | ); |
| 92 | }, |
| 93 | }; |
| 94 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected