Skip to content

Commit

Permalink
Merge pull request #2951 from andrewbaldwin44/feature/mui-markdown-link
Browse files Browse the repository at this point in the history
Webui Override Markdown HTML Link with MUI Link
  • Loading branch information
cyberw authored Oct 22, 2024
2 parents 3476949 + f0c2296 commit e9a51b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions locust/webui/src/components/Markdown/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Link } from '@mui/material';
import ReactMarkdown from 'react-markdown';

type CustomMarkdownLink = (props: {
href?: string;
children?: React.ReactNode;
}) => React.ReactElement;

export default function Markdown({ content }: { content: string }) {
return (
<ReactMarkdown components={{ a: Link as CustomMarkdownLink }} skipHtml={false}>
{content}
</ReactMarkdown>
);
}
4 changes: 2 additions & 2 deletions locust/webui/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
TableHead,
TableRow,
} from '@mui/material';
import Markdown from 'react-markdown';

import Markdown from 'components/Markdown/Markdown';
import useSortByField, { ISortByFieldOptions } from 'hooks/useSortByField';
import { ITableStructure } from 'types/table.types';
import { roundToDecimalPlaces } from 'utils/number';
Expand Down Expand Up @@ -44,7 +44,7 @@ function TableRowContent({ content, formatter, round, markdown }: ITableRowConte
}

if (markdown) {
return <Markdown skipHtml={false}>{content as string}</Markdown>;
return <Markdown content={content as string} />;
}

return content;
Expand Down

0 comments on commit e9a51b3

Please sign in to comment.