config.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
  2. /* vim: set ts=2 et sw=2 tw=80: */
  3. /*************************************************************
  4. *
  5. * MathJax/jax/output/HTML-CSS/config.js
  6. *
  7. * Initializes the HTML-CCS OutputJax (the main definition is in
  8. * MathJax/jax/input/HTML-CSS/jax.js, which is loaded when needed).
  9. *
  10. * ---------------------------------------------------------------------
  11. *
  12. * Copyright (c) 2009-2013 The MathJax Consortium
  13. *
  14. * Licensed under the Apache License, Version 2.0 (the "License");
  15. * you may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at
  17. *
  18. * http://www.apache.org/licenses/LICENSE-2.0
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. */
  26. MathJax.OutputJax["HTML-CSS"] = MathJax.OutputJax({
  27. id: "HTML-CSS",
  28. version: "2.2",
  29. directory: MathJax.OutputJax.directory + "/HTML-CSS",
  30. extensionDir: MathJax.OutputJax.extensionDir + "/HTML-CSS",
  31. autoloadDir: MathJax.OutputJax.directory + "/HTML-CSS/autoload",
  32. fontDir: MathJax.OutputJax.directory + "/HTML-CSS/fonts", // font name added later
  33. webfontDir: MathJax.OutputJax.fontDir + "/HTML-CSS", // font name added later
  34. config: {
  35. scale: 100, minScaleAdjust: 50, // global math scaling factor, and minimum adjusted scale factor
  36. availableFonts: ["STIX","TeX"], // list of local fonts to check for
  37. preferredFont: "TeX", // preferred local font (TeX or STIX)
  38. webFont: "TeX", // web-based font to use when no local fonts found (TeX is only choice)
  39. imageFont: "TeX", // font to use for image fallback mode (TeX is only choice)
  40. undefinedFamily: "STIXGeneral,'Arial Unicode MS',serif", // fonts to use for unknown unicode characters
  41. mtextFontInherit: false, // to make <mtext> be in page font rather than MathJax font
  42. EqnChunk: (MathJax.Hub.Browser.isMobile ? 10: 50),
  43. // number of equations to process before showing them
  44. EqnChunkFactor: 1.5, // chunk size is multiplied by this after each chunk
  45. EqnChunkDelay: 100, // milliseconds to delay between chunks (to let browser
  46. // respond to other events)
  47. linebreaks: {
  48. automatic: false, // when false, only process linebreak="newline",
  49. // when true, insert line breaks automatically in long expressions.
  50. width: "container" // maximum width of a line for automatic line breaks (e.g. "30em").
  51. // use "container" to compute size from containing element,
  52. // use "nn% container" for a portion of the container,
  53. // use "nn%" for a portion of the window size
  54. },
  55. styles: {
  56. ".MathJax_Display": {
  57. "text-align": "center",
  58. margin: "1em 0em"
  59. },
  60. ".MathJax .merror": {
  61. "background-color": "#FFFF88",
  62. color: "#CC0000",
  63. border: "1px solid #CC0000",
  64. padding: "1px 3px",
  65. "font-style": "normal",
  66. "font-size": "90%"
  67. },
  68. "#MathJax_Tooltip": {
  69. "background-color": "InfoBackground", color: "InfoText",
  70. border: "1px solid black",
  71. "box-shadow": "2px 2px 5px #AAAAAA", // Opera 10.5
  72. "-webkit-box-shadow": "2px 2px 5px #AAAAAA", // Safari 3 and Chrome
  73. "-moz-box-shadow": "2px 2px 5px #AAAAAA", // Forefox 3.5
  74. "-khtml-box-shadow": "2px 2px 5px #AAAAAA", // Konqueror
  75. filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')", // IE
  76. padding: "3px 4px",
  77. "z-index": 401
  78. }
  79. }
  80. }
  81. });
  82. if (MathJax.Hub.Browser.isMSIE && document.documentMode >= 9)
  83. {delete MathJax.OutputJax["HTML-CSS"].config.styles["#MathJax_Tooltip"].filter}
  84. if (!MathJax.Hub.config.delayJaxRegistration)
  85. {MathJax.OutputJax["HTML-CSS"].Register("jax/mml")}
  86. MathJax.Hub.Register.StartupHook("End Config",[function (HUB,HTMLCSS) {
  87. var CONFIG = HUB.Insert({
  88. //
  89. // The minimum versions that HTML-CSS supports
  90. //
  91. minBrowserVersion: {
  92. Firefox: 3.0,
  93. Opera: 9.52,
  94. MSIE: 6.0,
  95. Chrome: 0.3,
  96. Safari: 2.0,
  97. Konqueror: 4.0
  98. },
  99. //
  100. // For unsupported browsers, put back these delimiters for the preview
  101. //
  102. inlineMathDelimiters: ['$','$'], // or ["",""] or ["\\(","\\)"]
  103. displayMathDelimiters: ['$$','$$'], // or ["",""] or ["\\[","\\]"]
  104. //
  105. // For displayed math, insert <BR> for \n?
  106. //
  107. multilineDisplay: true,
  108. //
  109. // The function to call to display the math for unsupported browsers
  110. //
  111. minBrowserTranslate: function (script) {
  112. var MJ = HUB.getJaxFor(script), text = ["[Math]"], delim;
  113. var span = document.createElement("span",{className: "MathJax_Preview"});
  114. if (MJ.inputJax === "TeX") {
  115. if (MJ.root.Get("displaystyle")) {
  116. delim = CONFIG.displayMathDelimiters;
  117. text = [delim[0]+MJ.originalText+delim[1]];
  118. if (CONFIG.multilineDisplay) text = text[0].split(/\n/);
  119. } else {
  120. delim = CONFIG.inlineMathDelimiters;
  121. text = [delim[0]+MJ.originalText.replace(/^\s+/,"").replace(/\s+$/,"")+delim[1]];
  122. }
  123. }
  124. for (var i = 0, m = text.length; i < m; i++) {
  125. span.appendChild(document.createTextNode(text[i]));
  126. if (i < m-1) {span.appendChild(document.createElement("br"))}
  127. }
  128. script.parentNode.insertBefore(span,script);
  129. }
  130. },(HUB.config["HTML-CSS"]||{}));
  131. if (HUB.Browser.version !== "0.0" &&
  132. !HUB.Browser.versionAtLeast(CONFIG.minBrowserVersion[HUB.Browser]||0.0)) {
  133. HTMLCSS.Translate = CONFIG.minBrowserTranslate;
  134. HUB.Config({showProcessingMessages: false});
  135. MathJax.Message.Set(["MathJaxNotSupported",
  136. "Your browser does not support MathJax"],null,4000);
  137. HUB.Startup.signal.Post("MathJax not supported");
  138. }
  139. },MathJax.Hub,MathJax.OutputJax["HTML-CSS"]]);
  140. MathJax.OutputJax["HTML-CSS"].loadComplete("config.js");