fix: tidyMarkdown

This commit is contained in:
Yanlong Wang 2024-05-09 11:32:26 +08:00
parent 6b6774f43b
commit 59f807cb7c
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -1,9 +1,6 @@
export function tidyMarkdown(markdown: string): string {
const lines = markdown.split('\n');
const processedLines = lines.map((line) => {
// Remove leading spaces from each line
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) => {
text = text.replace(/\s+/g, ' ').trim();