diff --git a/src/components/doc-data.ts b/src/components/doc-data.ts index 350ca8b..6bc82e5 100644 --- a/src/components/doc-data.ts +++ b/src/components/doc-data.ts @@ -13,7 +13,9 @@ export interface DocEntry { /** Splits frontmatter and markdown body from a raw .md string. */ function parseFrontmatter(raw: string): Record | null { - const match = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/); + // Handle CRLF line endings by normalizing to LF first + const normalized = raw.replace(/\r\n/g, "\n"); + const match = normalized.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/); if (!match) return null; try { return yaml.load(match[1]) as Record; @@ -23,7 +25,8 @@ function parseFrontmatter(raw: string): Record | null { } function getBody(raw: string): string { - const match = raw.match(/^---\n[\s\S]*?\n---\n?([\s\S]*)$/); + const normalized = raw.replace(/\r\n/g, "\n"); + const match = normalized.match(/^---\n[\s\S]*?\n---\n?([\s\S]*)$/); return match ? match[1] : raw; }