>From baf1f93056feb034c223cc7d7f5234559cd34471 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Mon, 16 Feb 2015 02:04:02 +0100 Subject: [PATCH] ox-html: Use upstream MathJax CDN * ox-html.el (org-html-mathjax-options): Add multlinewidth, autonumber, tagindent and tagside. Remove MathML. Change default indent to correspond to upstream default. Change default MathJax path to point to upstream CDN. (org-html--build-mathjax-config): Remove MathML-related parts. (org-html-mathjax-template): Simplifiy template. * org.texi (@LaTeX{} fragments), (Math formatting in HTML export): Reflect change in default CDN. --- doc/org.texi | 51 ++++++++++++------------- lisp/ox-html.el | 115 ++++++++++++++++++++++++-------------------------------- 2 files changed, 73 insertions(+), 93 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index bec46a9..157f928 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10258,20 +10258,17 @@ format sub- and superscripts in a WYSIWYM way. Going beyond symbols and sub- and superscripts, a full formula language is needed. Org mode can contain @LaTeX{} math fragments, and it supports ways to process these for several export back-ends. When exporting to @LaTeX{}, -the code is obviously left as it is. When exporting to HTML, Org can invoke -the @uref{http://www.mathjax.org, MathJax library} (@pxref{Math formatting in -HTML export}) to process and display the address@hidden you plan to use -this regularly or on pages with significant page views, you should install address@hidden on your own server in order to limit the load of our server.}. -It can also process the mathematical expressions into images that can be -displayed in a browser (see @pxref{Previewing @LaTeX{} fragments}). +the code is left as it is. When exporting to HTML, Org can use either address@hidden://www.mathjax.org, MathJax} (@pxref{Math formatting in HTML +export}) or transcode the math into images (see @pxref{Previewing @LaTeX{} +fragments}). @LaTeX{} fragments don't need any special marking at all. The following snippets will be identified as @LaTeX{} source code: @itemize @bullet @item -Environments of any address@hidden @file{MathJax} is used, only the -environments recognized by @file{MathJax} will be processed. When +Environments of any address@hidden MathJax is used, only the +environments recognized by MathJax will be processed. When @file{dvipng} program or @file{imagemagick} suite is used to create images, any @LaTeX{} environment will be handled.}. The only requirement is that the @code{\begin} statement appears on a new line, at the beginning of the line @@ -10307,7 +10304,7 @@ either $$ address@hidden@} $$ or \[ address@hidden@} \]. @vindex org-export-with-latex @LaTeX{} processing can be configured with the variable @code{org-export-with-latex}. The default setting is @code{t} which means address@hidden for HTML, and no processing for ASCII and @LaTeX{} back-ends. +MathJax for HTML, and no processing for ASCII and @LaTeX{} back-ends. You can also set this variable on a per-file basis using one of these lines: @@ -11466,25 +11463,23 @@ You could use @code{http} addresses just as well. @cindex imagemagick @LaTeX{} math snippets (@address@hidden fragments}) can be displayed in two -different ways on HTML pages. The default is to use the address@hidden://www.mathjax.org, MathJax system} which should work out of the -box with Org mode installation because @uref{http://orgmode.org} serves address@hidden for Org mode users for small applications and for testing -purposes. @b{If you plan to use this regularly or on pages with significant -page views, you should address@hidden instructions can be -found on the MathJax website, see address@hidden://www.mathjax.org/resources/docs/?installation.html}.} MathJax on -your own server in order to limit the load of our server.} To configure address@hidden, use the variable @code{org-html-mathjax-options} or -insert something like the following into the buffer: - address@hidden -#+HTML_MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js" address@hidden example +different ways on HTML pages. The default is to use address@hidden://www.mathjax.org, MathJax} which should work out of the box with address@hidden default Org loads MathJax from address@hidden://docs.mathjax.org/en/latest/start.html#using-the-mathjax-content-delivery-network-cdn, +MathJax.org}. A link to the terms of service of the MathJax CDN can be found +in the docstring of @code{org-html-mathjax-options}.}. Some MathJax display +options can be configured via @code{org-html-mathjax-options}, or in the +buffer. For example, with the following settings, address@hidden +#+HTML_MATHJAX: align: left indent: 5em tagside: left tagindent: 0 address@hidden smallexample +equation labels will be displayed on the left marign and equations will be +five ems from the left margin. address@hidden See the docstring of the variable address@hidden for the meaning of the parameters in -this line. address@hidden See the docstring of address@hidden for all supported variables. The MathJax +template can be configure via @code{org-html-mathjax-template}. If you prefer, you can also request that @LaTeX{} fragments are processed into small images that will be inserted into the browser page. Before the diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 61619e0..b5e2231 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1064,82 +1064,78 @@ See `format-time-string' for more information on its components." ;;;; Template :: Mathjax (defcustom org-html-mathjax-options - '((path "http://orgmode.org/mathjax/MathJax.js") + '((path "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" ) (scale "100") (align "center") - (indent "2em") - (mathml nil)) + (indent "0em") + (multlinewidth "85%") + (autonumber "AMS") + (tagindent ".8em") + (tagside "right")) "Options for MathJax setup. -path The path where to find MathJax -scale Scaling for the HTML-CSS backend, usually between 100 and 133 -align How to align display math: left, center, or right -indent If align is not center, how far from the left/right side? -mathml Should a MathML player be used if available? - This is faster and reduces bandwidth use, but currently - sometimes has lower spacing quality. Therefore, the default is - nil. When browsers get better, this switch can be flipped. +path The path where to find MathJax +scale Scaling for the HTML-CSS backend, usually between 100 and 133 +align How to align display math: left, center, or right +indent If align is not center, how far from the left/right side? +multlinewidth The width of the multline environment. +autonumber How to number equations: None, all or as AMS Math. +tagindent The amount tags are indented. +tagside Whether tags are shown to the left or right of equations You can also customize this for each buffer, using something like -#+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\"" +#+HTML_MATHJAX: align: left indent: 5em tagside: left + +For further information about MathJax options, see the MathJax documentation: + + http://docs.mathjax.org/ + +Please note that by using the default CDN one must agree with +MathJax CDN Terms of Service. + + http://www.mathjax.org/mathjax-cdn-terms-of-service.html" :group 'org-export-html :type '(list :greedy t - (list :tag "path (the path from where to load MathJax.js)" - (const :format " " path) (string)) + (list :tag "path (the path from where to load MathJax.js)" + (const :format " " path) (string)) (list :tag "scale (scaling for the displayed math)" (const :format " " scale) (string)) (list :tag "align (alignment of displayed equations)" (const :format " " align) (string)) (list :tag "indent (indentation with left or right alignment)" (const :format " " indent) (string)) - (list :tag "mathml (should MathML display be used is possible)" - (const :format " " mathml) (boolean)))) + (list :tag "multlinewidth (width to use for the multline environment)" + (const :format " " multlinewidth) (string)) + (list :tag "autonumber (when should equations be numbered)" + (const :format " " autonumber) + (choice (const "AMS") + (const "None") + (const "All"))) + (list :tag "tagindent (the indentation of tags from left or right)" + (const :format " " tagindent) (string)) + (list :tag "tagside (location of tags)" + (const :format " " tagside) + (choice (const "left") + (const "right"))))) (defcustom org-html-mathjax-template - " -" - "The MathJax setup for XHTML files." +}); + +" + "The MathJax template. See also `org-html-mathjax-options'." :group 'org-export-html :type 'string) @@ -1691,17 +1687,6 @@ INFO is a plist used as a communication channel." (if (string-match (concat "%" (upcase (symbol-name name))) template) (setq template (replace-match val t t template)))) options) - (setq val (nth 1 (assq 'mathml options))) - (if (string-match (concat "\\