From 09d54e486305810121bda3b8288c931f97dca6b6 Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Thu, 4 Apr 2013 09:55:23 -0400 Subject: [PATCH] Mathjax plugin cleanups. --- docs/plugin-use.md | 8 ++++---- plugins/mathjax.lisp | 42 ++++++++++-------------------------------- src/coleslaw.lisp | 2 +- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/docs/plugin-use.md b/docs/plugin-use.md index 0533ce6..093bf9d 100644 --- a/docs/plugin-use.md +++ b/docs/plugin-use.md @@ -24,13 +24,13 @@ ### 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`. +`:force`, when non-nil, will force the inclusion of MathJax on all posts. 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. +`:location` specifies the location of the `MathJax.js` file. The default value is `"http://cdn.mathjax.org/mathjax/latest/MathJax.js"`. This is useful 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"`. +`:preset` allows the specification of the config parameter of `MathJax.js`. The default value is `"TeX-AMS-MML_HTMLorMML"`. -`:mathjax-config` allows specifying the content of the `...` in a `MathJax.Hub.Config ({ ... });` section. The default is `tex2jax: {inlineMath: [['$$','$$']]}`, which allows display equations to be enclosed in `$$`. If a `nil` argument is supplied the whole ` -") +") -(defvar *default-mathjax-config* "tex2jax: {inlineMath: [['$$','$$']]}") - -(defvar *mathjax-load-header-no-config* " -") - -(defvar *mathjax-load-header-with-config* " -") - -(defun enable (&key force - (mathjax-url "http://cdn.mathjax.org/mathjax/latest/MathJax.js") - (config "TeX-AMS-MML_HTMLorMML") - (mathjax-config *default-mathjax-config*)) +(defun enable (&key force config (preset "TeX-AMS-MML_HTMLorMML") + (location "http://cdn.mathjax.org/mathjax/latest/MathJax.js")) (labels ((math-post-p (obj) (member "math" (content-tags obj) :test #'string=)) (mathjax-p (obj) - (or force - (etypecase obj - (content (math-post-p obj)) - (index (some #'math-post-p (index-posts obj))))))) - - (let ((mathjax-header - (concatenate 'string - (if mathjax-config (format nil *mathjax-config-header* mathjax-config) "") - (if config - (format nil *mathjax-load-header-with-config* mathjax-url config) - (format nil *mathjax-load-header-no-config* mathjax-url))))) + (or force + (etypecase obj + (content (math-post-p obj)) + (index (some #'math-post-p (index-posts obj))))))) + (let ((mathjax-header (format nil *mathjax-header* config location preset))) (add-injection (list mathjax-header #'mathjax-p) :head)))) diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp index ad08cad..df0c2ad 100644 --- a/src/coleslaw.lisp +++ b/src/coleslaw.lisp @@ -75,7 +75,7 @@ Additional args to render CONTENT can be passed via RENDER-ARGS." (defun main (config-key) "Load the user's config section corresponding to CONFIG-KEY, then compile and deploy the blog." - (let (*injections*) + (let (*injections*) (load-config config-key) (load-content) (compile-theme (theme *config*))