Compare commits

..

2 commits

Author SHA1 Message Date
Declan Chidlow
fb7aa08b70
Merge cd4d8eb96d into 478d375125 2024-11-15 13:09:56 +00:00
Paul Makles
478d375125 fix: add try-catch block around md renderer
fix: update recursive match to block numbered lists
2024-11-15 13:09:40 +00:00

View file

@ -185,7 +185,8 @@ const Container = styled.div<{ largeEmoji: boolean }>`
/** /**
* Regex for matching execessive recursion of blockquotes and lists * Regex for matching execessive recursion of blockquotes and lists
*/ */
const RE_RECURSIVE = /(^(?:[>*+-][^\S\r\n]*){5})(?:[>*+-][^\S\r\n]*)+(.*$)/gm; const RE_RECURSIVE =
/(^(?:(?:[>*+-]|\d+\.)[^\S\r\n]*){5})(?:(?:[>*+-]|\d+\.)[^\S\r\n]*)+(.*$)/gm;
/** /**
* Regex for matching multi-line blockquotes * Regex for matching multi-line blockquotes
@ -247,9 +248,13 @@ export default memo(({ content, disallowBigEmoji }: MarkdownProps) => {
const [Content, setContent] = useState<React.ReactElement>(null!); const [Content, setContent] = useState<React.ReactElement>(null!);
useLayoutEffect(() => { useLayoutEffect(() => {
render try {
.process(sanitisedContent) render
.then((file) => setContent(file.result)); .process(sanitisedContent)
.then((file) => setContent(file.result));
} catch (err) {
setContent("Message failed to render." as never);
}
}, [sanitisedContent]); }, [sanitisedContent]);
const largeEmoji = useMemo( const largeEmoji = useMemo(