From cb41281bc88790605383be498bf5e10d360a043e Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 28 Jan 2023 12:25:40 +0000 Subject: html: Use match instead of car and cdr. * src/guile/skribilo/engine/html.scm (toc): Use match instead of car and cdr. --- src/guile/skribilo/engine/html.scm | 50 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/guile/skribilo/engine/html.scm b/src/guile/skribilo/engine/html.scm index 367eb3c..e9293e6 100644 --- a/src/guile/skribilo/engine/html.scm +++ b/src/guile/skribilo/engine/html.scm @@ -1089,34 +1089,34 @@ (display "") (loop (+ i 1)))))) (define (toc-entry fe level) - (let* ((c (car fe)) - (ch (cdr fe)) - (id (markup-ident c)) - (f (html-file c e))) - (unless (string? id) + (match fe + ((c ch ...) + (let ((id (markup-ident c)) + (f (html-file c e))) + (unless (string? id) (skribe-error 'toc (format #f "invalid identifier '~a'" id) c)) - (display " ") - ;; blank columns - (col level) - ;; number - (format #t "~a" - (html-container-number c e)) - ;; title - (format #t "" - (- 4 level)) - (format #t "" - (if (and (*destination-file*) - (string=? f (*destination-file*))) - "" - (strip-ref-base (or f (*destination-file*) ""))) - (string-canonicalize id)) - (output (markup-option c :title) e) - (display "") - (display "\n") - ;; the children - (for-each (lambda (n) (toc-entry n (+ 1 level))) ch))) + (display " ") + ;; blank columns + (col level) + ;; number + (format #t "~a" + (html-container-number c e)) + ;; title + (format #t "" + (- 4 level)) + (format #t "" + (if (and (*destination-file*) + (string=? f (*destination-file*))) + "" + (strip-ref-base (or f (*destination-file*) ""))) + (string-canonicalize id)) + (output (markup-option c :title) e) + (display "") + (display "\n") + ;; the children + (for-each (lambda (n) (toc-entry n (+ 1 level))) ch))))) (let* ((c (markup-option n :chapter)) (s (markup-option n :section)) -- cgit v1.2.3