Flexible Lisp Blogware. Fork for personal use. Mirrored from https://github.com/kingcons/coleslaw originally.

mathjax.lisp 929B

12345678910111213141516171819202122232425262728293031
  1. (defpackage :coleslaw-mathjax
  2. (:use :cl)
  3. (:export #:enable)
  4. (:import-from :coleslaw #:add-injection
  5. #:post
  6. #:index
  7. #:post-tags
  8. #:index-posts))
  9. (in-package :coleslaw-mathjax)
  10. (defvar *mathjax-header* "<script type=\"text/x-mathjax-config\">
  11. MathJax.Hub.Config({
  12. tex2jax: {
  13. inlineMath: [['$$','$$']]
  14. }
  15. });
  16. </script>
  17. <script type=\"text/javascript\"
  18. src=\"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML\">
  19. </script>")
  20. (defun enable ()
  21. (labels ((math-post-p (post)
  22. (member "math" (post-tags post) :test #'string=))
  23. (mathjax-p (content)
  24. (etypecase content
  25. (post (math-post-p content))
  26. (index (some #'math-post-p (index-posts content))))))
  27. (add-injection (list *mathjax-header* #'mathjax-p) :head)))