From 3d48daede7b5f7268382d6c9a1ff1289db36825b Mon Sep 17 00:00:00 2001 From: Tahar Amin Touzi <128868336+amintt2@users.noreply.github.com> Date: Sat, 27 Dec 2025 22:12:44 +0100 Subject: [PATCH] handle both Unix and Windows line endings - Changed split('\n') to split(/\r?\n/) to handle both Unix and Windows line endings - Added .trim() to each line to remove any remaining whitespace including \r --- src/lib/product-loader.ts | 44 ++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/lib/product-loader.ts b/src/lib/product-loader.ts index 39508a9..299f0b9 100644 --- a/src/lib/product-loader.ts +++ b/src/lib/product-loader.ts @@ -122,20 +122,33 @@ export function parseProductRoadmap(md: string): ProductRoadmap | null { try { const sections: Section[] = [] - // Match sections with pattern ### N. Title - const sectionMatches = [...md.matchAll(/### (\d+)\.\s*(.+)\n+([\s\S]*?)(?=\n### |\n## |\n#[^#]|$)/g)] - - for (const match of sectionMatches) { - const order = parseInt(match[1], 10) - const title = match[2].trim() - const description = match[3].trim() - - sections.push({ - id: slugify(title), - title, - description, - order, - }) + // Split by lines and parse manually for more reliability + // Handle both Unix (\n) and Windows (\r\n) line endings + const lines = md.split(/\r?\n/) + + for (let i = 0; i < lines.length; i++) { + const line = lines[i].trim() // Trim to remove any remaining whitespace + + // Match pattern: ### N. Title + const match = line.match(/^###\s+(\d+)\.\s*(.+)$/) + + if (match) { + const order = parseInt(match[1], 10) + const title = match[2].trim() + + // Get description from next non-empty line + let description = '' + if (i + 1 < lines.length) { + description = lines[i + 1].trim() + } + + sections.push({ + id: slugify(title), + title, + description, + order, + }) + } } // Sort by order @@ -146,7 +159,8 @@ export function parseProductRoadmap(md: string): ProductRoadmap | null { } return { sections } - } catch { + } catch (error) { + console.error('[Parser] Error:', error) return null } }