Debian Codegraph @

unpacked/config/MMLorHTML.js

raw
1 /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3
4 /*************************************************************
5 *
6 * MathJax/config/MMLorHTML.js
7 *
8 * Chooses between the NativeMML and HTML-CSS output jax depending
9 * on the capabilities of the browser and configuration settings
10 * of the page.
11 *
12 * This file should be added to the config array when configuring
13 * MathJax. Note that if you include this, you should NOT include
14 * an output jax in the jax array (it will be added for you by
15 * this file).
16 *
17 * You can specify the preferred output jax on a global or
18 * browser-by-browser basis. To specify it globally, use
19 *
20 * MathJax.Hub.Config({
21 * MMLorHTML: {prefer: "MML"} // or "HTML"
22 * });
23 *
24 * To specify on a browser-by-borwser basis, use
25 *
26 * MathJax.Hub.Config({
27 * MMLorHTML: {prefer: {
28 * MSIE: "MML",
29 * Firefox: "MML",
30 * Opera: "HTML",
31 * other: "HTML"
32 * }}
33 * });
34 *
35 * ---------------------------------------------------------------------
36 *
37 * Copyright (c) 2010-2020 The MathJax Consortium
38 *
39 * Licensed under the Apache License, Version 2.0 (the "License");
40 * you may not use this file except in compliance with the License.
41 * You may obtain a copy of the License at
42 *
43 * http://www.apache.org/licenses/LICENSE-2.0
44 *
45 * Unless required by applicable law or agreed to in writing, software
46 * distributed under the License is distributed on an "AS IS" BASIS,
47 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48 * See the License for the specific language governing permissions and
49 * limitations under the License.
50 */
51
52 (function (HUB,BROWSER) {
53 var VERSION = "2.7.0";
54
55 var CONFIG = MathJax.Hub.CombineConfig("MMLorHTML",{
56 prefer: {
57 MSIE:"MML",
58 Firefox:"HTML",
59 Opera:"HTML",
60 Chrome:"HTML",
61 Safari:"HTML",
62 other:"HTML"
63 }
64 });
65
66 var MINBROWSERVERSION = {
67 Firefox: 3.0,
68 Opera: 9.52,
69 MSIE: 6.0,
70 Chrome: 0.3,
71 Safari: 2.0,
72 Konqueror: 4.0
73 };
74
75 var canUseHTML = (BROWSER.version === "0.0" ||
76 BROWSER.versionAtLeast(MINBROWSERVERSION[BROWSER]||0.0));
77
78 var canUseMML = (BROWSER.isFirefox && BROWSER.versionAtLeast("1.5")) ||
79 (BROWSER.isMSIE && BROWSER.hasMathPlayer) ||
80 (BROWSER.isSafari && BROWSER.versionAtLeast("5.0")) ||
81 (BROWSER.isOpera && BROWSER.versionAtLeast("9.52"));
82
83 HUB.Register.StartupHook("End Config",function () {
84 var prefer = (CONFIG.prefer && typeof(CONFIG.prefer) === "object" ?
85 CONFIG.prefer[MathJax.Hub.Browser]||CONFIG.prefer.other||"HTML" :
86 CONFIG.prefer);
87
88 if (canUseHTML || canUseMML) {
89 if (canUseMML && (prefer === "MML" || !canUseHTML)) {
90 if (MathJax.OutputJax.NativeMML) {MathJax.OutputJax.NativeMML.Register("jax/mml")}
91 else {HUB.config.jax.unshift("output/NativeMML")}
92 HUB.Startup.signal.Post("NativeMML output selected");
93 } else {
94 if (MathJax.OutputJax["HTML-CSS"]) {MathJax.OutputJax["HTML-CSS"].Register("jax/mml")}
95 else {HUB.config.jax.unshift("output/HTML-CSS")}
96 HUB.Startup.signal.Post("HTML-CSS output selected");
97 }
98 } else {
99 HUB.PreProcess.disabled = true;
100 HUB.prepareScripts.disabled = true;
101 MathJax.Message.Set(
102 ["MathJaxNotSupported","Your browser does not support MathJax"],
103 null,4000
104 );
105 HUB.Startup.signal.Post("MathJax not supported");
106 }
107 });
108
109 })(MathJax.Hub,MathJax.Hub.Browser);
110
111 MathJax.Ajax.loadComplete("[MathJax]/config/MMLorHTML.js");