-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Innovation time - Github markdown model card details code highlighting #1581
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { useTheme } from '@mui/material/styles' | |
import Typography from '@mui/material/Typography' | ||
import ReactMarkdown from 'markdown-to-jsx' | ||
import { useMemo } from 'react' | ||
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' | ||
|
||
export type MarkdownDisplayProps = { | ||
children: string | ||
|
@@ -99,6 +100,24 @@ export default function MarkdownDisplay({ children }: MarkdownDisplayProps) { | |
/> | ||
), | ||
}, | ||
code: { | ||
component: ({ children, ...props }: any) => { | ||
const language = props.className ? props.className.replace('lang-', '') : '' | ||
|
||
return ( | ||
<Box | ||
component='code' | ||
sx={{ | ||
backgroundColor: theme.palette.grey[200], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use a theme colour that works in both light and dark modes. A static colour will not work for both. |
||
fontFamily: 'monospace', | ||
}} | ||
{...props} | ||
> | ||
{language ? <SyntaxHighlighter language={language}>{children}</SyntaxHighlighter> : children} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check that all colours used by this package conform to accessibility contrast requirements for both light and dark mode themes. |
||
</Box> | ||
) | ||
}, | ||
}, | ||
table: { | ||
component: (props: any) => ( | ||
<div style={{ overflowX: 'auto' }}> | ||
|
@@ -108,7 +127,7 @@ export default function MarkdownDisplay({ children }: MarkdownDisplayProps) { | |
}, | ||
}, | ||
}), | ||
[theme.palette.container.main, theme.palette.markdownBorder.main], | ||
[theme.palette.container.main, theme.palette.grey, theme.palette.markdownBorder.main], | ||
) | ||
|
||
return <ReactMarkdown options={options}>{children}</ReactMarkdown> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect there to be accompanying
package-lock.json
changes with installing a new package. Make sure those changes are also committed