The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/components/basic/MarkdownText.js

19 lines
630 B

import { Box } from '@rocket.chat/fuselage';
import React, { useMemo } from 'react';
import marked from 'marked';
marked.InlineLexer.rules.gfm.strong = /^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/;
marked.InlineLexer.rules.gfm.em = /^__(?=\S)([\s\S]*?\S)__(?!_)|^_(?=\S)([\s\S]*?\S)_(?!_)/;
function MarkdownText({ content, ...props }) {
const options = useMemo(() => ({
gfm: true,
headerIds: false,
}), []);
const __html = useMemo(() => marked(content, options), [content, options]);
return <Box dangerouslySetInnerHTML={{ __html }} withRichContent {...props} />;
}
export default MarkdownText;