|
@@ -14,15 +14,16 @@
|
14
|
14
|
</script>~]
|
15
|
15
|
<script type=\"text/javascript\" src=\"~A~@[?config=~A~]\"></script>")
|
16
|
16
|
|
|
17
|
+(defgeneric mathjax-p (document)
|
|
18
|
+ (:documentation "Test if DOCUMENT requires contains any math-tagged content.")
|
|
19
|
+ (:method ((content content))
|
|
20
|
+ (tag-p "math" content))
|
|
21
|
+ (:method ((index index))
|
|
22
|
+ (and (slot-boundp index 'content)
|
|
23
|
+ (some #'mathjax-p (index-content index)))))
|
|
24
|
+
|
17
|
25
|
(defun enable (&key force config (preset "TeX-AMS-MML_HTMLorMML")
|
18
|
26
|
(location "http://cdn.mathjax.org/mathjax/latest/MathJax.js"))
|
19
|
|
- (labels ((math-post-p (obj)
|
20
|
|
- ;; Would it be better to test against latex than math, here?
|
21
|
|
- (tag-p "math" obj))
|
22
|
|
- (mathjax-p (obj)
|
23
|
|
- (or force
|
24
|
|
- (etypecase obj
|
25
|
|
- (content (math-post-p obj))
|
26
|
|
- (index (some #'math-post-p (index-content obj)))))))
|
|
27
|
+ (flet ((plugin-p (x) (or force (mathjax-p x))))
|
27
|
28
|
(let ((mathjax-header (format nil *mathjax-header* config location preset)))
|
28
|
|
- (add-injection (list mathjax-header #'mathjax-p) :head))))
|
|
29
|
+ (add-injection (list mathjax-header #'plugin-p) :head))))
|