Skip to content

Commit

Permalink
Revert "fix: refine regex to handle newlines after indentation groups"
Browse files Browse the repository at this point in the history
This reverts commit e050bd6.
  • Loading branch information
tshuli committed Nov 23, 2023
1 parent d98f05c commit 10955ed
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions frontend/src/components/MarkdownText/MarkdownText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,7 @@ export const MarkdownText = ({
const processedRawString = useMemo(() => {
// Create new line nodes for every new line in raw string so new lines gets rendered.
if (multilineBreaks) {
/**
* Matching new lines that are not preceded by a token that indents.
*
* (?<!{regex}): negative lookbehind to ensure that the following regex does not match
*
* (-|\d+\.|\*): matching character tokens that indents
* -: "-"
* *: "*",
* \d+ : "1.", "2.", etc.
*
* \s: whitespace following the token, indentation groups must start with token followed by a whitespace character
*
* .*: any character, any number of times, this is the actual text content of the line
*
* \n: new line character
*
* \n: the new line character that we will want markdown to render as a new line
*/
return children.replace(/(?<!(-|\d+\.|\*)\s.*\n)\n/gi, '&nbsp; \n')
return children.replace(/\n/gi, '&nbsp; \n')
}
return children
}, [children, multilineBreaks])
Expand Down

0 comments on commit 10955ed

Please sign in to comment.