import type { CreateRecipeInput } from '../types/recipe.js'; export interface ParsedCopyMeThatRecipe { title: string; sourceUrl?: string; description?: string; imageUrl?: string; tags: string[]; made: boolean; rating?: number; servings?: string; ingredients: string[]; instructions: string[]; notes?: string; } /** * Parses CopyMeThat HTML export format. * Supports both single-recipe HTML and multi-recipe exports. */ export class CopyMeThatHtmlParser { /** * Parse all recipes from a CopyMeThat HTML export file. */ parseRecipes(html: string): ParsedCopyMeThatRecipe[] { const recipeBlocks = this.extractRecipeBlocks(html); console.log(`[CopyMeThatHtmlParser] Found ${recipeBlocks.length} recipe blocks`); const parsed = recipeBlocks.map(block => this.parseRecipeBlock(block)).filter(r => r !== null) as ParsedCopyMeThatRecipe[]; console.log(`[CopyMeThatHtmlParser] Successfully parsed ${parsed.length} recipes`); return parsed; } /** * Extract individual recipe HTML blocks from the document. */ private extractRecipeBlocks(html: string): string[] { const blocks: string[] = []; // Match with flexible whitespace around = and quotes const recipeRegex = /