Skip to content

Commit

Permalink
fix: add try-catch block around md renderer
Browse files Browse the repository at this point in the history
fix: update recursive match to block numbered lists
  • Loading branch information
insertish committed Nov 15, 2024
1 parent cb6296a commit 478d375
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/markdown/RemarkRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ const Container = styled.div<{ largeEmoji: boolean }>`
/**
* 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
Expand Down Expand Up @@ -247,9 +248,13 @@ export default memo(({ content, disallowBigEmoji }: MarkdownProps) => {
const [Content, setContent] = useState<React.ReactElement>(null!);

useLayoutEffect(() => {
render
.process(sanitisedContent)
.then((file) => setContent(file.result));
try {
render
.process(sanitisedContent)
.then((file) => setContent(file.result));
} catch (err) {
setContent("Message failed to render." as never);
}
}, [sanitisedContent]);

const largeEmoji = useMemo(
Expand Down

0 comments on commit 478d375

Please sign in to comment.