mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
Added some clarifying comments.
This commit is contained in:
parent
7c181ca3fe
commit
36bcf9c3e2
1 changed files with 4 additions and 0 deletions
|
@ -259,6 +259,7 @@
|
||||||
(len (length headers)))
|
(len (length headers)))
|
||||||
(lambda (h) (- len (length (memq h headers))))))
|
(lambda (h) (- len (length (memq h headers))))))
|
||||||
|
|
||||||
|
;; return a list of (index . link-to-header) for all headers
|
||||||
(define (extract-contents x)
|
(define (extract-contents x)
|
||||||
(match x
|
(match x
|
||||||
(('div ('a ('@ ('name . name)) . _)
|
(('div ('a ('@ ('name . name)) . _)
|
||||||
|
@ -280,6 +281,7 @@
|
||||||
(else
|
(else
|
||||||
'())))
|
'())))
|
||||||
|
|
||||||
|
;; nest the (index . link-to-header)s into ol
|
||||||
(define (get-contents x)
|
(define (get-contents x)
|
||||||
(if (null? x)
|
(if (null? x)
|
||||||
'()
|
'()
|
||||||
|
@ -287,6 +289,7 @@
|
||||||
(let lp ((ls (cdr x)) (parent (car (cdar x))) (kids '()) (res '()))
|
(let lp ((ls (cdr x)) (parent (car (cdar x))) (kids '()) (res '()))
|
||||||
(define (collect)
|
(define (collect)
|
||||||
(cons `(li ,parent ,(get-contents (reverse kids))) res))
|
(cons `(li ,parent ,(get-contents (reverse kids))) res))
|
||||||
|
;; take a span of all sub-headers, recurse and repeat on next span
|
||||||
(cond
|
(cond
|
||||||
((null? ls)
|
((null? ls)
|
||||||
`(ol ,@(reverse (collect))))
|
`(ol ,@(reverse (collect))))
|
||||||
|
@ -315,6 +318,7 @@ div#footer {padding-bottom: 50px}
|
||||||
(div (@ (id . "menu"))
|
(div (@ (id . "menu"))
|
||||||
,(let ((contents (get-contents (extract-contents x))))
|
,(let ((contents (get-contents (extract-contents x))))
|
||||||
(match contents
|
(match contents
|
||||||
|
;; flatten if we have only a single heading
|
||||||
(('ol (li y sections ...))
|
(('ol (li y sections ...))
|
||||||
sections)
|
sections)
|
||||||
(else contents))))
|
(else contents))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue