ai-app-factory / src /parseTutorial.mts
jbilcke-hf's picture
jbilcke-hf HF staff
initial commit
9c9e5d3
raw
history blame
No virus
426 Bytes
export function parseTutorial(text: string): Array<{ filename: string; content: string }> {
const result: { filename: string; content: string; }[] = [];
const regex = /# In (?:the )?(.*):\n```(?:\w+\n)?([\s\S]*?)```/g;
let match: RegExpExecArray | null;
while ((match = regex.exec(text)) !== null) {
result.push({
filename: match[1],
content: match[2].trim(),
});
}
return result;
}