({ className, children }: Props)
| 16 | children: string |
| 17 | } |
| 18 | export const ArticleMarkdown = ({ className, children }: Props) => { |
| 19 | const theme = useTheme() |
| 20 | |
| 21 | return ( |
| 22 | <MarkdownContent> |
| 23 | <ReactMarkdown |
| 24 | className={cx(styles.articleMarkdown, className)} |
| 25 | remarkPlugins={[gfm as any]} |
| 26 | // This makes it so that HTML inside that `children`, as a string, |
| 27 | // is preserved and left alone. |
| 28 | rehypePlugins={[rehypeRaw]} |
| 29 | components={{ |
| 30 | // eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 31 | code: ({ node, inline, className, children, ...props }) => { |
| 32 | const match = /language-(\w+)/.exec(className || '') |
| 33 | return !inline && match ? ( |
| 34 | <SyntaxHighlighter |
| 35 | style={theme.colorScheme === 'dark' ? vscDarkPlus : vs} |
| 36 | language={match[1]} |
| 37 | PreTag="div" |
| 38 | children={String(children).replace(/\n$/, '')} |
| 39 | {...(props as any)} |
| 40 | /> |
| 41 | ) : ( |
| 42 | <code className={className} {...props}> |
| 43 | {children} |
| 44 | </code> |
| 45 | ) |
| 46 | }, |
| 47 | }} |
| 48 | > |
| 49 | {children} |
| 50 | </ReactMarkdown> |
| 51 | </MarkdownContent> |
| 52 | ) |
| 53 | } |
nothing calls this directly
no test coverage detected