summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-10 17:00:32 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-10 17:00:32 +0100
commitd5da001a3df092274f86b0628d574b6d5e16e622 (patch)
tree814b7f2136bb28f42640b301e314dcc928b91f0f
parentc32cf7a8452549a6b4870301c1451679ecb06908 (diff)
Properly format comments.
-rw-r--r--mulkcms.lisp14
1 files changed, 13 insertions, 1 deletions
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 ""