fix: tidyMarkdown

This commit is contained in:
Yanlong Wang 2024-05-09 11:25:51 +08:00
parent 4bee36ed4a
commit 6b6774f43b
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -2,7 +2,7 @@ export function tidyMarkdown(markdown: string): string {
const lines = markdown.split('\n');
const processedLines = lines.map((line) => {
// Remove leading spaces from each line
line = line.trimStart();
line = line.replace(/^[ \t]+/, '');
// Handle complex broken links with text and optional images
line = line.replace(/\[\s*([^\]\n!]*?)\s*(?:!\[([^\]]*)\]\((.*?)\))?\s*\]\s*\(\s*([^)\n]+)\s*\)/g, (match, text, alt, imgUrl, linkUrl) => {