From d5da001a3df092274f86b0628d574b6d5e16e622 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 10 Mar 2011 17:00:32 +0100 Subject: Properly format comments. --- mulkcms.lisp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'mulkcms.lisp') diff --git a/mulkcms.lisp b/mulkcms.lisp index 12b9b7e..13aea8d 100644 --- a/mulkcms.lisp +++ b/mulkcms.lisp @@ -57,13 +57,25 @@ :comments-link "" :comments-heading "Comments"))) +(defun format-comment-content (text) + ;; Taken from Mulkblog. + (with-html-output-to-string (out) + (loop for last-position = 0 then (cadr matches) + for matches = (ppcre:all-matches "(\\n|\\r|\\r\\n)(\\n|\\r|\\r\\n)+" + text) + then (cddr matches) + while (not (endp matches)) + do (htm (:p (esc (subseq text last-position (car matches))))) + finally + (htm (:p (esc (subseq text last-position))))))) + (defun paramify-comment (comment-revision-data) (destructuring-bind (crid comment date content author format status article-revision &rest args) comment-revision-data (declare (ignore args crid article-revision status format comment)) (list :publishing-date date - :body content + :body (format-comment-content content) :author author ;;FIXME :link "" -- cgit v1.2.3