From 121b1328324b5eb77a19c1d2f6080482bd4e07fa Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Tue, 19 Aug 2025 22:38:50 +0200 Subject: html: WIP: Add html output command --- cook/html.scm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 cook/html.scm (limited to 'cook/html.scm') 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 + (($ text) + `(p ,text)) + (($
name) + `(h1 ,name)) + (($ elements) + `(li ,@(map expand elements))) + (($ quantity unit) + (list "(" (number->string quantity) unit ")")) + (($ (or ) name amount) + `(span ,@(if name (list name) '()) + ,@(if amount (expand amount) '()))) + (($ metadata body) + `((@raw "") + (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)))) -- cgit v1.2.3