// Debug heading extraction const file1Content = "# Algorithm Design\n\nThis discusses design patterns"; const file2Content = "This file mentions algorithm somewhere in the body text"; function extractHeadings(content) { const headingMatches = content.match(/^# (.*?)$/gm); if (headingMatches) { return headingMatches.map((h) => h.replace(/^# /, '')); } return []; } console.log("File 1 content:", file1Content); console.log("File 1 headings:", extractHeadings(file1Content)); console.log("File 2 content:", file2Content); console.log("File 2 headings:", extractHeadings(file2Content)); // Check if there's any issue with the regex const allLines1 = file1Content.split('\n'); const allLines2 = file2Content.split('\n'); console.log("File 1 lines:", allLines1); console.log("File 2 lines:", allLines2); // Check each line for heading match allLines1.forEach((line, i) => { const match = line.match(/^# (.*?)$/); console.log(`File 1 line ${i}: "${line}" -> heading match: ${!!match}`); }); allLines2.forEach((line, i) => { const match = line.match(/^# (.*?)$/); console.log(`File 2 line ${i}: "${line}" -> heading match: ${!!match}`); });