diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2025-08-19 22:38:50 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2025-08-19 22:40:48 +0200 |
commit | 121b1328324b5eb77a19c1d2f6080482bd4e07fa (patch) | |
tree | d7eb0991f3eaa35dbcc4eda46006c379ced5b787 /cook/html.scm | |
parent | 252a4f525210d1b5a0dca71c337695a117c06156 (diff) |
html: WIP: Add html output command
Diffstat (limited to 'cook/html.scm')
-rw-r--r-- | cook/html.scm | 35 |
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)))) |