diff --git a/TODO b/TODO index bc7dd78..6fb3d1a 100644 --- a/TODO +++ b/TODO @@ -13,8 +13,7 @@ Plugins? Injection support for HEAD and BODY. What about predicate-based injecti How is it served? Hunchentoot, Lighttpd, S3, whomever! TODO: -; after that, focus on markdown support, injections for code highlighting and latex - +; test mathjax+markdown ; doc themes and plugins ; fix plugins: s3 ;; Incremental compile: only "touched" posts+tags+months. By-20 must be redone, of course. diff --git a/plugins/markdown.lisp b/plugins/markdown.lisp index db650c5..519e993 100644 --- a/plugins/markdown.lisp +++ b/plugins/markdown.lisp @@ -1,9 +1,12 @@ (eval-when (:compile-toplevel) - (ql:quickload '3mbd)) + (ql:quickload '(3bmd 3bmd-ext-code-blocks))) (defpackage :coleslaw-md (:use :cl :coleslaw)) (in-package :coleslaw-md) - +(defmethod render-content (text (format (eql :md))) + (let ((3mbd-code-blocks:*code-blocks* t)) + (with-output-to-string (str) + (3bmd:parse-string-and-print-to-stream text str)))) diff --git a/src/posts.lisp b/src/posts.lisp index e32ea7e..63cd746 100644 --- a/src/posts.lisp +++ b/src/posts.lisp @@ -48,19 +48,22 @@ (unless (string= (read-line in) ";;;;;") (error "The provided file lacks the expected header."))) (parse-field (str) - (nth-value 1 (cl-ppcre:scan-to-strings "[a-zA-Z]+: (.*)" str)))) + (nth-value 1 (cl-ppcre:scan-to-strings "[a-zA-Z]+: (.*)" str))) + (slurp-remainder () + (read-sequence (make-string (- (file-length in) (file-position in))) + in :start (file-position in)))) (check-header) (let ((args (loop for field in '("title" "tags" "date" "format") for line = (read-line in nil) appending (list (make-keyword (string-upcase field)) (aref (parse-field line) 0))))) - (check-header) - (setf (getf args :tags) (cl-ppcre:split ", " (getf args :tags)) - (getf args :format) (make-keyword (string-upcase (getf args :format)))) - (apply 'make-instance 'post - (append args (list :content (render-content (read-line in nil) - (getf args :format)) - :slug (slugify (getf args :title)))))))) + (check-header) + (setf (getf args :tags) (cl-ppcre:split ", " (getf args :tags)) + (getf args :format) (make-keyword (string-upcase (getf args :format)))) + (apply 'make-instance 'post + (append args (list :content (render-content (slurp-remainder) + (getf args :format)) + :slug (slugify (getf args :title)))))))) (defun write-post (post &key prev next) "Write out the HTML for POST in SLUG.html."