X-Git-Url: https://git.jsancho.org/?p=blog.git;a=blobdiff_plain;f=haunt.scm;h=1828bc6f2eedfd49a95ae41e031fd86ff79ac67d;hp=7ad26eebc47d1e48cce23476d47d4f6bd9f05d62;hb=c5d5ac26328e5010cbf0d3f65ed9206fbb5e0e02;hpb=bf75bbf48ffb7e81c8ded9fe740ddc944ccf0c78 diff --git a/haunt.scm b/haunt.scm index 7ad26ee..1828bc6 100644 --- a/haunt.scm +++ b/haunt.scm @@ -89,10 +89,16 @@ (site-post-slug site post) ".html")) (define (get-paragraphs sxml count) - (let ((pars (filter - (lambda (e) (and (pair? e) (eq? (car e) 'p))) - sxml))) - (list-head pars (min count (length pars))))) + (define (getp sxml count res) + (cond ((or (= count 0) (null? sxml)) + res) + ((and (pair? (car sxml)) (eq? (caar sxml) 'p)) + (getp (cdr sxml) (- count 1) (cons (car sxml) res))) + ((and (pair? (car sxml)) (eq? (caar sxml) 'a)) + (getp (cdr sxml) count (cons (car sxml) res))) + (else + (getp (cdr sxml) count res)))) + (reverse (getp sxml count '()))) (define (post-summary post) (or (post-ref post 'summary)