Add Markdown plugin with 3mbd's code highlighting support.
This commit is contained in:
parent
49e1504477
commit
221ea46288
3 changed files with 17 additions and 12 deletions
3
TODO
3
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.
|
||||
|
|
|
@ -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))))
|
||||
|
|
|
@ -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."
|
||||
|
|
Loading…
Add table
Reference in a new issue