File size: 491 Bytes
e9674a6
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
export function parseTutorial(text: string): Array<{ filename: string; content: string }> {
  const result: { filename: string; content: string; }[] = [];
  const regex = /#\s+(?:And finally,\s+)?in\s+(?:(?:the|your)\s+)?(.*)(?:, add the following code)?:\n```(?:\w+\n)?([\s\S]*?)```/gi;
  let match: RegExpExecArray | null;
  while ((match = regex.exec(text)) !== null) {
      result.push({
          filename: match[1],
          content: match[2].trim(),
      });
  }
  return result;
}