From f030a32679e7291eeb3ec4925a6354767bed3694 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 1 Jun 2025 22:02:24 +0200 Subject: Add content to recipe page --- src/chef/utils.clj | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/chef/utils.clj') diff --git a/src/chef/utils.clj b/src/chef/utils.clj index c2c6bc1..7f476a2 100644 --- a/src/chef/utils.clj +++ b/src/chef/utils.clj @@ -40,3 +40,16 @@ category-parents (map #(:categories/name %)) (cstr/join " > "))) + +(defn parse-ingredients [s] + (->> s + (re-seq #"([A-z0-9 ]*)=([0-9]*) ?([A-z]*)") + (map #(hash-map :description (nth % 1) + :amount (Integer/parseInt (nth % 2)) + :unit (nth % 3))))) + +(defn valid-ingredients? [s] + (and (string? s) + (->> s + (re-matches #"(([A-z0-9 ]*)=([0-9]*) ?([A-z]*)\n?)*") + some?))) -- cgit v1.2.3