From 44594a2a8182b31dc9484bdb1d827435d11737af Mon Sep 17 00:00:00 2001 From: Kieran Klukas Date: Sun, 26 Apr 2026 21:47:19 -0400 Subject: [PATCH] feat: add better checks on prettify quantities --- internal/extract/schema/jsonld.go | 11 ++- test-recipe.html | 116 ++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 test-recipe.html diff --git a/internal/extract/schema/jsonld.go b/internal/extract/schema/jsonld.go index 1dc9bb5..063b8ef 100644 --- a/internal/extract/schema/jsonld.go +++ b/internal/extract/schema/jsonld.go @@ -371,22 +371,21 @@ func ParseIngredient(text string) models.Ingredient { func parseIngredient(text string) models.Ingredient { text = strings.TrimSpace(text) - text = prettifyQuantities(text) if m := ingredientRangeRe.FindStringSubmatch(text); len(m) == 4 { - return models.Ingredient{RawText: text, Quantity: m[1], Unit: m[2], Name: m[3]} + return models.Ingredient{RawText: prettifyQuantities(text), Quantity: m[1], Unit: m[2], Name: m[3]} } if m := ingredientFracAdjUnitRe.FindStringSubmatch(text); len(m) == 5 { name := strings.TrimSpace(m[2]) + " " + m[4] - return models.Ingredient{RawText: text, Quantity: m[1], Unit: m[3], Name: name} + return models.Ingredient{RawText: prettifyQuantities(text), Quantity: m[1], Unit: m[3], Name: name} } if m := ingredientFracRe.FindStringSubmatch(text); len(m) == 4 { - return models.Ingredient{RawText: text, Quantity: m[1], Unit: m[2], Name: m[3]} + return models.Ingredient{RawText: prettifyQuantities(text), Quantity: m[1], Unit: m[2], Name: m[3]} } if m := ingredientNoUnitRe.FindStringSubmatch(text); len(m) == 3 { - return models.Ingredient{RawText: text, Quantity: m[1], Name: m[2]} + return models.Ingredient{RawText: prettifyQuantities(text), Quantity: m[1], Name: m[2]} } - return models.Ingredient{RawText: text} + return models.Ingredient{RawText: prettifyQuantities(text)} } var decimalRe = regexp.MustCompile(`\b(\d+\.\d+)\b`) diff --git a/test-recipe.html b/test-recipe.html new file mode 100644 index 0000000..e5823db --- /dev/null +++ b/test-recipe.html @@ -0,0 +1,116 @@ + + + + + + Chili Crisp Fettuccine Alfredo + + + + + +

Chili Crisp Fettuccine Alfredo

+

A spicy twist on classic fettuccine alfredo with crispy chili oil, marinated chicken, and a creamy Parmesan sauce.

+ Chili Crisp Fettuccine Alfredo +

Ingredients

+ +

Instructions

+
    +
  1. Pat chicken breast dry and season with salt to taste, smoked paprika powder, garlic powder, and black pepper powder. Add oil and mix well to combine. Let marinate for 30 minutes.
  2. +
  3. Bring a large pot of generously salted water to a boil. Cook fettuccine until al dente. Reserve 1 cup pasta water, then drain.
  4. +
  5. Heat oil in a pan. Add the marinated chicken and cook for 4-5 minutes per side on medium-high heat depending on thickness. Remove the chicken and set aside.
  6. +
  7. In the same pan, add butter. Once melted, add chili oil and cook for 30 seconds. Add all purpose flour and whisk constantly for 30-40 seconds to cook out the raw taste — do not brown.
  8. +
  9. Pour in heavy whipping cream (room temperature). Add salt to taste, garlic powder, black pepper, dried parsley, and smoked paprika powder. Stir to combine.
  10. +
  11. Simmer gently for 3-4 minutes, stirring, until slightly thickened. Reduce heat to low, then stir in Parmesan cheese (freshly grated) until melted and smooth. Add lemon juice. Taste and adjust salt or lemon as needed.
  12. +
  13. Add the cooked fettuccine to the sauce. Toss gently, adding the reserved pasta water a little at a time until the sauce is silky and coats the pasta well. Slice the rested chicken and add to the pan. Toss again and simmer on low for 1-2 minutes to let everything come together.
  14. +
  15. Garnish with extra Parmesan, parsley, or a pinch of black pepper.
  16. +
+ + -- 2.54.0