Added options to MathJax plugin, also updated documentation

This commit is contained in:
Willem Rein Oudshoorn 2013-04-03 18:27:30 +02:00
parent 9bc2e55d58
commit 3afb6e29e4
2 changed files with 35 additions and 9 deletions

View file

@ -22,6 +22,14 @@
**Example**: ```(mathjax)```
### Options
`:force`, when specified with a true value, will force the inclusion of MathJax, even if no posts are tagged "math". Default value is `nil`.
`:mathjax-url` specifies the location of the `MathJax.js`. The default value is `"http://cdn.mathjax.org/mathjax/latest/MathJax.js"`. This is useful if you want to force a specific value of MathJax, or if you have a local copy of MathJax and want to use that version.
`:config` allows the specification of the config parameter of `MathJax.js`. The default value is `"TeX-AMS-MML_HTMLorMML"`.
## ReStructuredText
**Description**: Some people really like [ReStructuredText](http://docutils.sourceforge.net/rst.html). Who knows why? But it only took one method to add, so yeah! Just create a post with ```format: rst``` and the plugin will do the rest.

View file

@ -9,22 +9,40 @@
(in-package :coleslaw-mathjax)
(defvar *mathjax-header* "<script type=\"text/x-mathjax-config\">
(defvar *mathjax-config-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 ()
(defvar *mathjax-load-header-no-config* "<script type=\"text/javascript\"
src=\"~A\">
</script>
")
(defvar *mathjax-load-header-with-config* "<script type=\"text/javascript\"
src=\"~A?config=~A\">
</script>
")
(defun enable (&key force
(mathjax-url "http://cdn.mathjax.org/mathjax/latest/MathJax.js")
(config "TeX-AMS-MML_HTMLorMML"))
(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))))))
(add-injection (list *mathjax-header* #'mathjax-p) :head)))
(or force
(etypecase obj
(content (math-post-p obj))
(index (some #'math-post-p (index-posts obj)))))))
(let ((mathjax-header
(concatenate 'string
*mathjax-config-header*
(if config
(format nil *mathjax-load-header-with-config* mathjax-url config)
(format nil *mathjax-load-header-no-config* mathjax-url)))))
(add-injection (list mathjax-header #'mathjax-p) :head))))