summaryrefslogtreecommitdiff
path: root/cook/html.scm
diff options
context:
space:
mode:
Diffstat (limited to 'cook/html.scm')
-rw-r--r--cook/html.scm35
1 files changed, 35 insertions, 0 deletions
diff --git a/cook/html.scm b/cook/html.scm
new file mode 100644
index 0000000..0f8a501
--- /dev/null
+++ b/cook/html.scm
@@ -0,0 +1,35 @@
+;; TODO
+(define (expand x)
+ (match x
+ (($ <note> text)
+ `(p ,text))
+ (($ <section> name)
+ `(h1 ,name))
+ (($ <step> elements)
+ `(li ,@(map expand elements)))
+ (($ <amount> quantity unit)
+ (list "(" (number->string quantity) unit ")"))
+ (($ (or <ingredient> <cookware> <timer>) name amount)
+ `(span ,@(if name (list name) '())
+ ,@(if amount (expand amount) '())))
+ (($ <recipe> metadata body)
+ `((@raw "<!DOCTYPE html>")
+ (html (body (ol ,@(expand body))))))
+ ((? list? x)
+ (map expand x))
+ ((? string? x)
+ x)
+ (else "")))
+
+(define (recipe->html recipe)
+ (let ((ingredients (recipe-ingredients recipe))
+ (cookware (recipe-cookware recipe))
+ (timers (recipe-timers recipe)))
+ #;(for-each (lambda (x)
+ (display (ingredient-name x))
+ (display ": ")
+ (when (ingredient-amount x)
+ (display (amount-quantity (ingredient-amount x)))
+ (display (amount-unit (ingredient-amount x))))
+ (newline)) ingredients)
+ (sxml->xml (expand recipe))))