coleslaw/plugins/mathjax.lisp

31 lines
923 B
Common Lisp
Raw Normal View History

(defpackage :coleslaw-mathjax
2012-09-15 17:39:00 -04:00
(:use :cl)
(:export #:enable)
2012-09-15 17:39:00 -04:00
(:import-from :coleslaw #:add-injection
2013-01-02 13:04:20 -05:00
#:content
2012-09-15 17:39:00 -04:00
#:index
2013-01-02 13:04:20 -05:00
#:content-tags
2012-09-15 17:39:00 -04:00
#:index-posts))
2011-04-19 13:36:17 -04:00
(in-package :coleslaw-mathjax)
(defvar *mathjax-header* "<script type=\"text/x-mathjax-config\">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$$','$$']]
}
});
</script>
<script type=\"text/javascript\"
src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML\">
</script>")
(defun enable ()
2013-01-02 13:04:20 -05:00
(labels ((math-post-p (obj)
(member "math" (content-tags obj) :test #'string=))
(mathjax-p (obj)
(etypecase obj
(content (math-post-p obj))
(index (some #'math-post-p (index-posts obj))))))
2012-09-15 17:39:00 -04:00
(add-injection (list *mathjax-header* #'mathjax-p) :head)))