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