diff options
author | Tim <contact@bytim.eu> | 2025-06-01 22:02:24 +0200 |
---|---|---|
committer | Tim <contact@bytim.eu> | 2025-06-01 22:02:24 +0200 |
commit | f030a32679e7291eeb3ec4925a6354767bed3694 (patch) | |
tree | 5bf5f32dc45767319f63029f0d01696b20881e2c /src/chef/utils.clj | |
parent | ffb5d0b740e3fa23143ad89dab29a44d5b0acd34 (diff) | |
download | chef-f030a32679e7291eeb3ec4925a6354767bed3694.tar.xz chef-f030a32679e7291eeb3ec4925a6354767bed3694.zip |
Add content to recipe page
Diffstat (limited to 'src/chef/utils.clj')
-rw-r--r-- | src/chef/utils.clj | 13 |
1 files changed, 13 insertions, 0 deletions
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?))) |