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

mathjax.lisp 923B

12345678910111213141516171819202122232425262728293031
  1. (defpackage :coleslaw-mathjax
  2. (:use :cl)
  3. (:export #:enable)
  4. (:import-from :coleslaw #:add-injection
  5. #:content
  6. #:index
  7. #:content-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 (obj)
  22. (member "math" (content-tags obj) :test #'string=))
  23. (mathjax-p (obj)
  24. (etypecase obj
  25. (content (math-post-p obj))
  26. (index (some #'math-post-p (index-posts obj))))))
  27. (add-injection (list *mathjax-header* #'mathjax-p) :head)))