org-e-html: Fix mathjax

This commit is contained in:
Jambunathan K 2012-03-01 10:30:41 +05:30
parent f0af36a348
commit 4d58568076
1 changed files with 30 additions and 35 deletions

View File

@ -120,7 +120,8 @@
(:html-preamble nil nil org-e-html-preamble) (:html-preamble nil nil org-e-html-preamble)
(:html-table-tag nil nil org-e-html-table-tag) (:html-table-tag nil nil org-e-html-table-tag)
(:xml-declaration nil nil org-e-html-xml-declaration) (:xml-declaration nil nil org-e-html-xml-declaration)
(:LaTeX-fragments nil "LaTeX" org-export-with-LaTeX-fragments)) (:LaTeX-fragments nil "LaTeX" org-export-with-LaTeX-fragments)
(:mathjax "MATHJAX" nil "" space))
"Alist between export properties and ways to set them. "Alist between export properties and ways to set them.
The car of the alist is the property name, and the cdr is a list The car of the alist is the property name, and the cdr is a list
@ -1567,39 +1568,31 @@ This function shouldn't be used for floats. See
(defun org-e-html-mathjax-config (template options in-buffer) (defun org-e-html-mathjax-config (template options in-buffer)
"Insert the user setup into the matchjax template." "Insert the user setup into the matchjax template."
(let (name val (yes " ") (no "// ") x) (when (member (plist-get info :LaTeX-fragments) '(mathjax t))
(mapc (let (name val (yes " ") (no "// ") x)
(lambda (e) (mapc
(setq name (car e) val (nth 1 e)) (lambda (e)
(if (string-match (concat "\\<" (symbol-name name) ":") in-buffer) (setq name (car e) val (nth 1 e))
(setq val (car (read-from-string (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
(substring in-buffer (match-end 0)))))) (setq val (car (read-from-string
(if (not (stringp val)) (setq val (format "%s" val))) (substring in-buffer (match-end 0))))))
(if (string-match (concat "%" (upcase (symbol-name name))) template) (if (not (stringp val)) (setq val (format "%s" val)))
(setq template (replace-match val t t template)))) (if (string-match (concat "%" (upcase (symbol-name name))) template)
options) (setq template (replace-match val t t template))))
(setq val (nth 1 (assq 'mathml options))) options)
(if (string-match (concat "\\<mathml:") in-buffer) (setq val (nth 1 (assq 'mathml options)))
(setq val (car (read-from-string (if (string-match (concat "\\<mathml:") in-buffer)
(substring in-buffer (match-end 0)))))) (setq val (car (read-from-string
;; Exchange prefixes depending on mathml setting (substring in-buffer (match-end 0))))))
(if (not val) (setq x yes yes no no x)) ;; Exchange prefixes depending on mathml setting
;; Replace cookies to turn on or off the config/jax lines (if (not val) (setq x yes yes no no x))
(if (string-match ":MMLYES:" template) ;; Replace cookies to turn on or off the config/jax lines
(setq template (replace-match yes t t template))) (if (string-match ":MMLYES:" template)
(if (string-match ":MMLNO:" template) (setq template (replace-match yes t t template)))
(setq template (replace-match no t t template))) (if (string-match ":MMLNO:" template)
;; Return the modified template (setq template (replace-match no t t template)))
template)) ;; Return the modified template
template)))
(defun org-e-html-mathjax (info)
(when (or (eq (plist-get info :HTML-fragments) 'mathjax)
(and org-export-have-math
(eq (plist-get info :HTML-fragments) t)))
(org-e-html-mathjax-config
org-e-html-mathjax-template
org-e-html-mathjax-options
(or (plist-get info :mathjax) ""))))
(defun org-e-html-preamble (info) (defun org-e-html-preamble (info)
(when (plist-get info :html-preamble) (when (plist-get info :html-preamble)
@ -1732,7 +1725,9 @@ original parsed data. INFO is a plist holding export options."
<head>" <head>"
(org-e-html-meta-info info) ; meta (org-e-html-meta-info info) ; meta
(org-e-html-style info) ; style (org-e-html-style info) ; style
(org-e-html-mathjax info) ; mathjax (org-e-html-mathjax-config ; mathjax
org-e-html-mathjax-template org-e-html-mathjax-options
(or (plist-get info :mathjax) ""))
" "
</head>" </head>"