+
+"
+ "The MathJax setup for XHTML files."
+ :group 'org-export-html
+ :type 'string)
+
(defcustom org-export-html-tag-class-prefix ""
"Prefix to class names for TODO keywords.
Each tag gets a class given by the tag itself, with this prefix.
@@ -439,7 +545,13 @@ This may also be a function, building and inserting the postamble.")
(file-name-nondirectory
org-current-export-file)))
org-current-export-dir nil "Creating LaTeX image %s"
- nil nil (eq (plist-get parameters :LaTeX-fragments) 'verbatim)))
+ nil nil
+ (cond
+ ((eq (plist-get parameters :LaTeX-fragments) 'verbatim) 'verbatim)
+ ((eq (plist-get parameters :LaTeX-fragments) 'mathjax ) 'mathjax)
+ ((eq (plist-get parameters :LaTeX-fragments) t ) 'mathjax)
+ ((eq (plist-get parameters :LaTeX-fragments) 'dvipng ) 'dvipng)
+ (t nil))))
(goto-char (point-min))
(let (label l1)
(while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t)
@@ -812,6 +924,7 @@ PUB-DIR is set, use this as the publishing directory."
(buffer-substring
(if region-p (region-beginning) (point-min))
(if region-p (region-end) (point-max))))
+ (org-export-have-math nil)
(lines
(org-split-string
(org-export-preprocess-string
@@ -835,6 +948,16 @@ PUB-DIR is set, use this as the publishing directory."
:LaTeX-fragments
(plist-get opt-plist :LaTeX-fragments))
"[\r\n]"))
+ (mathjax
+ (if (or (eq (plist-get opt-plist :LaTeX-fragments) 'mathjax)
+ (and org-export-have-math
+ (eq (plist-get opt-plist :LaTeX-fragments) t)))
+
+ (org-export-html-mathjax-config
+ org-export-html-mathjax-template
+ org-export-html-mathjax-options
+ (or (plist-get opt-plist :mathjax) ""))
+ ""))
table-open type
table-buffer table-orig-buffer
ind item-type starter didclose
@@ -904,6 +1027,7 @@ lang=\"%s\" xml:lang=\"%s\">
%s
+%s
@@ -922,6 +1046,7 @@ lang=\"%s\" xml:lang=\"%s\">
(or charset "iso-8859-1")
date author description keywords
style
+ mathjax
(if (or link-up link-home)
(concat
(format org-export-html-home/up-format
diff --git a/lisp/org.el b/lisp/org.el
index 31d241104..a05f2bfcc 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15880,7 +15880,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
(concat "ltxpng/" (file-name-sans-extension
(file-name-nondirectory
buffer-file-name)))
- default-directory 'overlays msg at 'forbuffer)
+ default-directory 'overlays msg at 'forbuffer 'dvipng)
(message msg "done. Use `C-c C-c' to remove images.")))))
(defvar org-latex-regexps
@@ -15894,8 +15894,9 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
"Regular expressions for matching embedded LaTeX.")
+(defvar org-export-have-math nil) ;; dynamic scoping
(defun org-format-latex (prefix &optional dir overlays msg at
- forbuffer protect-only)
+ forbuffer processing-type)
"Replace LaTeX fragments with links to an image, and produce images.
Some of the options can be changed using the variable
`org-format-latex-options'."
@@ -15909,7 +15910,7 @@ Some of the options can be changed using the variable
(org-format-latex-header-extra
(plist-get (org-infile-export-plist) :latex-header-extra))
(cnt 0) txt hash link beg end re e checkdir
- executables-checked
+ executables-checked string
m n block linkfile movefile ov)
;; Check the different regular expressions
(while (setq e (pop re-list))
@@ -15925,9 +15926,26 @@ Some of the options can be changed using the variable
(not (eq (get-char-property (match-beginning n)
'org-overlay-type)
'org-latex-overlay))))
- (if protect-only
+ (setq org-export-have-math t)
+ (cond
+ ((eq processing-type 'verbatim)
+ ;; Leave the text verbatim, just protect it
+ (add-text-properties (match-beginning n) (match-end n)
+ '(org-protected t)))
+ ((eq processing-type 'mathjax)
+ ;; Prepare for MathJax processing
+ (setq string (match-string n))
+ (if (equal m "$")
+ (save-excursion
+ (delete-region (match-beginning n) (match-end n))
+ (goto-char (match-beginning n))
+ (insert (org-add-props (concat "\\(" (substring string 1 -1)
+ "\\)")
+ '(org-protected t))))
(add-text-properties (match-beginning n) (match-end n)
- '(org-protected t))
+ '(org-protected t))))
+ ((or (eq processing-type 'dvipng) t)
+ ;; Process to an image
(setq txt (match-string n)
beg (match-beginning n) end (match-end n)
cnt (1+ cnt))
@@ -15981,7 +15999,8 @@ Some of the options can be changed using the variable
(delete-region beg end)
(insert (org-add-props link
(list 'org-latex-src
- (replace-regexp-in-string "\"" "" txt))))))))))))
+ (replace-regexp-in-string
+ "\"" "" txt)))))))))))))
;; This function borrows from Ganesh Swami's latex2png.el
(defun org-create-formula-image (string tofile options buffer)
@@ -17650,14 +17669,6 @@ See the individual commands for more information."
(org-inside-LaTeX-fragment-p)]
["Insert citation" org-reftex-citation t]
"--"
- ["Export LaTeX fragments as images"
- (if (featurep 'org-exp)
- (setq org-export-with-LaTeX-fragments
- (not org-export-with-LaTeX-fragments))
- (require 'org-exp))
- :style toggle :selected (and (boundp 'org-export-with-LaTeX-fragments)
- org-export-with-LaTeX-fragments)]
- "--"
["Template for BEAMER" org-insert-beamer-options-template t])
"--"
("MobileOrg"