From c5d5ac26328e5010cbf0d3f65ed9206fbb5e0e02 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 28 Feb 2018 12:28:29 +0100 Subject: [PATCH] Show images in post summaries --- haunt.scm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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) -- 2.39.5