From 5ea102615171fb6f682a51a60ad0fce9361cc057 Mon Sep 17 00:00:00 2001
From: kyuno053 <31762247+kyuno053@users.noreply.github.com>
Date: Sat, 22 Aug 2026 19:01:46 +0200
Subject: [PATCH] feat(recipes): adaptateurs RecipeSourceAdapter pour Marmiton,
750g et Manger Bouger (#67)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat(recipes): ajoute un adaptateur RecipeSourceAdapter pour Marmiton
Étend jsonLdRecipeAdapter (json-ld-recipe.ts) plutôt que de dupliquer sa
logique : marmitonAdapter délègue fetchDetail/parse directement à
l'adaptateur générique JSON-LD (une page recette marmiton.org expose un
Recipe schema.org standard), et n'ajoute que ce que l'adaptateur
générique ne peut pas offrir — un list() qui lit l'ItemList schema.org
embarqué sur la page de résultats de recherche de marmiton.org (pagination
via &page=N, fin de résultats détectée via la réponse 404 renvoyée
au-delà de la dernière page).
extractJsonLdBlocks est exporté depuis json-ld-recipe.ts pour être
réutilisé par marmiton.ts sans dupliquer le regex d'extraction des blocs
` block —
+ * same shape as `JSON_LD_SCRIPT_PATTERN` in json-ld-recipe.ts, kept as its
+ * own private copy here rather than sharing that module's export: this one
+ * does textual surgery on the *raw HTML* before `jsonLdRecipeAdapter` ever
+ * sees it (see {@link sanitizeJsonLdBlocks} below), a different concern
+ * from extracting-and-parsing blocks into objects.
+ */
+const JSON_LD_SCRIPT_PATTERN =
+ /(` block every Next.js page ships — the site's own server-rendered hydration data, read instead of scraping HTML for both `list()` (the listing's recipe cards) and `parse()` (backfilling a gap in the detail page's JSON-LD, see {@link extractPortionsFromNextData}). */
+const NEXT_DATA_PATTERN = /` block
+ * a mangerbouger.fr recipe *detail* page carries (verified live across a
+ * sample of 9 recipes — always exactly one, always a bare `Recipe`, never
+ * an `@graph`) — a much narrower pattern than `json-ld-recipe.ts`'s own
+ * `JSON_LD_SCRIPT_PATTERN` (no `g` flag: this module only ever needs the
+ * first/only block, to patch it — see {@link patchRecipeJsonLd}) or
+ * `750g.ts`'s identically-named private copy (which does its own,
+ * different, character-level repair over every block on the page).
+ */
+const JSON_LD_SCRIPT_PATTERN =
+ /(