mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-05-18 07:47:29 -04:00
fix: unparsed ingredients poorly formatted when fed to NLP parser (#7086)
Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com> Co-authored-by: Michael Genson <genson.michael@gmail.com>
This commit is contained in:
committed by
GitHub
parent
449e3baa07
commit
4dd8d836e1
@@ -142,8 +142,24 @@ export function useIngredientTextParser() {
|
||||
return sanitizeIngredientHTML(text);
|
||||
};
|
||||
|
||||
function ingredientToParserString(ingredient: RecipeIngredient): string {
|
||||
if (ingredient.originalText) {
|
||||
return ingredient.originalText;
|
||||
}
|
||||
|
||||
// If the ingredient has no unit and no food, it's unparsed — the note
|
||||
// contains the full ingredient text. Using parseIngredientText would
|
||||
// incorrectly prepend the quantity (e.g. "1 1/2 cup apples").
|
||||
if (!ingredient.unit && !ingredient.food) {
|
||||
return ingredient.note || "";
|
||||
}
|
||||
|
||||
return parseIngredientText(ingredient, 1, false) ?? "";
|
||||
}
|
||||
|
||||
return {
|
||||
useParsedIngredientText,
|
||||
parseIngredientText,
|
||||
ingredientToParserString,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user