fix: normalize url

This commit is contained in:
Han Xiao 2025-03-17 14:55:47 +08:00
parent 01705291c4
commit 767c0b37ef

View File

@ -223,7 +223,6 @@ export function smartMergeStrings(str1: string, str2: string): string {
}
}
export function fixCodeBlockIndentation(markdownText: string): string {
// Track the state of code blocks and their indentation
const lines = markdownText.split('\n');
@ -256,8 +255,21 @@ export function fixCodeBlockIndentation(markdownText: string): string {
result.push(line);
}
}
} else if (codeBlockStack.length > 0) {
// Inside a code block - adjust indentation to match opening fence
const openingBlock = codeBlockStack[codeBlockStack.length - 1];
// Only adjust non-empty lines
if (line.trim().length > 0) {
// Remove any existing indentation and apply the opening fence indentation
const trimmedLine = line.trimStart();
result.push(`${openingBlock.indent}${trimmedLine}`);
} else {
// For empty lines, just keep them as is
result.push(line);
}
} else {
// Not a code fence line, just add it as is
// Not in a code block, just add it as is
result.push(line);
}
}