test: add milkdown markdown roundtrip integration coverage

Co-authored-by: rfc1437 <774975+rfc1437@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-17 06:49:38 +00:00
parent c3e15034f5
commit 54a367d423
4 changed files with 126 additions and 7 deletions

View File

@@ -37,3 +37,37 @@ export function unescapeMacroSyntax(markdown: string): string {
return result;
}
const unorderedListItemPattern = /^\s{0,3}[-+*]\s/;
const orderedListItemPattern = /^\s{0,3}\d+\.\s/;
function getListLineType(line: string): 'ordered' | 'unordered' | null {
if (unorderedListItemPattern.test(line)) return 'unordered';
if (orderedListItemPattern.test(line)) return 'ordered';
return null;
}
export function normalizeMilkdownMarkdown(markdown: string): string {
const unescaped = unescapeMacroSyntax(markdown);
const lines = unescaped.split('\n');
const normalized: string[] = [];
for (let i = 0; i < lines.length; i += 1) {
const line = lines[i];
const previousListType = i > 0 ? getListLineType(lines[i - 1]) : null;
const nextListType = i < lines.length - 1 ? getListLineType(lines[i + 1]) : null;
if (line === '' && previousListType !== null && previousListType === nextListType) {
continue;
}
if (line === '>') {
normalized.push('> ');
continue;
}
normalized.push(line);
}
return normalized.join('\n');
}