mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
Update markdown.tsx
This commit is contained in:
@@ -153,12 +153,14 @@ const Markdown = ({ content, title }: MarkdownProps) => {
|
|||||||
|
|
||||||
const processedContent = useMemo(() => {
|
const processedContent = useMemo(() => {
|
||||||
let md = content;
|
let md = content;
|
||||||
// Preserve newlines in code blocks
|
if (md) {
|
||||||
md = md.replace(/```[\s\S]*?```/g, (m) => m.replace(/\n/g, '\n '));
|
// Preserve newlines in code blocks
|
||||||
// Add an extra newline after blockquote lines
|
md = md.replace(/```[\s\S]*?```/g, (m) => m.replace(/\n/g, '\n '));
|
||||||
md = md.replace(/^(>.*)\n(?!>)/gm, '$1\n\n');
|
// Add an extra newline after blockquote lines
|
||||||
// Retain empty lines
|
md = md.replace(/^(>.*)\n(?!>)/gm, '$1\n\n');
|
||||||
md = md.replace(/(?<=\n\n)(?![*-])\n/g, ' \n ');
|
// Retain empty lines
|
||||||
|
md = md.replace(/(?<=\n\n)(?![*-])\n/g, ' \n ');
|
||||||
|
}
|
||||||
return md;
|
return md;
|
||||||
}, [content]);
|
}, [content]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user