skribilo-bugs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#61306: [PATCH 4/5] html: Use match instead of car and cdr.


From: Arun Isaac
Subject: bug#61306: [PATCH 4/5] html: Use match instead of car and cdr.
Date: Mon, 6 Feb 2023 00:08:18 +0000

* 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(-)

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 "<td></td>")
                             (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 " <tr>")
-                   ;; blank columns
-                   (col level)
-                   ;; number
-                   (format #t "<td valign=\"top\" align=\"left\">~a</td>"
-                           (html-container-number c e))
-                   ;; title
-                   (format #t "<td colspan=\"~a\" width=\"100%\">"
-                           (- 4 level))
-                   (format #t "<a href=\"~a#~a\">"
-                           (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 "</a></td>")
-                   (display "</tr>\n")
-                   ;; the children
-                   (for-each (lambda (n) (toc-entry n (+ 1 level))) ch)))
+                    (display " <tr>")
+                    ;; blank columns
+                    (col level)
+                    ;; number
+                    (format #t "<td valign=\"top\" align=\"left\">~a</td>"
+                            (html-container-number c e))
+                    ;; title
+                    (format #t "<td colspan=\"~a\" width=\"100%\">"
+                            (- 4 level))
+                    (format #t "<a href=\"~a#~a\">"
+                            (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 "</a></td>")
+                    (display "</tr>\n")
+                    ;; the children
+                    (for-each (lambda (n) (toc-entry n (+ 1 level))) ch)))))
 
              (let* ((c (markup-option n :chapter))
                     (s (markup-option n :section))
-- 
2.38.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]