mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix greentext, escape from blockquotes correctly
This commit is contained in:
@@ -151,10 +151,13 @@ const Markdown = ({ content, title }: MarkdownProps) => {
|
|||||||
|
|
||||||
const isInCatalogView = isCatalogView(useLocation().pathname, useParams());
|
const isInCatalogView = isCatalogView(useLocation().pathname, useParams());
|
||||||
|
|
||||||
// retain empty lines
|
|
||||||
const processedContent = useMemo(() => {
|
const processedContent = useMemo(() => {
|
||||||
let md = content;
|
let md = content;
|
||||||
|
// Preserve newlines in code blocks
|
||||||
md = md.replace(/```[\s\S]*?```/g, (m) => m.replace(/\n/g, '\n '));
|
md = md.replace(/```[\s\S]*?```/g, (m) => m.replace(/\n/g, '\n '));
|
||||||
|
// Add an extra newline after blockquote lines
|
||||||
|
md = md.replace(/^(>.*)\n(?!>)/gm, '$1\n\n');
|
||||||
|
// Retain empty lines
|
||||||
md = md.replace(/(?<=\n\n)(?![*-])\n/g, ' \n ');
|
md = md.replace(/(?<=\n\n)(?![*-])\n/g, ' \n ');
|
||||||
return md;
|
return md;
|
||||||
}, [content]);
|
}, [content]);
|
||||||
|
|||||||
Reference in New Issue
Block a user