diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2025-05-03 22:59:56 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2025-05-03 22:59:56 +0200 |
commit | 458017a291d200b736efe5d4b8dcb6789eb08b3a (patch) | |
tree | 74aad82c2a138b17e3d75c8290907fb94f01444e /cook/parse.scm | |
parent | 8a221325935df057c89938de69e6393c3aec62d5 (diff) |
cook: add section markers
Diffstat (limited to 'cook/parse.scm')
-rw-r--r-- | cook/parse.scm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cook/parse.scm b/cook/parse.scm index e53ce9f..498b055 100644 --- a/cook/parse.scm +++ b/cook/parse.scm @@ -61,6 +61,11 @@ https://github.com/cooklang/spec/blob/main/EBNF.md note? (text note-text)) +(define-record-type <section> + (make-section name) + section? + (name section-name)) + (define-record-type <recipe> (make-recipe metadata body) recipe? @@ -192,6 +197,12 @@ https://github.com/cooklang/spec/blob/main/EBNF.md (concatenate! x)))))) (make-step (merge-step-strings (concatenate! s))))) + (section ((: "=" (=> c (+ ,any-text-chars)) (or eos ,nl)) + (make-section (string-trim (list->string c) + (lambda (x) + (or (char=? x #\space) + (char=? x #\=))))))) + (metadata ((: bol ">>" (=> k ,(parse-map meta-key string-trim)) (* ,whitespace) ":" (* ,whitespace) @@ -199,7 +210,7 @@ https://github.com/cooklang/spec/blob/main/EBNF.md (* ,whitespace) eol) (make-metadata-line k v))) - (element ((or ,metadata ,comment ,note ,step))) + (element ((or ,metadata ,comment ,note ,section ,step))) (recipe ((=> els (* (: ,element ,(parse-ignore |