Straight update of MathJax to 2.0 -- doesn't currently load correctly if experimental $wgMathUseMathJax is enabled, be warned!

Using the unpacked files; minus the PNG fonts.
This commit is contained in:
Brion Vibber 2012-03-01 01:21:20 +00:00
parent d1957900e2
commit f5df298230
339 changed files with 26227 additions and 3881 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
/*
* /MathJax/unpacked/config/AM_HTMLorMML-full.js
*
* Copyright (c) 2010-11 Design Science, Inc.
*
* Part of the MathJax library.
* See http://www.mathjax.org for details.
*
* Licensed under the Apache License, Version 2.0;
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["asciimath2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js"],
jax: ["input/AsciiMath","output/HTML-CSS","output/NativeMML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/AM_HTMLorMML-full.js");

21
modules/MathJax/config/AM_HTMLorMML.js vendored Normal file
View File

@ -0,0 +1,21 @@
/*
* /MathJax/unpacked/config/AM_HTMLorMML.js
*
* Copyright (c) 2010-11 Design Science, Inc.
*
* Part of the MathJax library.
* See http://www.mathjax.org for details.
*
* Licensed under the Apache License, Version 2.0;
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["asciimath2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js"],
jax: ["input/AsciiMath","output/HTML-CSS","output/NativeMML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/AM_HTMLorMML.js");

View File

@ -14,13 +14,12 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML"],
NativeMML: {
showMathMenuMSIE: false
},
menuSettings: {
zoom: "Double-Click"
zoom: "Double-Click",
mpContext: true,
mpMouse: true
},
errorSettings: {
message: ["[Math Error]"]

View File

@ -14,13 +14,12 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML"],
NativeMML: {
showMathMenuMSIE: false
},
menuSettings: {
zoom: "Double-Click"
zoom: "Double-Click",
mpContext: true,
mpMouse: true
},
errorSettings: {
message: ["[Math Error]"]

View File

@ -14,7 +14,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["mml2jax.js","MathZoom.js","MathMenu.js","toMathML.js"],
extensions: ["mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js"],
jax: ["input/MathML","output/HTML-CSS","output/NativeMML"]
});

View File

@ -14,7 +14,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["mml2jax.js","MathZoom.js","MathMenu.js","toMathML.js"],
extensions: ["mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js"],
jax: ["input/MathML","output/HTML-CSS","output/NativeMML"]
});

View File

@ -31,7 +31,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,11 +46,18 @@
* limitations under the License.
*/
(function (HUB) {
var VERSION = "1.1.1";
(function (HUB,BROWSER) {
var VERSION = "2.0";
var CONFIG = MathJax.Hub.CombineConfig("MMLorHTML",{
prefer: {MSIE:"MML", Firefox:"MML", Opera:"HTML", other:"HTML"}
prefer: {
MSIE:"MML",
Firefox:"HTML",
Opera:"HTML",
Chrome:"HTML",
Safari:"HTML",
other:"HTML"
}
});
var MINBROWSERVERSION = {
@ -61,17 +68,14 @@
Safari: 2.0,
Konqueror: 4.0
};
var canUseHTML = (BROWSER.version === "0.0" ||
BROWSER.versionAtLeast(MINBROWSERVERSION[BROWSER]||0.0));
var canUseHTML = (HUB.Browser.version === "0.0" ||
HUB.Browser.versionAtLeast(MINBROWSERVERSION[HUB.Browser]||0.0));
var MathPlayer = false;
if (!HUB.Browser.isIE9) // this crashes IE9 RC, so skip it for now
{try {new ActiveXObject("MathPlayer.Factory.1"); MathPlayer = true} catch(err) {}}
var canUseMML = (HUB.Browser.isFirefox && HUB.Browser.versionAtLeast("1.5")) ||
(HUB.Browser.isMSIE && MathPlayer) ||
(HUB.Browser.isOpera && HUB.Browser.versionAtLeast("9.52"));
var canUseMML = (BROWSER.isFirefox && BROWSER.versionAtLeast("1.5")) ||
(BROWSER.isMSIE && BROWSER.hasMathPlayer) ||
(BROWSER.isSafari && BROWSER.versionAtLeast("5.0")) ||
(BROWSER.isOpera && BROWSER.versionAtLeast("9.52"));
HUB.Register.StartupHook("End Config",function () {
var prefer = (CONFIG.prefer && typeof(CONFIG.prefer) === "object" ?
@ -96,6 +100,6 @@
}
});
})(MathJax.Hub);
})(MathJax.Hub,MathJax.Hub.Browser);
MathJax.Ajax.loadComplete("[MathJax]/config/MMLorHTML.js");

View File

@ -14,7 +14,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML"]
});

View File

@ -14,7 +14,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML"]
});

View File

@ -0,0 +1,20 @@
/*
* /MathJax/unpacked/config/TeX-AMS-MML_SVG-full.js
*
* Copyright (c) 2010-11 Design Science, Inc.
*
* Part of the MathJax library.
* See http://www.mathjax.org for details.
*
* Licensed under the Apache License, Version 2.0;
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.Hub.Config({
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","input/MathML","output/SVG"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-AMS-MML_SVG-full.js");

View File

@ -0,0 +1,20 @@
/*
* /MathJax/unpacked/config/TeX-AMS-MML_SVG.js
*
* Copyright (c) 2010-11 Design Science, Inc.
*
* Part of the MathJax library.
* See http://www.mathjax.org for details.
*
* Licensed under the Apache License, Version 2.0;
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.Hub.Config({
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","input/MathML","output/SVG"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-AMS-MML_SVG.js");

View File

@ -13,7 +13,7 @@
*/
MathJax.Hub.Config({
extensions: ["tex2jax.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
extensions: ["tex2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"]
});

View File

@ -13,7 +13,7 @@
*/
MathJax.Hub.Config({
extensions: ["tex2jax.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
extensions: ["tex2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"]
});

View File

@ -0,0 +1,21 @@
/*
* /MathJax/unpacked/config/TeX-MML-AM_HTMLorMML-full.js
*
* Copyright (c) 2010-11 Design Science, Inc.
*
* Part of the MathJax library.
* See http://www.mathjax.org for details.
*
* Licensed under the Apache License, Version 2.0;
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","asciimath2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","input/MathML","input/AsciiMath","output/HTML-CSS","output/NativeMML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-MML-AM_HTMLorMML-full.js");

View File

@ -0,0 +1,21 @@
/*
* /MathJax/unpacked/config/TeX-MML-AM_HTMLorMML.js
*
* Copyright (c) 2010-11 Design Science, Inc.
*
* Part of the MathJax library.
* See http://www.mathjax.org for details.
*
* Licensed under the Apache License, Version 2.0;
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","asciimath2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","input/MathML","input/AsciiMath","output/HTML-CSS","output/NativeMML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-MML-AM_HTMLorMML.js");

View File

@ -9,7 +9,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009-2011 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -62,9 +62,8 @@ MathJax.Hub.Config({
//
// Example:
// styles: {
// ".MathJax .merror": {
// color: "blue",
// "background-color": "green"
// ".MathJax_Preview": {
// color: "#888"
// }
// },
//
@ -183,6 +182,62 @@ MathJax.Hub.Config({
// is processed.
//
elements: [],
//
// Since typesetting usually changes the vertical dimensions of the
// page, if the URL contains an anchor position you may no longer be
// positioned at the correct position on the page, so MathJax can
// reposition to that location after it completes its initial
// typesetting of the page. This value controls whether MathJax will
// reposition the browser to the #hash location from the page URL after
// typesetting for the page.
//
positionToHash: true,
//
// These control whether to attach the MathJax contextual menu to the
// expressions typeset by MathJax. Since the code for handling
// MathPlayer in Internet Explorer is somewhat delicate, it is
// controlled separately via (showMathMenuMSIE). The latter is now
// deprecated in favor of the MathJax contextual menu settings for
// MathPlayer.
//
// These values used to be listed in the separate output jax, but
// have been moved to this more central location since they are shared
// by all output jax.
//
showMathMenu: true,
showMathMenuMSIE: true,
//
// The default settings for the MathJax contextual menu (overridden by
// the MathJax cookie when users change the menu settings).
//
menuSettings: {
zoom: "None", // when to do MathZoom
CTRL: false, // require CTRL for MathZoom?
ALT: false, // require Alt or Option?
CMD: false, // require CMD?
Shift: false, // require Shift?
zscale: "200%", // the scaling factor for MathZoom
font: "Auto", // what font HTML-CSS should use
context: "MathJax", // or "Browser" for pass-through to browser menu
mpContext: false, // true means pass menu events to MathPlayer in IE
mpMouse: false, // true means pass mouse events to MathPlayer in IE
texHints: true // include class names for TeXAtom elements
},
//
// The message and style for when there is a processing error handling
// the mathematics (something has gone wrong with the input or output
// jax that prevents it from operating properly).
//
errorSettings: {
message: ["[Math Processing Error]"], // HTML snippet structure for message to use
style: {color: "#CC0000", "font-style":"italic"} // style for message
},
//============================================================================
//
@ -215,6 +270,19 @@ MathJax.Hub.Config({
['\\[','\\]']
],
//
// This value determines whether tex2jax requires braces to be
// balanced within math delimiters (which allows for nested dollar
// signs). Set to false to get pre-v2.0 compatibility. When true,
//
// $y = x^2 \hbox{ when $x > 2$}$.
//
// will be properly handled as a single expression. When false, it
// would be interpreted as two searpate expressions, each with
// improperly balanced braces.
//
balanceBraces: true,
//
// This array lists the names of the tags whose contents should not be
// processed by tex2jax (other than to look for ignore/process classes
@ -262,6 +330,13 @@ MathJax.Hub.Config({
//
processEnvironments: true,
//
// Controls whether tex2jax processes \ref{...} commands outside
// of math mode. Set to "false" to prevent processing of \ref
// except within math mode.
//
processRefs: true,
//
// Controls whether tex2jax inserts MathJax_Preview spans to make a
// preview available, and what preview to use, when it locates in-line
@ -280,6 +355,71 @@ MathJax.Hub.Config({
},
//============================================================================
//
// These parameters control the asciimath2jax preprocessor (when you have included
// "asciimath2jax.js" in the extensions list above).
//
asciimath2jax: {
//
// The delimiters that surround asciimath expressions. The first in each
// pair is the initial delimiter and the second is the terminal delimiter.
//
delimiters: [
['`','`']
],
//
// This array lists the names of the tags whose contents should not be
// processed by asciimath2jax (other than to look for ignore/process classes
// as listed below). You can add to (or remove from) this list to prevent
// MathJax from processing mathematics in specific contexts.
//
skipTags: ["script","noscript","style","textarea","pre","code"],
//
// This is the class name used to mark elements whose contents should
// not be processed by asciimath2jax (other than to look for the
// processClass pattern below). Note that this is a regular
// expression, and so you need to be sure to quote any regexp special
// characters. The pattern is automatically preceeded by '(^| )(' and
// followed by ')( |$)', so your pattern will have to match full words
// in the class name. Assigning an element this class name will
// prevent `asciimath2jax` from processing its contents.
//
ignoreClass: "asciimath2jax_ignore",
//
// This is the class name used to mark elements whose contents SHOULD
// be processed by asciimath2jax. This is used to turn on processing
// within tags that have been marked as ignored or skipped above.
// Note that this is a regular expression, and so you need to be sure
// to quote any regexp special characters. The pattern is
// automatically preceeded by '(^| )(' and followed by ')( |$)', so
// your pattern will have to match full words in the class name. Use
// this to restart processing within an element that has been marked
// as ignored above.
//
processClass: "asciimath2jax_process",
// Controls whether asciimath2jax inserts MathJax_Preview spans to make a
// preview available, and what preview to use, when it locates in-line
// and display mathetics on the page. The default is "AsciiMath", which
// means use the AsciiMath code as the preview (until it is processed by
// MathJax). Set to "none" to prevent the previews from being
// inserted (the math will simply disappear until it is typeset). Set
// to an array containing the description of an HTML snippet in order
// to use the same preview for all equations on the page (e.g., you
// could have it say "[math]" or load an image).
//
// E.g., preview: ["[math]"],
// or preview: [["img",{src: "http://myserver.com/images/mypic.jpg"}]]
//
preview: "AsciiMath"
},
//============================================================================
//
// These parameters control the mml2jax preprocessor (when you have included
@ -368,13 +508,80 @@ MathJax.Hub.Config({
// bold: ['{\\bf #1}', 1]
// }
//
Macros: {}
Macros: {},
//
// Equation numbering parameters.
//
equationNumbers: {
autoNumber: "none", // "AMS" for standard AMS environment numbering,
// or "all" to number all displayed equations
// formatNumber: function (n) {return n}, // format for equation number n
// formatTag: function (n) {return '('+n+')'}, // format for \tag and \eqref
// formatID: function (n) {return 'mjx-eqn-'+String(n).replace(/[:'"<>&]/g,"")},
// // element ID to use for reference
// formatURL: function (id) {return '#'+escape(id)}, // URL to use for references
useLabelIds: true // make element ID's use \label name rather than equation number
},
//
// Controls the TeX/noErrors extension
//
noErrors: {
disabled: false, // set to true to return to original error messages
multiLine: true, // false to not include original line breaks
inlineDelimiters: ["",""], // or use ["$","$"] or ["\\(","\\)"] to put back delimiters
style: {
"font-size": "90%",
"text-align": "left",
"color": "black",
"padding": "1px 3px",
"border": "1px solid"
}
},
//
// Controls the TeX/noUndefined extension
//
noUndefined: {
disabled: false, // set to true to return to original error messages
attributes: { // attributes to set for the undefined control sequence
mathcolor: "red"
}
},
//
// Controls the TeX/unicode extension
unicode: {
fonts: "STIXGeneral,'Arial Unicode MS'" // the default font list for unknown characters
}
},
//============================================================================
//
// These parameters control the MathML inupt jax.
// These parameters control the AsciiMath input jax.
//
AsciiMath: {
//
// Determines whether limits are placed above and below operators,
// or next to them. (AsciiMath doesn't have separate in-line and
// display modes like TeX and MathML do, so this is the only control
// you have over its output)
//
displaystyle: true,
//
// The character to use for decimal places when scanning for a number.
// If you change it to ",", beware of things like "(1,2)" which would need
// to be changed to "(1, 2)" to be parsed correctly.
//
decimal: "."
},
//============================================================================
//
// These parameters control the MathML input jax.
//
MathML: {
//
@ -396,6 +603,12 @@ MathJax.Hub.Config({
//
scale: 100,
//
// Don't allow the matching of math text to surrounding text to use a scaling
// factor smaller than this.
//
minScaleAdjust: 50,
//
// This is a list of the fonts to look for on a user's computer in
// preference to using MathJax's web-based fonts. These must
@ -452,19 +665,71 @@ MathJax.Hub.Config({
// if it doesn't contain the needed character), so order these carefully.
//
undefinedFamily: "STIXGeneral,'Arial Unicode MS',serif",
//
// This controls whether the MathJax contextual menu will be available
// on the mathematics in the page. If true, then right-clicking (on
// the PC) or control-clicking (on the Mac) will produce a MathJax
// menu that allows you to get the source of the mathematics in
// various formats, change the size of the mathematics relative to the
// surrounding text, and get information about MathJax.
// This setting controls whether <mtext> elements will be typeset
// using the math fonts or the font of the surrounding text. When
// false, the mathvariant="normal" font will be used; when true,
// the font will be inherited from the surrounding paragraph.
//
// Set this to false to disable the menu. When true, the MathMenu
// items below configure the actions of the menu.
mtextFontInherit: false,
//
// These values control how "chunky" the display of mathematical
// expressions will be.
//
showMathMenu: true,
// EqnChunk is the number of equations that will be typeset before
// they appear on screen. Larger values make for less visual flicker
// as the equations are drawn, but also mean longer delays before the
// reader sees anything.
//
// EqChunkFactor is the factor by which the EqnChunk will grow after each
// chunk is displayed.
//
// EqChunkDelay is the time (in milliseconds) to delay between chunks
// (to allow the browser to respond to other user interaction).
//
// Set EqnChunk to 1, EqnChunkFactor to 1, and EqnChunkDelay to 10 to get
// the behavior from MathJax v1.1 and below.
//
EqnChunk: 50,
EqnChunkFactor: 1.5,
EqnChunkDelay: 100,
//
// These settings control automatic line breaking. It is off by
// default, so only explicit line breaks are performed (via
// linebreak="newline" attributes on <mo> and <mspace> elements). To
// perform automatic line breaking on line expressions, set
// 'automatic' to 'true' below. The line breaks will be applied via a
// penalty-based heuristic, which does well, but isn't perfect. You
// might need to use linebreak="goodbreak" or linebreak="badbreak" by
// hand in order to get better effects. It is also possible to modify
// the penalty values; contact the MathJax user's forum for details.
//
linebreaks: {
//
// This controls the automatic breaking of expressions:
// when false, only process linebreak="newline",
// when true, line breaks are inserted automatically in long expressions.
//
automatic: false,
//
// This controls how wide the lines of mathematics can be
//
// Use an explicit width like "30em" for a fixed width.
// Use "container" to compute the size from the containing element.
// Use "nn% container" for a portion of the container.
// Use "nn%" for a portion of the window size.
//
// The container-based widths may be slower, and may not produce the
// expected results if the layout width changes due to the removal
// of previews or inclusion of mathematics during typesetting.
//
width: "container"
},
//
// This allows you to define or modify the styles used to display
@ -472,9 +737,9 @@ MathJax.Hub.Config({
//
// Example:
// styles: {
// ".MathJax_Preview": {
// "font-size": "80%", // preview uses a smaller font
// color: "red" // and is in red
// ".MathJax .merror": {
// color: "#CC0000",
// border: "1px solid #CC0000"
// }
// }
//
@ -505,23 +770,11 @@ MathJax.Hub.Config({
scale: 100,
//
// This controls whether the MathJax contextual menu will be available
// on the mathematics in the page. If true, then right-clicking (on
// the PC) or control-clicking (on the Mac) will produce a MathJax
// menu that allows you to get the source of the mathematics in
// various formats, change the size of the mathematics relative to the
// surrounding text, and get information about MathJax.
//
// Set this to false to disable the menu. When true, the MathMenu
// items below configure the actions of the menu.
//
// There is a separate setting for MSIE, since the code to handle that
// is a bit delicate; if it turns out to have unexpected consequences,
// you can turn it off without turing off other browser support.
//
showMathMenu: true,
showMathMenuMSIE: true,
// Don't allow the matching of math text to surrounding text to use a scaling
// factor smaller than this.
//
minScaleAdjust: 50,
//
// This allows you to define or modify the styles used to display
// various math elements created by MathJax.
@ -536,6 +789,146 @@ MathJax.Hub.Config({
styles: {}
},
//============================================================================
//
// These parameters control the SVG output jax.
//
"SVG": {
//
// This controls the global scaling of mathematics as compared to the
// surrounding text. Values between 100 and 133 are usually good choices.
//
scale: 100,
//
// Don't allow the matching of math text to surrounding text to use a scaling
// factor smaller than this.
//
minScaleAdjust: 50,
//
// This specifies the font to use for SVG output (currently the only
// one available)
//
font: "TeX",
//
// This is the stroke width to use for all character paths (1em = 1000
// units). This is a cheap way of getting slightly lighter or darker
// characters
//
blacker: 10,
//
// This is the font-family CSS value used for characters that are not
// in the selected font. IE will stop looking after the first font
// that exists on the system (even if it doesn't contain the needed
// character), so order these carefully.
//
undefinedFamily: "STIXGeneral,'Arial Unicode MS',serif",
//
// This setting controls whether <mtext> elements will be typeset
// using the math fonts or the font of the surrounding text. When
// false, the mathvariant="normal" font will be used; when true,
// the font will be inherited from the surrounding paragraph.
//
mtextFontInherit: false,
//
// This controls whether the MathML structure is retained and CSS
// classes are added to mark the original MathML elements (as in the
// HTML-CSS output). By default, the SVG output jax removes unneeded
// nesting in order to produce a more efficient markup, but if you
// want to use CSS to style the elements as if they were MathML, you
// might need to set this to true.
//
addMMLclasses: false,
//
// These values control how "chunky" the display of mathematical
// expressions will be.
//
// EqnChunk is the number of equations that will be typeset before
// they appear on screen. Larger values make for less visual flicker
// as the equations are drawn, but also mean longer delays before the
// reader sees anything.
//
// EqChunkFactor is the factor by which the EqnChunk will grow after each
// chunk is displayed.
//
// EqChunkDelay is the time (in milliseconds) to delay between chunks
// (to allow the browser to respond to other user interaction).
//
// Set EqnChunk to 1, EqnChunkFactor to 1, and EwnChunkDelay to 10 to get
// the behavior from MathJax v1.1 and below.
//
EqnChunk: 50,
EqnChunkFactor: 1.5,
EqnChunkDelay: 100,
//
// These settings control automatic line breaking. It is off by
// default, so only explicit line breaks are performed (via
// linebreak="newline" attributes on <mo> and <mspace> elements). To
// perform automatic line breaking on line expressions, set
// 'automatic' to 'true' below. The line breaks will be applied via a
// penalty-based heuristic, which does well, but isn't perfect. You
// might need to use linebreak="goodbreak" or linebreak="badbreak" by
// hand in order to get better effects. It is also possible to modify
// the penalty values; contact the MathJax user's forum for details.
//
linebreaks: {
//
// This controls the automatic breaking of expressions:
// when false, only process linebreak="newline",
// when true, line breaks are inserted automatically in long expressions.
//
automatic: false,
//
// This controls how wide the lines of mathematics can be
//
// Use an explicit width like "30em" for a fixed width.
// Use "container" to compute the size from the containing element.
// Use "nn% container" for a portion of the container.
// Use "nn%" for a portion of the window size.
//
// The container-based widths may be slower, and may not produce the
// expected results if the layout width changes due to the removal
// of previews or inclusion of mathematics during typesetting.
//
width: "container"
},
//
// This allows you to define or modify the styles used to display
// various math elements created by MathJax.
//
// Example:
// styles: {
// ".MathJax .merror": {
// color: "#CC0000",
// border: "1px solid #CC0000"
// }
// }
//
styles: {},
//
// Configuration for <maction> tooltips
// (see also the #MathJax_Tooltip CSS in MathJax/jax/output/SVG/config.js,
// which can be overriden using the styles values above).
//
tooltip: {
delayPost: 600, // milliseconds delay before tooltip is posted after mouseover
delayClear: 600, // milliseconds delay before tooltip is cleared after mouseout
offsetX: 10, offsetY: 5 // pixels to offset tooltip from mouse position
}
},
//============================================================================
//
// These parameters control the contextual menus that are available on the
@ -548,20 +941,23 @@ MathJax.Hub.Config({
// this long, the menu will appear. (The menu also will appear if you
// click on the label.) It is in milliseconds.
//
delay: 400,
delay: 150,
//
// This is the URL for the MathJax Help menu item.
//
helpURL: "http://www.mathjax.org/help/user/",
helpURL: "http://www.mathjax.org/help-v2/user/",
//
// These control whether the "Math Renderer", "Font Preferences",
// and "Contextual Menu" submenus will be displayed or not.
// These control whether the "Math Renderer", "MathPlayer", "Font
// Preferences", "Contextual Menu", and "Discoverable" menu items will
// be displayed or not.
//
showRenderer: true,
showMathPlayer: true,
showFontMenu: false,
showContext: false,
showDiscoverable: false,
//
// These are the settings for the Show Source window. The initial
@ -582,6 +978,20 @@ MathJax.Hub.Config({
styles: {}
},
//============================================================================
//
// These parameters control the contextual menus that are available on the
// mathematics within the page (provided the showMathMenu value is true above).
//
MathEvents: {
//
// This is the time required for the mouse to be held still over a
// typeset equation in order for it to count as a hover (used when the
// zoom trigger is "Hover"). It is in milliseconds.
//
hover: 500
},
//============================================================================
//
@ -596,8 +1006,10 @@ MathJax.Hub.Config({
//
prefer: {
MSIE: "MML",
Firefox: "MML",
Firefox: "HTML",
Opera: "HTML",
Safari: "HTML",
Chrome: "HTML",
other: "HTML"
}
}

View File

@ -67,7 +67,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -83,7 +83,7 @@
*/
(function (HUB,HTML) {
var VERSION = "1.1";
var VERSION = "2.0";
var CONFIG = HUB.CombineConfig("FontWarnings",{
//
@ -91,7 +91,7 @@
//
messageStyle: {
position:"fixed", bottom:"4em", left:"3em", width:"40em",
border: "3px solid #880000", "background-color": "#E0E0E0",
border: "3px solid #880000", "background-color": "#E0E0E0", color: "black",
padding: "1em", "font-size":"small", "white-space":"normal",
"border-radius": ".75em", // Opera 10.5 and IE9
@ -113,7 +113,7 @@
webFont: [
["closeBox"],
"MathJax is using web-based fonts to display the mathematics ",
"on this page. These take time to download, so the page would",
"on this page. These take time to download, so the page would ",
"render faster if you installed math fonts directly in your ",
"system's font folder.",
["fonts"]
@ -180,7 +180,7 @@
"MathJax can use either the ",
["a",{href:"http://www.stixfonts.org/",target:"_blank"},"STIX fonts"],
" or the ",
["a",{href:"http://www.mathjax.org/help/fonts/",target:"_blank"},["MathJax TeX fonts"]],
["a",{href:"http://www.mathjax.org/help-v2/fonts/",target:"_blank"},["MathJax TeX fonts"]],
". Download and install either one to improve your MathJax experience."
],
@ -194,7 +194,7 @@
TeXfonts: [
["p"],
"This page is designed to use the ",
["a",{href:"http://www.mathjax.org/help/fonts/",target:"_blank"},["MathJax TeX fonts"]],
["a",{href:"http://www.mathjax.org/help-v2/fonts/",target:"_blank"},["MathJax TeX fonts"]],
". Download and install those fonts to improve your MathJax experience."
]

View File

@ -0,0 +1,79 @@
/*************************************************************
*
* MathJax/extensions/HTML-CSS/handle-floats.js
*
* This extension allows HTML-CSS output to deal with floating elements
* better. In particular, when there are tags or equation numbers, these
* would overlap floating elements, but with this extension, the width of
* the line should properly correspond to the amount of space remaining.
*
* To load it, include
*
* "HTML-CSS": {
* extensions: ["handle-floats.js"]
* }
*
* in your configuration.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJAx.Extension["HTML-CSS/handle-floats"] = {
version: "2.0"
};
//
// Make the display DIV be a table-cell
// Use padding to get the separation, since table cells don't do margin
// Make the width large (it will shrink to fit the remaining room)
//
MathJax.Hub.Config({
"HTML-CSS": {
styles: {
".MathJax_Display": {
display: "table-cell",
padding: "1em 0 ! important",
width: (MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 8 ? "100%" : "1000em")
}
}
}
});
//
// Two consecutive equations would end up side-by-side, so force a separator
// (Needed by IE8, IE9, and Firefox, at least).
//
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"],
TRANSLATE = HTMLCSS.Translate;
HTMLCSS.Augment({
Translate: function (script,state) {
TRANSLATE.call(this,script,state);
if (script.MathJax.elementJax.HTMLCSS.display) {
var next = script.nextSibling;
if (!next || next.className !== "MathJax_MSIE_Separator") {
var span = HTMLCSS.Element("span",{className:"MathJax_MSIE_Separator"});
script.parentNode.insertBefore(span,next);
}
}
}
});
MathJax.Hub.Startup.signal.Post("HTML-CSS handle-floats Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/HTML-CSS/handle-floats.js");

531
modules/MathJax/extensions/MathEvents.js vendored Normal file
View File

@ -0,0 +1,531 @@
/*************************************************************
*
* MathJax/extensions/MathEvents.js
*
* Implements the event handlers needed by the output jax to perform
* menu, hover, and other events.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function (HUB,HTML,AJAX,CALLBACK,OUTPUT,INPUT) {
var VERSION = "2.0";
var EXTENSION = MathJax.Extension;
var ME = EXTENSION.MathEvents = {version: VERSION};
var SETTINGS = HUB.config.menuSettings;
var CONFIG = {
hover: 500, // time required to be considered a hover
frame: {
x: 3.5, y: 5, // frame padding and
bwidth: 1, // frame border width (in pixels)
bcolor: "#A6D", // frame border color
hwidth: "15px", // haze width
hcolor: "#83A" // haze color
},
button: {
x: -4, y: -3, // menu button offsets
wx: -2, // button offset for full-width equations
src: AJAX.fileURL(OUTPUT.imageDir+"/MenuArrow-15.png") // button image
},
fadeinInc: .2, // increment for fade-in
fadeoutInc: .05, // increment for fade-out
fadeDelay: 50, // delay between fade-in or fade-out steps
fadeoutStart: 400, // delay before fade-out after mouseout
fadeoutDelay: 15*1000, // delay before automatic fade-out
styles: {
".MathJax_Hover_Frame": {
"border-radius": ".25em", // Opera 10.5 and IE9
"-webkit-border-radius": ".25em", // Safari and Chrome
"-moz-border-radius": ".25em", // Firefox
"-khtml-border-radius": ".25em", // Konqueror
"box-shadow": "0px 0px 15px #83A", // Opera 10.5 and IE9
"-webkit-box-shadow": "0px 0px 15px #83A", // Safari and Chrome
"-moz-box-shadow": "0px 0px 15px #83A", // Forefox
"-khtml-box-shadow": "0px 0px 15px #83A", // Konqueror
border: "1px solid #A6D ! important",
display: "inline-block", position:"absolute"
},
".MathJax_Hover_Arrow": {
position:"absolute",
width:"15px", height:"11px",
cursor:"pointer"
}
}
};
//
// Common event-handling code
//
var EVENT = ME.Event = {
LEFTBUTTON: 0, // the event.button value for left button
RIGHTBUTTON: 2, // the event.button value for right button
MENUKEY: "altKey", // the event value for alternate context menu
Mousedown: function (event) {return EVENT.Handler(event,"Mousedown",this)},
Mouseup: function (event) {return EVENT.Handler(event,"Mouseup",this)},
Mousemove: function (event) {return EVENT.Handler(event,"Mousemove",this)},
Mouseover: function (event) {return EVENT.Handler(event,"Mouseover",this)},
Mouseout: function (event) {return EVENT.Handler(event,"Mouseout",this)},
Click: function (event) {return EVENT.Handler(event,"Click",this)},
DblClick: function (event) {return EVENT.Handler(event,"DblClick",this)},
Menu: function (event) {return EVENT.Handler(event,"ContextMenu",this)},
//
// Call the output jax's event handler or the zoom handler
//
Handler: function (event,type,math) {
if (AJAX.loadingMathMenu) {return EVENT.False(event)}
var jax = OUTPUT[math.jaxID];
if (!event) {event = window.event}
event.isContextMenu = (type === "ContextMenu");
if (jax[type]) {return jax[type](event,math)}
if (EXTENSION.MathZoom) {return EXTENSION.MathZoom.HandleEvent(event,type,math)}
},
//
// Try to cancel the event in every way we can
//
False: function (event) {
if (!event) {event = window.event}
if (event) {
if (event.preventDefault) {event.preventDefault()}
if (event.stopPropagation) {event.stopPropagation()}
event.cancelBubble = true;
event.returnValue = false;
}
return false;
},
//
// Load the contextual menu code, if needed, and post the menu
//
ContextMenu: function (event,math,force) {
//
// Check if we are showing menus
//
var JAX = OUTPUT[math.jaxID], jax = JAX.getJaxFromMath(math);
var show = (JAX.config.showMathMenu != null ? JAX : HUB).config.showMathMenu;
if (!show || (SETTINGS.context !== "MathJax" && !force)) return;
//
// Remove selections, remove hover fades
//
if (ME.msieEventBug) {event = window.event || event}
EVENT.ClearSelection(); HOVER.ClearHoverTimer();
if (jax.hover) {
if (jax.hover.remove) {clearTimeout(jax.hover.remove); delete jax.hover.remove}
jax.hover.nofade = true;
}
//
// If the menu code is loaded, post the menu
// Otherwse lad the menu code and try again
//
var MENU = MathJax.Menu;
if (MENU) {
MENU.jax = jax;
var source = MENU.menu.Find("Show Math As").menu;
source.items[1].name = (INPUT[jax.inputJax].sourceMenuTitle||"Original Form");
source.items[0].hidden = (jax.inputJax === "Error"); // hide MathML choice for error messages
var MathPlayer = MENU.menu.Find("Math Settings","MathPlayer");
MathPlayer.hidden = !(jax.outputJax === "NativeMML" && HUB.Browser.hasMathPlayer);
return MENU.menu.Post(event);
} else {
if (!AJAX.loadingMathMenu) {
AJAX.loadingMathMenu = true;
var ev = {
pageX:event.pageX, pageY:event.pageY,
clientX:event.clientX, clientY:event.clientY
};
CALLBACK.Queue(
AJAX.Require("[MathJax]/extensions/MathMenu.js"),
function () {delete AJAX.loadingMathMenu; if (!MathJax.Menu) {MathJax.Menu = {}}},
["ContextMenu",this,ev,math,force] // call this function again
);
}
return EVENT.False(event);
}
},
//
// Mousedown handler for alternate means of accessing menu
//
AltContextMenu: function (event,math) {
var JAX = OUTPUT[math.jaxID];
var show = (JAX.config.showMathMenu != null ? JAX : HUB).config.showMathMenu;
if (show) {
show = (JAX.config.showMathMenuMSIE != null ? JAX : HUB).config.showMathMenuMSIE;
if (SETTINGS.context === "MathJax" && !SETTINGS.mpContext && show) {
if (!ME.noContextMenuBug || event.button !== EVENT.RIGHTBUTTON) return;
} else {
if (!event[EVENT.MENUKEY] || event.button !== EVENT.LEFTBUTTON) return;
}
return JAX.ContextMenu(event,math,true);
}
},
ClearSelection: function () {
if (ME.safariContextMenuBug) {setTimeout("window.getSelection().empty()",0)}
if (document.selection) {setTimeout("document.selection.empty()",0)}
},
getBBox: function (span) {
span.appendChild(ME.topImg);
var h = ME.topImg.offsetTop, d = span.offsetHeight-h, w = span.offsetWidth;
span.removeChild(ME.topImg);
return {w:w, h:h, d:d};
}
};
//
// Handle hover "discoverability"
//
var HOVER = ME.Hover = {
//
// Check if we are moving from a non-MathJax element to a MathJax one
// and either start fading in again (if it is fading out) or start the
// timer for the hover
//
Mouseover: function (event,math) {
if (SETTINGS.discoverable || SETTINGS.zoom === "Hover") {
var from = event.fromElement || event.relatedTarget,
to = event.toElement || event.target;
if (from && to && (from.isMathJax != to.isMathJax ||
HUB.getJaxFor(from) !== HUB.getJaxFor(to))) {
var jax = this.getJaxFromMath(math);
if (jax.hover) {HOVER.ReHover(jax)} else {HOVER.HoverTimer(jax,math)}
return EVENT.False(event);
}
}
},
//
// Check if we are moving from a MathJax element to a non-MathJax one
// and either start fading out, or clear the timer if we haven't
// hovered yet
//
Mouseout: function (event,math) {
if (SETTINGS.discoverable || SETTINGS.zoom === "Hover") {
var from = event.fromElement || event.relatedTarget,
to = event.toElement || event.target;
if (from && to && (from.isMathJax != to.isMathJax ||
HUB.getJaxFor(from) !== HUB.getJaxFor(to))) {
var jax = this.getJaxFromMath(math);
if (jax.hover) {HOVER.UnHover(jax)} else {HOVER.ClearHoverTimer()}
return EVENT.False(event);
}
}
},
//
// Restart hover timer if the mouse moves
//
Mousemove: function (event,math) {
if (SETTINGS.discoverable || SETTINGS.zoom === "Hover") {
var jax = this.getJaxFromMath(math); if (jax.hover) return;
if (HOVER.lastX == event.clientX && HOVER.lastY == event.clientY) return;
HOVER.lastX = event.clientX; HOVER.lastY = event.clientY;
HOVER.HoverTimer(jax,math);
return EVENT.False(event);
}
},
//
// Clear the old timer and start a new one
//
HoverTimer: function (jax,math) {
this.ClearHoverTimer();
this.hoverTimer = setTimeout(CALLBACK(["Hover",this,jax,math]),CONFIG.hover);
},
ClearHoverTimer: function () {
if (this.hoverTimer) {clearTimeout(this.hoverTimer); delete this.hoverTimer}
},
//
// Handle putting up the hover frame
//
Hover: function (jax,math) {
//
// Check if Zoom handles the hover event
//
if (EXTENSION.MathZoom && EXTENSION.MathZoom.Hover({},math)) return;
//
// Get the hover data
//
var JAX = OUTPUT[jax.outputJax],
span = JAX.getHoverSpan(jax,math),
bbox = JAX.getHoverBBox(jax,span,math),
show = (JAX.config.showMathMenu != null ? JAX : HUB).config.showMathMenu;
var dx = CONFIG.frame.x, dy = CONFIG.frame.y, dd = CONFIG.frame.bwidth; // frame size
if (ME.msieBorderWidthBug) {dd = 0}
jax.hover = {opacity:0, id:jax.inputID+"-Hover"};
//
// The frame and menu button
//
var frame = HTML.Element("span",{
id:jax.hover.id, isMathJax: true,
style:{display:"inline-block", width:0, height:0, position:"relative"}
},[["span",{
className:"MathJax_Hover_Frame", isMathJax: true,
style:{
display:"inline-block", position:"absolute",
top:this.Px(-bbox.h-dy-dd-(bbox.y||0)), left:this.Px(-dx-dd+(bbox.x||0)),
width:this.Px(bbox.w+2*dx), height:this.Px(bbox.h+bbox.d+2*dy),
opacity:0, filter:"alpha(opacity=0)"
}}
]]
);
var button = HTML.Element("span",{
isMathJax: true, id:jax.hover.id+"Menu",
style:{display:"inline-block", "z-index": 1, width:0, height:0, position:"relative"}
},[["img",{
className: "MathJax_Hover_Arrow", isMathJax: true, math: math,
src: CONFIG.button.src, onclick: this.HoverMenu, jax:JAX.id,
style: {
left:this.Px(bbox.w+dx+dd+(bbox.x||0)+CONFIG.button.x),
top:this.Px(-bbox.h-dy-dd-(bbox.y||0)-CONFIG.button.y),
opacity:0, filter:"alpha(opacity=0)"
}
}]]
);
if (bbox.width) {
frame.style.width = button.style.width = bbox.width;
frame.style.marginRight = button.style.marginRight = "-"+bbox.width;
frame.firstChild.style.width = bbox.width;
button.firstChild.style.left = "";
button.firstChild.style.right = this.Px(CONFIG.button.wx);
}
//
// Add the frame and button
//
span.parentNode.insertBefore(frame,span);
if (show) {span.parentNode.insertBefore(button,span)}
if (span.style) {span.style.position = "relative"} // so math is on top of hover frame
//
// Start the hover fade-in
//
this.ReHover(jax);
},
//
// Restart the hover fade in and fade-out timers
//
ReHover: function (jax) {
if (jax.hover.remove) {clearTimeout(jax.hover.remove)}
jax.hover.remove = setTimeout(CALLBACK(["UnHover",this,jax]),CONFIG.fadeoutDelay);
this.HoverFadeTimer(jax,CONFIG.fadeinInc);
},
//
// Start the fade-out
//
UnHover: function (jax) {
if (!jax.hover.nofade) {this.HoverFadeTimer(jax,-CONFIG.fadeoutInc,CONFIG.fadeoutStart)}
},
//
// Handle the fade-in and fade-out
//
HoverFade: function (jax) {
delete jax.hover.timer;
jax.hover.opacity = Math.max(0,Math.min(1,jax.hover.opacity + jax.hover.inc));
jax.hover.opacity = Math.floor(1000*jax.hover.opacity)/1000;
var frame = document.getElementById(jax.hover.id),
button = document.getElementById(jax.hover.id+"Menu");
frame.firstChild.style.opacity = jax.hover.opacity;
frame.firstChild.style.filter = "alpha(opacity="+Math.floor(100*jax.hover.opacity)+")";
if (button) {
button.firstChild.style.opacity = jax.hover.opacity;
button.firstChild.style.filter = frame.style.filter;
}
if (jax.hover.opacity === 1) {return}
if (jax.hover.opacity > 0) {this.HoverFadeTimer(jax,jax.hover.inc); return}
frame.parentNode.removeChild(frame);
if (button) {button.parentNode.removeChild(button)}
if (jax.hover.remove) {clearTimeout(jax.hover.remove)}
delete jax.hover;
},
//
// Set the fade to in or out (via inc) and start the timer, if needed
//
HoverFadeTimer: function (jax,inc,delay) {
jax.hover.inc = inc;
if (!jax.hover.timer) {
jax.hover.timer = setTimeout(CALLBACK(["HoverFade",this,jax]),(delay||CONFIG.fadeDelay));
}
},
//
// Handle a click on the menu button
//
HoverMenu: function (event) {
if (!event) {event = window.event}
return OUTPUT[this.jax].ContextMenu(event,this.math,true);
},
//
// Clear all hover timers
//
ClearHover: function (jax) {
if (jax.hover.remove) {clearTimeout(jax.hover.remove)}
if (jax.hover.timer) {clearTimeout(jax.hover.timer)}
HOVER.ClearHoverTimer();
delete jax.hover;
},
//
// Make a measurement in pixels
//
Px: function (m) {
if (Math.abs(m) < .006) {return "0px"}
return m.toFixed(2).replace(/\.?0+$/,"") + "px";
},
//
// Preload images so they show up with the menu
//
getImages: function () {
var menu = new Image();
menu.src = CONFIG.button.src;
}
};
//
// Handle touch events.
//
// Use double-tap-and-hold as a replacement for context menu event.
// Use double-tap as a replacement for double click.
//
var TOUCH = ME.Touch = {
last: 0, // time of last tap event
delay: 500, // delay time for double-click
//
// Check if this is a double-tap, and if so, start the timer
// for the double-tap and hold (to trigger the contextual menu)
//
start: function (event) {
var now = new Date().getTime();
var dblTap = (now - TOUCH.last < TOUCH.delay);
TOUCH.last = now;
if (dblTap) {
TOUCH.timeout = setTimeout(TOUCH.menu,TOUCH.delay,event,this);
event.preventDefault();
}
},
//
// Check if there is a timeout pending, i.e., we have a
// double-tap and were waiting to see if it is held long
// enough for the menu. Since we got the end before the
// timeout, it is a double-click, not a double-tap-and-hold.
// Prevent the default action and issue a double click.
//
end: function (event) {
if (TOUCH.timeout) {
clearTimeout(TOUCH.timeout);
delete TOUCH.timeout; TOUCH.last = 0;
event.preventDefault();
return EVENT.Handler((event.touches[0]||event.touch),"DblClick",this);
}
},
//
// If the timeout passes without an end event, we issue
// the contextual menu event.
//
menu: function (event,math) {
delete TOUCH.timeout; TOUCH.last = 0;
return EVENT.Handler((event.touches[0]||event.touch),"ContextMenu",math);
}
};
//
// Mobile screens are small, so use larger version of arrow
//
if (HUB.Browser.isMobile) {
var arrow = CONFIG.styles[".MathJax_Hover_Arrow"];
arrow.width = "25px"; arrow.height = "18px";
CONFIG.button.x = -6;
}
//
// Set up browser-specific values
//
HUB.Browser.Select({
MSIE: function (browser) {
var mode = (document.documentMode || 0);
var isIE8 = browser.versionAtLeast("8.0");
ME.msieBorderWidthBug = (document.compatMode === "BackCompat"); // borders are inside offsetWidth/Height
ME.msieEventBug = browser.isIE9; // must get event from window even though event is passed
ME.msieAlignBug = (!isIE8 || mode < 8); // inline-block spans don't rest on baseline
if (mode < 9) {EVENT.LEFTBUTTON = 1} // IE < 9 has wrong event.button values
},
Safari: function (browser) {
ME.safariContextMenuBug = true; // selection can be started by contextmenu event
},
Opera: function (browser) {
ME.operaPositionBug = true; // position is wrong unless border is used
},
Konqueror: function (browser) {
ME.noContextMenuBug = true; // doesn't produce contextmenu event
}
});
//
// Used in measuring zoom and hover positions
//
ME.topImg = (ME.msieAlignBug ?
HTML.Element("img",{style:{width:0,height:0,position:"relative"},src:"about:blank"}) :
HTML.Element("span",{style:{width:0,height:0,display:"inline-block"}})
);
if (ME.operaPositionBug) {ME.topImg.style.border="1px solid"}
//
// Get configuration from user
//
ME.config = CONFIG = HUB.CombineConfig("MathEvents",CONFIG);
var SETFRAME = function () {
var haze = CONFIG.styles[".MathJax_Hover_Frame"];
haze.border = CONFIG.frame.bwidth+"px solid "+CONFIG.frame.bcolor+" ! important";
haze["box-shadow"] = haze["-webkit-box-shadow"] =
haze["-moz-box-shadow"] = haze["-khtml-box-shadow"] =
"0px 0px "+CONFIG.frame.hwidth+" "+CONFIG.frame.hcolor;
};
//
// Queue the events needed for startup
//
CALLBACK.Queue(
HUB.Register.StartupHook("End Config",{}), // wait until config is complete
[SETFRAME],
["getImages",HOVER],
["Styles",AJAX,CONFIG.styles],
["Post",HUB.Startup.signal,"MathEvents Ready"],
["loadComplete",AJAX,"[MathJax]/extensions/MathEvents.js"]
);
})(MathJax.Hub,MathJax.HTML,MathJax.Ajax,MathJax.Callback,MathJax.OutputJax,MathJax.InputJax);

View File

@ -8,7 +8,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,21 +23,29 @@
* limitations under the License.
*/
(function (HUB,HTML,AJAX) {
var VERSION = "1.1.4";
MathJax.Extension.MathMenu = {version: VERSION};
(function (HUB,HTML,AJAX,CALLBACK,OUTPUT) {
var VERSION = "2.0";
var isPC = HUB.Browser.isPC, isMSIE = HUB.Browser.isMSIE;
var SIGNAL = MathJax.Callback.Signal("menu") // signal for menu events
MathJax.Extension.MathMenu = {
version: VERSION,
signal: SIGNAL
};
var isPC = HUB.Browser.isPC, isMSIE = HUB.Browser.isMSIE, isIE9 = ((document.documentMode||0) > 8);
var ROUND = (isPC ? null : "5px");
var CONFIG = HUB.CombineConfig("MathMenu",{
delay: 150, // the delay for submenus
helpURL: "http://www.mathjax.org/help/user/", // the URL for the "MathJax Help" menu
helpURL: "http://www.mathjax.org/help-v2/user/", // the URL for the "MathJax Help" menu
closeImg: AJAX.fileURL(OUTPUT.imageDir+"/CloseX-31.png"), // image for close "X" for mobiles
showRenderer: true, // show the "Math Renderer" menu?
showMathPlayer: true, // show the "MathPlayer" menu?
showFontMenu: false, // show the "Font Preference" menu?
showContext: false, // show the "Context Menu" menu?
showDiscoverable: false, // show the "Discoverable" menu?
windowSettings: { // for source window
status: "no", toolbar: "no", locationbar: "no", menubar: "no",
@ -130,25 +138,22 @@
".MathJax_MenuActive": {
"background-color": (isPC ? "Highlight" : "#606872"),
color: (isPC ? "HighlightText" : "white")
},
".MathJax_Menu_Close": {
position:"absolute",
width: "31px", height: "31px",
top:"-15px", left:"-15px"
}
}
});
/*************************************************************/
/*
* Cancel event's default action (try everything we can)
*/
var FALSE = function (event) {
if (!event) {event = window.event}
if (event) {
if (event.preventDefault) {event.preventDefault()}
if (event.stopPropagation) {event.stopPropagation()}
event.cancelBubble = true;
event.returnValue = false;
}
return false;
};
var FALSE, HOVER;
HUB.Register.StartupHook("MathEvents Ready",function () {
FALSE = MathJax.Extension.MathEvents.Event.False;
HOVER = MathJax.Extension.MathEvents.Hover;
});
/*************************************************************/
/*
* The main menu class
@ -159,7 +164,7 @@
posted: false,
title: null,
margin: 5,
Init: function (def) {this.items = [].slice.call(arguments,0)},
With: function (def) {if (def) {HUB.Insert(this,def)}; return this},
@ -170,14 +175,25 @@
if (!event) {event = window.event};
var title = (!this.title ? null : [["div",{className: "MathJax_MenuTitle"},[this.title]]]);
var div = document.getElementById("MathJax_MenuFrame");
if (!div) {div = MENU.Background(this)}
if (!div) {
div = MENU.Background(this);
delete ITEM.lastItem; delete ITEM.lastMenu;
delete MENU.skipUp;
SIGNAL.Post(["post",MENU.jax]);
}
var menu = HTML.addElement(div,"div",{
onmouseup: MENU.Mouseup, ondblclick: this.False,
ondragstart: this.False, onselectstart: this.False, oncontextmenu: this.False,
onmouseup: MENU.Mouseup, ondblclick: FALSE,
ondragstart: FALSE, onselectstart: FALSE, oncontextmenu: FALSE,
menuItem: this, className: "MathJax_Menu"
},title);
for (var i = 0, m = this.items.length; i < m; i++) {this.items[i].Create(menu)}
if (MENU.isMobile) {
HTML.addElement(menu,"span",{
className: "MathJax_Menu_Close", menu: parent,
ontouchstart: MENU.Close, ontouchend: FALSE, onmousedown: MENU.Close, onmouseup: FALSE
},[["img",{src: CONFIG.closeImg, style:{width:"100%",height:"100%"}}]]);
}
this.posted = true;
menu.style.width = (menu.offsetWidth+2) + "px";
@ -189,15 +205,16 @@
if (!parent) {
if (x + menu.offsetWidth > document.body.offsetWidth - this.margin)
{x = document.body.offsetWidth - menu.offsetWidth - this.margin}
MENU.skipUp = true;
if (MENU.isMobile) {x = Math.max(5,x-Math.floor(menu.offsetWidth/2)); y -= 20}
MENU.skipUp = event.isContextMenu;
} else {
var side = "left", mw = parent.offsetWidth;
x = parent.offsetWidth - 2; y = 0;
x = (MENU.isMobile ? 30 : mw - 2); y = 0;
while (parent && parent !== div) {
x += parent.offsetLeft; y += parent.offsetTop;
parent = parent.parentNode;
}
if (x + menu.offsetWidth > document.body.offsetWidth - this.margin)
if (x + menu.offsetWidth > document.body.offsetWidth - this.margin && !MENU.isMobile)
{side = "right"; x = Math.max(this.margin,x - mw - menu.offsetWidth + 6)}
if (!isPC) {
// in case these ever get implemented
@ -211,36 +228,75 @@
menu.style.left = x+"px"; menu.style.top = y+"px";
if (document.selection && document.selection.empty) {document.selection.empty()}
return this.False(event);
return FALSE(event);
},
/*
* Remove the menu from the screen
*/
Remove: function (event,menu) {
SIGNAL.Post(["unpost",MENU.jax]);
var div = document.getElementById("MathJax_MenuFrame");
if (div) {
div.parentNode.removeChild(div);
if (this.msieBackgroundBug) {detachEvent("onresize",MENU.Resize)}
if (this.msieFixedPositionBug) {detachEvent("onresize",MENU.Resize)}
}
},
Mouseup: function (event,menu) {
if (MENU.skipUp) {delete MENU.skipUp} else {this.Remove(event,menu)}
if (MENU.jax.hover) {
delete MENU.jax.hover.nofade;
HOVER.UnHover(MENU.jax);
}
return FALSE(event);
},
False: FALSE
/*
* Find a named item in a menu (or submenu).
* A list of names means descend into submenus.
*/
Find: function (name) {
var names = [].slice.call(arguments,1);
for (var i = 0, m = this.items.length; i < m; i++) {
if (this.items[i].name === name) {
if (names.length) {
if (!this.items[i].menu) {return null}
return this.items[i].menu.Find.apply(this.items[i].menu,names);
}
return this.items[i];
}
}
return null;
},
/*
* Find the index of a menu item (so we can insert before or after it)
*/
IndexOf: function (name) {
for (var i = 0, m = this.items.length; i < m; i++)
{if (this.items[i].name === name) {return i}}
return null;
}
},{
config: CONFIG,
div: null, // the DOM elements for the menu and submenus
Remove: function (event) {MENU.Event(event,this,"Remove")},
Mouseover: function (event) {MENU.Event(event,this,"Mouseover")},
Mouseout: function (event) {MENU.Event(event,this,"Mouseout")},
Mousedown: function (event) {MENU.Event(event,this,"Mousedown")},
Mouseup: function (event) {MENU.Event(event,this,"Mouseup")},
Mousemove: function (event) {MENU.Event(event,this,"Mousemove")},
Event: function (event,menu,type) {
Close: function (event)
{return MENU.Event(event,this.menu||this.parentNode,(this.menu?"Touchend":"Remove"))},
Remove: function (event) {return MENU.Event(event,this,"Remove")},
Mouseover: function (event) {return MENU.Event(event,this,"Mouseover")},
Mouseout: function (event) {return MENU.Event(event,this,"Mouseout")},
Mousedown: function (event) {return MENU.Event(event,this,"Mousedown")},
Mouseup: function (event) {return MENU.Event(event,this,"Mouseup")},
Touchstart: function (event) {return MENU.Event(event,this,"Touchstart")},
Touchend: function (event) {return MENU.Event(event,this,"Touchend")},
Event: function (event,menu,type,force) {
if (MENU.skipMouseover && type === "Mouseover" && !force) {return FALSE(event)}
if (MENU.skipUp) {
if (type.match(/Mouseup|Touchend/)) {delete MENU.skipUp; return FALSE(event)}
if (type === "Touchstart" ||
(type === "Mousedown" && !MENU.skipMousedown)) {delete MENU.skipUp}
}
if (!event) {event = window.event}
var item = menu.menuItem;
if (item && item[type]) {return item[type](event,menu)}
@ -263,6 +319,8 @@
// MSIE doesn't allow transparent background to be hit boxes, so
// fake it using opacity with solid background color
bg.style.backgroundColor = "white"; bg.style.filter = "alpha(opacity=0)";
}
if (menu.msieFixedPositionBug) {
// MSIE can't do fixed position, so use a full-sized background
// and an onresize handler to update it (stupid, but necessary)
div.width = div.height = 0; this.Resize();
@ -285,7 +343,14 @@
},
saveCookie: function () {HTML.Cookie.Set("menu",this.cookie)},
getCookie: function () {this.cookie = HTML.Cookie.Get("menu")}
getCookie: function () {this.cookie = HTML.Cookie.Get("menu")},
//
// Preload images so they show up with the menu
//
getImages: function () {
if (MENU.isMobile) {var close = new Image(); close.src = CONFIG.closeImg}
}
});
@ -300,8 +365,9 @@
if (!this.hidden) {
var def = {
onmouseover: MENU.Mouseover, onmouseout: MENU.Mouseout,
onmouseup: MENU.Mouseup, onmousedown: this.False,
ondragstart: this.False, onselectstart: this.False, onselectend: this.False,
onmouseup: MENU.Mouseup, onmousedown: MENU.Mousedown,
ondragstart: FALSE, onselectstart: FALSE, onselectend: FALSE,
ontouchstart: MENU.Touchstart, ontouchend: MENU.Touchend,
className: "MathJax_MenuItem", menuItem: this
};
if (this.disabled) {def.className += " MathJax_MenuDisabled"}
@ -324,7 +390,7 @@
menus[m].parentNode.removeChild(menus[m]);
m--;
}
if (this.Timer) {this.Timer(event,menu)}
if (this.Timer && !MENU.isMobile) {this.Timer(event,menu)}
}
},
Mouseout: function (event,menu) {
@ -332,7 +398,20 @@
if (this.timer) {clearTimeout(this.timer); delete this.timer}
},
Mouseup: function (event,menu) {return this.Remove(event,menu)},
Touchstart: function (event,menu) {return this.TouchEvent(event,menu,"Mousedown")},
Touchend: function (event,menu) {return this.TouchEvent(event,menu,"Mouseup")},
TouchEvent: function (event,menu,type) {
if (this !== ITEM.lastItem) {
if (ITEM.lastMenu) {MENU.Event(event,ITEM.lastMenu,"Mouseout")}
MENU.Event(event,menu,"Mouseover",true);
ITEM.lastItem = this; ITEM.lastMenu = menu;
}
if (this.nativeTouch) {return null}
MENU.Event(event,menu,type);
return false;
},
Remove: function (event,menu) {
menu = menu.parentNode.menuItem;
return menu.Remove(event,menu);
@ -341,8 +420,7 @@
Activate: function (menu) {this.Deactivate(menu); menu.className += " MathJax_MenuActive"},
Deactivate: function (menu) {menu.className = menu.className.replace(/ MathJax_MenuActive/,"")},
With: function (def) {if (def) {HUB.Insert(this,def)}; return this},
False: FALSE
With: function (def) {if (def) {HUB.Insert(this,def)}; return this}
});
/*************************************************************/
@ -356,10 +434,15 @@
this.name = name; this.action = action;
this.With(def);
},
Label: function (def,menu) {return [this.name]},
Mouseup: function (event,menu) {
if (!this.disabled) {this.Remove(event,menu); this.action.call(this,event)}
return this.False(event);
if (!this.disabled) {
this.Remove(event,menu);
SIGNAL.Post(["command",this]);
this.action.call(this,event);
}
return FALSE(event);
}
});
@ -377,13 +460,19 @@
this.menu = MENU.apply(MENU,[].slice.call(arguments,i));
},
Label: function (def,menu) {
def.onmousemove = MENU.Mousemove; this.menu.posted = false;
this.menu.posted = false;
return [this.name+" ",["span",{className:"MathJax_MenuArrow"},[this.marker]]];
},
Timer: function (event,menu) {
if (this.timer) {clearTimeout(this.timer)}
event = {clientX: event.clientX, clientY: event.clientY}; // MSIE can't pass the event below
this.timer = setTimeout(MathJax.Callback(["Mouseup",this,event,menu]),CONFIG.delay);
this.timer = setTimeout(CALLBACK(["Mouseup",this,event,menu]),CONFIG.delay);
},
Touchend: function (event,menu) {
var forceout = this.menu.posted;
var result = this.SUPER(arguments).Touchend.apply(this,arguments);
if (forceout) {this.Deactivate(menu); delete ITEM.lastItem; delete ITEM.lastMenu}
return result;
},
Mouseup: function (event,menu) {
if (!this.disabled) {
@ -391,7 +480,7 @@
if (this.timer) {clearTimeout(this.timer); delete this.timer}
this.menu.Post(event,menu);
} else {
var menus = document.getElementById("MathJax_MenuFrame").childNodes,
var menus = document.getElementById("MathJax_MenuFrame").childNodes,
m = menus.length-1;
while (m >= 0) {
var child = menus[m];
@ -402,7 +491,7 @@
}
}
}
return this.False(event);
return FALSE(event);
}
});
@ -434,10 +523,11 @@
menu.firstChild.display = "";
CONFIG.settings[this.variable] = this.value;
MENU.cookie[this.variable] = CONFIG.settings[this.variable]; MENU.saveCookie();
if (this.action) {this.action.call(MENU)}
SIGNAL.Post(["radio button",this]);
}
this.Remove(event,menu);
return this.False(event);
if (this.action && !this.disabled) {this.action.call(MENU,this)}
return FALSE(event);
}
});
@ -462,10 +552,11 @@
menu.firstChild.display = (CONFIG.settings[this.variable] ? "none" : "");
CONFIG.settings[this.variable] = !CONFIG.settings[this.variable];
MENU.cookie[this.variable] = CONFIG.settings[this.variable]; MENU.saveCookie();
if (this.action) {this.action.call(MENU)}
SIGNAL.Post(["checkbox",this]);
}
this.Remove(event,menu);
return this.False(event);
if (this.action && !this.disabled) {this.action.call(MENU,this)}
return FALSE(event);
}
});
@ -501,9 +592,10 @@
* Handle the ABOUT box
*/
MENU.About = function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"] || {fontInUse: ""};
var HTMLCSS = OUTPUT["HTML-CSS"] || {fontInUse: ""};
var local = (HTMLCSS.webFonts ? "" : "local "), web = (HTMLCSS.webFonts ? " web" : "");
var font = (HTMLCSS.imgFonts ? "Image" : local+HTMLCSS.fontInUse+web) + " fonts";
if (font === "local fonts" && OUTPUT.SVG) {font = "web SVG fonts"}
var jax = ["MathJax.js v"+MathJax.fileversion,["br"]];
jax.push(["div",{style:{"border-top":"groove 2px",margin:".25em 0"}}]);
MENU.About.GetJax(jax,MathJax.InputJax,"Input Jax");
@ -513,16 +605,17 @@
MENU.About.GetJax(jax,MathJax.Extension,"Extension",true);
jax.push(["div",{style:{"border-top":"groove 2px",margin:".25em 0"}}],["center",{},[
HUB.Browser + " v"+HUB.Browser.version +
(HTMLCSS.webFonts ? " \u2014 "+HTMLCSS.allowWebFonts+" fonts" : "")
(HTMLCSS.webFonts && !HTMLCSS.imgFonts ? " \u2014 "+HTMLCSS.allowWebFonts+" fonts" : "")
]]);
MENU.About.div = MENU.Background(MENU.About);
var about = MathJax.HTML.addElement(MENU.About.div,"div",{
var about = HTML.addElement(MENU.About.div,"div",{
id: "MathJax_About", onclick: MENU.About.Remove
},[
["b",{style:{fontSize:"120%"}},["MathJax"]]," v"+MathJax.version,["br"],
"using "+font,["br"],["br"],
["span",{style:{
display:"inline-block", "text-align":"left", "font-size":"80%",
"max-height":"20em", overflow:"auto",
"background-color":"#E4E4E4", padding:".4em .6em", border:"1px inset"
}},jax],["br"],["br"],
["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]]
@ -542,10 +635,13 @@
if (MENU.About.div) {document.body.removeChild(MENU.About.div); delete MENU.About.div}
};
MENU.About.GetJax = function (jax,JAX,type,noTypeCheck) {
var info = [];
for (var id in JAX) {if (JAX.hasOwnProperty(id) && JAX[id]) {
if ((noTypeCheck && JAX[id].version) || (JAX[id].isa && JAX[id].isa(JAX)))
{jax.push((JAX[id].id||id)+" "+type+" v"+JAX[id].version,["br"])}
{info.push((JAX[id].id||id)+" "+type+" v"+JAX[id].version)}
}}
info.sort();
for (var i = 0, m = info.length; i < m; i++) {jax.push(info[i],["br"])}
return jax;
};
@ -564,26 +660,29 @@
if (!event) {event = window.event}
var EVENT = {screenX:event.screenX, screenY:event.screenY};
if (!MENU.jax) return;
if (CONFIG.settings.format === "MathML") {
if (this.format === "MathML") {
var MML = MathJax.ElementJax.mml;
if (MML && typeof(MML.mbase.prototype.toMathML) !== "undefined") {
// toMathML() can call MathJax.Hub.RestartAfter, so trap errors and check
try {MENU.ShowSource.Text(MENU.jax.root.toMathML(),event)} catch (err) {
if (!err.restart) {throw err}
MathJax.Callback.After([this,arguments.callee,EVENT]);
CALLBACK.After([this,MENU.ShowSource,EVENT]);
}
} else if (!AJAX.loadingToMathML) {
AJAX.loadingToMathML = true;
MENU.ShowSource.Window(event); // WeBKit needs to open window on click event
MathJax.Callback.Queue(
CALLBACK.Queue(
AJAX.Require("[MathJax]/extensions/toMathML.js"),
function () {delete AJAX.loadingToMathML},
[this,arguments.callee,EVENT] // call this function again
function () {
delete AJAX.loadingToMathML;
if (!MML.mbase.prototype.toMathML) {MML.mbase.prototype.toMathML = function () {}}
},
[this,MENU.ShowSource,EVENT] // call this function again
);
return;
}
} else {
if (MENU.jax.originalText == null) {alert("No TeX form available"); return}
if (MENU.jax.originalText == null) {alert("No original form available"); return}
MENU.ShowSource.Text(MENU.jax.originalText,event);
}
};
@ -599,19 +698,29 @@
var w = MENU.ShowSource.Window(event);
text = text.replace(/^\s*/,"").replace(/\s*$/,"");
text = text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
w.document.open();
w.document.write("<html><head><title>MathJax Equation Source</title></head><body style='font-size:85%'>");
w.document.write("<table><tr><td><pre>"+text+"</pre></td></tr></table>");
w.document.write("</body></html>"); w.document.close();
var table = w.document.body.firstChild;
var H = (w.outerHeight-w.innerHeight)||30, W = (w.outerWidth-w.innerWidth)||30;
W = Math.min(Math.floor(.5*screen.width),table.offsetWidth+W+25);
H = Math.min(Math.floor(.5*screen.height),table.offsetHeight+H+25);
w.resizeTo(W,H);
if (event && event.screenX != null) {
var x = Math.max(0,Math.min(event.screenX-Math.floor(W/2), screen.width-W-20)),
y = Math.max(0,Math.min(event.screenY-Math.floor(H/2), screen.height-H-20));
w.moveTo(x,y);
if (MENU.isMobile) {
w.document.open();
w.document.write("<html><head><meta name='viewport' content='width=device-width, initial-scale=1.0' /><title>MathJax Equation Source</title></head><body style='font-size:85%'>");
w.document.write("<pre>"+text+"</pre>");
w.document.write("<hr><input type='button' value='Close' onclick='window.close()' />");
w.document.write("</body></html>");
w.document.close();
} else {
w.document.open();
w.document.write("<html><head><title>MathJax Equation Source</title></head><body style='font-size:85%'>");
w.document.write("<table><tr><td><pre>"+text+"</pre></td></tr></table>");
w.document.write("</body></html>");
w.document.close();
var table = w.document.body.firstChild;
var H = (w.outerHeight-w.innerHeight)||30, W = (w.outerWidth-w.innerWidth)||30;
W = Math.min(Math.floor(.5*screen.width),table.offsetWidth+W+25);
H = Math.min(Math.floor(.5*screen.height),table.offsetHeight+H+25);
w.resizeTo(W,H);
if (event && event.screenX != null) {
var x = Math.max(0,Math.min(event.screenX-Math.floor(W/2), screen.width-W-20)),
y = Math.max(0,Math.min(event.screenY-Math.floor(H/2), screen.height-H-20));
w.moveTo(x,y);
}
}
delete MENU.ShowSource.w;
};
@ -620,7 +729,7 @@
* Handle rescaling all the math
*/
MENU.Scale = function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"], nMML = MathJax.OutputJax.NativeMML;
var HTMLCSS = OUTPUT["HTML-CSS"], nMML = OUTPUT.NativeMML;
var SCALE = (HTMLCSS ? HTMLCSS.config.scale : nMML.config.scale);
var scale = prompt("Scale all mathematics (compared to surrounding text) by",SCALE+"%");
if (scale) {
@ -649,29 +758,104 @@
* Handle changing the renderer
*/
MENU.Renderer = function () {
var jax = HUB.config.outputJax["jax/mml"];
var jax = HUB.outputJax["jax/mml"];
if (jax[0] !== CONFIG.settings.renderer) {
MathJax.Callback.Queue(
["Require",AJAX,"[MathJax]/jax/output/"+CONFIG.settings.renderer+"/config.js"],
["Post",HUB.Startup.signal,CONFIG.settings.renderer+" output selected"],
[function () {
var JAX = MathJax.OutputJax[CONFIG.settings.renderer];
for (var i = 0, m = jax.length; i < m; i++)
{if (jax[i] === JAX) {jax.splice(i,1); break}}
jax.unshift(JAX);
}],
["Reprocess",HUB]
var BROWSER = HUB.Browser, message, MESSAGE = MENU.Renderer.Messages, warned;
//
// Check that the new renderer is appropriate for the browser
//
switch (CONFIG.settings.renderer) {
case "NativeMML":
if (!CONFIG.settings.warnedMML) {
if (BROWSER.isChrome || (BROWSER.isSafari && !BROWSER.versionAtLeast("5.0"))) {message = MESSAGE.MML.WebKit}
else if (BROWSER.isMSIE) {if (!BROWSER.hasMathPlayer) {message = MESSAGE.MML.MSIE}}
else {message = MESSAGE.MML[BROWSER]}
warned = "warnedMML";
}
break;
case "SVG":
if (!CONFIG.settings.warnedSVG) {
if (BROWSER.isMSIE && !isIE9) {message = MESSAGE.SVG.MSIE}
}
break;
}
if (message) {
message += "\n\nSwitch the renderer anyway?\n\n" +
"(Press OK to switch, CANCEL to continue with the current renderer)";
MENU.cookie.renderer = jax[0].id; MENU.saveCookie(); if (!confirm(message)) {return}
if (warned) {MENU.cookie[warned] = CONFIG.settings[warned] = true}
MENU.cookie.renderer = CONFIG.settings.renderer; MENU.saveCookie();
}
HUB.Queue(
["setRenderer",HUB,CONFIG.settings.renderer,"jax/mml"],
["Rerender",HUB]
);
}
};
MENU.Renderer.Messages = {
MML: {
WebKit: "Your browser doesn't seem to support MathML natively, " +
"so switching to MathML output may cause the mathematics " +
"on the page to become unreadable.",
MSIE: "Internet Explorer requires the MathPlayer plugin " +
"in order to process MathML output.",
Opera: "Opera's support for MathML is limited, so switching to " +
"MathML output may cause some expressions to render poorly.",
Firefox: "Your browser's native MathML does not implement all the features " +
"used by MathJax, so some expressions my render improperly."
},
SVG: {
MSIE: "SVG is not implemented in Internet Explorer prior to " +
"IE9, or when the browser is emulating IE8 or below. " +
"Switching to SVG output will cause the mathemtics to " +
"not display properly."
}
};
/*
* Handle setting the HTMLCSS fonts
*/
MENU.Font = function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"]; if (!HTMLCSS) return;
var HTMLCSS = OUTPUT["HTML-CSS"]; if (!HTMLCSS) return;
document.location.reload();
};
/*
* Handle setting MathPlayer events
*/
MENU.MPEvents = function (item) {
var discoverable = CONFIG.settings.discoverable,
MESSAGE = MENU.MPEvents.Messages;
if (!isIE9) {
if (CONFIG.settings.mpMouse && !confirm(MESSAGE.IE8warning)) {
delete MENU.cookie.mpContext; delete CONFIG.settings.mpContext;
delete MENU.cookie.mpMouse; delete CONFIG.settings.mpMouse;
MENU.saveCookie();
return;
}
CONFIG.settings.mpContext = CONFIG.settings.mpMouse;
MENU.cookie.mpContext = MENU.cookie.mpMouse = CONFIG.settings.mpMouse;
MENU.saveCookie();
MathJax.Hub.Queue(["Rerender",MathJax.Hub])
} else if (!discoverable && item.name === "Menu Events" && CONFIG.settings.mpContext) {
alert(MESSAGE.IE9warning);
}
};
MENU.MPEvents.Messages = {
IE8warning:
"This will disable the MathJax menu and zoom features, " +
"but you can Alt-Click on an expression to obtain the MathJax " +
"menu instead.\n\nReally change the MathPlayer settings?",
IE9warning:
"The MathJax contextual menu will be disabled, but you can " +
"Alt-Click on an expression to obtain the MathJax menu instead."
};
/*************************************************************/
/*************************************************************/
@ -682,15 +866,22 @@
var isIE8 = browser.versionAtLeast("8.0") && document.documentMode > 7;
MENU.Augment({
margin: 20,
msieBackgroundBug: (quirks || !isIE8),
msieBackgroundBug: true,
msieFixedPositionBug: (quirks || !isIE8),
msieAboutBug: quirks
});
if (document.documentMode >= 9) {
if (isIE9) {
delete CONFIG.styles["#MathJax_About"].filter;
delete CONFIG.styles[".MathJax_Menu"].filter;
}
},
Firefox: function (browser) {
MENU.skipMouseover = browser.isMobile && browser.versionAtLeast("6.0");
MENU.skipMousedown = browser.isMobile;
}
});
MENU.isMobile = HUB.Browser.isMobile;
MENU.noContextMenu = HUB.Browser.noContextMenu;
/*************************************************************/
@ -702,8 +893,6 @@
* it wasn't set in the cookie.
*/
CONFIG.settings = HUB.config.menuSettings;
if (!CONFIG.settings.format)
{CONFIG.settings.format = (MathJax.InputJax.TeX ? "Original" : "MathML")}
if (typeof(CONFIG.settings.showRenderer) !== "undefined") {CONFIG.showRenderer = CONFIG.settings.showRenderer}
if (typeof(CONFIG.settings.showFontMenu) !== "undefined") {CONFIG.showFontMenu = CONFIG.settings.showFontMenu}
if (typeof(CONFIG.settings.showContext) !== "undefined") {CONFIG.showContext = CONFIG.settings.showContext}
@ -713,13 +902,14 @@
* The main menu
*/
MENU.menu = MENU(
ITEM.COMMAND("Show Source",MENU.ShowSource),
ITEM.SUBMENU("Format",
ITEM.RADIO("MathML", "format"),
ITEM.RADIO("Original", "format", {value: "Original"})
ITEM.SUBMENU("Show Math As",
ITEM.COMMAND("MathML Code", MENU.ShowSource, {nativeTouch: true, format: "MathML"}),
ITEM.COMMAND("Original Form", MENU.ShowSource, {nativeTouch: true}),
ITEM.RULE(),
ITEM.CHECKBOX("Show TeX hints in MathML", "texHints")
),
ITEM.RULE(),
ITEM.SUBMENU("Settings",
ITEM.SUBMENU("Math Settings",
ITEM.SUBMENU("Zoom Trigger",
ITEM.RADIO("Hover", "zoom", {action: MENU.Zoom}),
ITEM.RADIO("Click", "zoom", {action: MENU.Zoom}),
@ -745,7 +935,16 @@
ITEM.RULE(),
ITEM.SUBMENU("Math Renderer", {hidden:!CONFIG.showRenderer},
ITEM.RADIO("HTML-CSS", "renderer", {action: MENU.Renderer}),
ITEM.RADIO("MathML", "renderer", {action: MENU.Renderer, value:"NativeMML"})
ITEM.RADIO("MathML", "renderer", {action: MENU.Renderer, value:"NativeMML"}),
ITEM.RADIO("SVG", "renderer", {action: MENU.Renderer})
),
ITEM.SUBMENU("MathPlayer", {hidden:!HUB.Browser.isMSIE ||
!CONFIG.showMathPlayer,
disabled:!HUB.Browser.hasMathPlayer},
ITEM.LABEL("Let MathPlayer Handle:"),
ITEM.CHECKBOX("Menu Events", "mpContext", {action: MENU.MPEvents, hidden:!isIE9}),
ITEM.CHECKBOX("Mouse Events", "mpMouse", {action: MENU.MPEvents, hidden:!isIE9}),
ITEM.CHECKBOX("Mouse and Menu Events", "mpMouse", {action: MENU.MPEvents, hidden:isIE9})
),
ITEM.SUBMENU("Font Preference", {hidden:!CONFIG.showFontMenu},
ITEM.LABEL("For HTML-CSS:"),
@ -761,34 +960,66 @@
ITEM.RADIO("MathJax", "context"),
ITEM.RADIO("Browser", "context")
),
ITEM.COMMAND("Scale All Math ...",MENU.Scale)
ITEM.COMMAND("Scale All Math ...",MENU.Scale),
ITEM.RULE().With({hidden:!CONFIG.showDiscoverable, name:"discover_rule"}),
ITEM.CHECKBOX("Highlight on Hover", "discoverable", {hidden:!CONFIG.showDiscoverable})
),
ITEM.RULE(),
ITEM.COMMAND("About MathJax",MENU.About),
ITEM.COMMAND("MathJax Help",MENU.Help)
);
if (MENU.isMobile) {
(function () {
var settings = CONFIG.settings;
var trigger = MENU.menu.Find("Math Settings","Zoom Trigger").menu;
trigger.items[0].disabled = trigger.items[1].disabled = true;
if (settings.zoom === "Hover" || settings.zoom == "Click") {settings.zoom = "None"}
trigger.items = trigger.items.slice(0,4);
if (navigator.appVersion.match(/[ (]Android[) ]/)) {
MENU.ITEM.SUBMENU.Augment({marker: "\u00BB"});
}
})();
}
});
MENU.showRenderer = function (show) {
MENU.cookie.showRenderer = CONFIG.showRenderer = show; MENU.saveCookie();
MENU.menu.items[3].menu.item[3].hidden = !show;
MENU.menu.Find("Math Settings","Math Renderer").hidden = !show;
};
MENU.showMathPlayer = function (show) {
MENU.cookie.showMathPlayer = CONFIG.showMathPlayer = show; MENU.saveCookie();
MENU.menu.Find("Math Settings","MathPlayer").hidden = !show;
};
MENU.showFontMenu = function (show) {
MENU.cookie.showFontMenu = CONFIG.showFontMenu = show; MENU.saveCookie();
MENU.menu.items[3].menu.items[4].hidden = !show
MENU.menu.Find("Math Settings","Font Preference").hidden = !show;
};
MENU.showContext = function (show) {
MENU.cookie.showContext = CONFIG.showContext = show; MENU.saveCookie();
MENU.menu.items[3].menu.items[5].hidden = !show
MENU.menu.Find("Math Settings","Contextual Menu").hidden = !show;
};
MENU.showDiscoverable = function (show) {
MENU.cookie.showContext = CONFIG.showContext = show; MENU.saveCookie();
MENU.menu.Find("Math Settings","Highlight on Hover").hidden = !show;
MENU.menu.Find("Math Settings","discover_rule").hidden = !show;
};
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
if (!MathJax.OutputJax["HTML-CSS"].config.imageFont)
{MENU.menu.Find("Math Settings","Font Preference","TeX (image)").disabled = true}
});
/*************************************************************/
MathJax.Callback.Queue(
CALLBACK.Queue(
HUB.Register.StartupHook("End Config",{}), // wait until config is complete
["getImages",MENU],
["Styles",AJAX,CONFIG.styles],
["Post",HUB.Startup.signal,"MathMenu Ready"],
["loadComplete",AJAX,"[MathJax]/extensions/MathMenu.js"]
);
})(MathJax.Hub,MathJax.HTML,MathJax.Ajax);
})(MathJax.Hub,MathJax.HTML,MathJax.Ajax,MathJax.CallBack,MathJax.OutputJax);

View File

@ -7,7 +7,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,11 +23,9 @@
*/
(function (HUB,HTML,AJAX,HTMLCSS,nMML) {
var VERSION = "1.1";
var VERSION = "2.0";
var CONFIG = HUB.CombineConfig("MathZoom",{
delay: 400, // mouse must be still this long (milliseconds)
styles: {
//
// The styles for the MathZoom display box
@ -35,8 +33,8 @@
"#MathJax_Zoom": {
position:"absolute", "background-color":"#F0F0F0", overflow:"auto",
display:"block", "z-index":301, padding:".5em", border:"1px solid black", margin:0,
"font-family":"serif", "font-size":"85%", "font-weight":"normal",
"font-style":"normal", "text-align":"left", "text-indent":0, "text-transform":"none",
"font-weight":"normal", "font-style":"normal",
"text-align":"left", "text-indent":0, "text-transform":"none",
"line-height":"normal", "letter-spacing":"normal", "word-spacing":"normal",
"word-wrap":"normal", "white-space":"nowrap", "float":"none",
"box-shadow":"5px 5px 15px #AAAAAA", // Opera 10.5 and IE9
@ -53,40 +51,39 @@
position:"absolute", left:0, top:0, "z-index":300, display:"inline-block",
width:"100%", height:"100%", border:0, padding:0, margin:0,
"background-color":"white", opacity:0, filter:"alpha(opacity=0)"
},
"#MathJax_ZoomEventTrap": {
position:"absolute", left:0, top:0, "z-index":302,
display:"inline-block", border:0, padding:0, margin:0,
"background-color":"white", opacity:0, filter:"alpha(opacity=0)"
}
}
});
/*************************************************************/
/*
* Cancel event's default action (try everything we can)
*/
var FALSE = function (event) {
if (!event) {event = window.event}
if (event) {
if (event.preventDefault) {event.preventDefault()}
if (event.stopPropagation) {event.stopPropagation()}
event.cancelBubble = true;
event.returnValue = false;
}
return false;
};
var FALSE, HOVER, EVENT;
MathJax.Hub.Register.StartupHook("MathEvents Ready",function () {
EVENT = MathJax.Extension.MathEvents.Event;
FALSE = MathJax.Extension.MathEvents.Event.False;
HOVER = MathJax.Extension.MathEvents.Hover;
});
/*************************************************************/
var ZOOM = MathJax.Extension.MathZoom = {
version: VERSION,
settings: HUB.config.menuSettings,
scrollSize: 18, // width of scrool bars
//
// Used to override HTMLCSS or nMML method of the same name
// Process events passed from output jax
//
HandleEvent: function (event,type,math) {
if (!event) {event = window.event}
if (ZOOM.settings.CTRL && !event.ctrlKey) return true;
if (ZOOM.settings.ALT && !event.altKey) return true;
if (ZOOM.settings.CMD && !event.metaKey) return true;
if (ZOOM.settings.Shift && !event.shiftKey) return true;
if (!ZOOM[type]) return true;
return ZOOM[type](event,math);
},
@ -94,69 +91,46 @@
// Zoom on click
//
Click: function (event,math) {
if (this.settings.zoom === "Click") {return this.Zoom(math,event)}
if (this.settings.zoom === "Click") {return this.Zoom(event,math)}
},
//
// Zoom on double click
//
DblClick: function (event,math) {
if (this.settings.zoom === "Double-Click") {return this.Zoom(math,event)}
if (this.settings.zoom === "Double-Click") {return this.Zoom(event,math)}
},
//
// Zoom on hover
// Zoom on hover (called by MathEvents.Hover)
//
Mouseover: function (event,math) {
if (this.settings.zoom === "Hover") {
ZOOM.oldMouseOver = math.onmouseover;
math.onmouseover = null;
math.onmousemove = this.Mousemove;
math.onmouseout = this.Mouseout;
return ZOOM.Timer(event,math);
}
},
Mouseout: function (event) {
this.onmouseover = ZOOM.oldMouseOver; delete ZOOM.oldMouseOver;
this.onmousemove = this.onmouseout = null;
ZOOM.ClearTimer();
return FALSE(event);
},
Mousemove: function (event) {
return ZOOM.Timer(event||window.event,this);
},
Timer: function (event,math) {
this.ClearTimer();
this.timer = setTimeout(MathJax.Callback(["Zoom",this,math,{}]),CONFIG.delay);
return FALSE(event);
},
ClearTimer: function () {
if (this.timer) {clearTimeout(this.timer); delete this.timer}
Hover: function (event,math) {
if (this.settings.zoom === "Hover") {this.Zoom(event,math); return true}
return false;
},
//
// Handle the actual zooming
//
Zoom: function (math,event) {
this.ClearTimer(); this.Remove();
Zoom: function (event,math) {
//
// Find the jax and its type
// Remove any other zoom and clear timers
//
var parent = math.parentNode;
if (parent.className === "MathJax_MathContainer") {parent = parent.parentNode}
if (parent.parentNode.className === "MathJax_MathContainer") {parent = parent.parentNode.parentNode}
var script = (String(parent.className).match(/^MathJax_(MathML|Display)$/) ? parent : math).nextSibling;
var jax = HUB.getJaxFor(script), root = jax.root;
var JAX = (HTMLCSS && jax.outputJax.isa(HTMLCSS.constructor) ? "HTMLCSS" :
(nMML && jax.outputJax.isa(nMML.constructor) ? "MathML" : null));
if (!JAX) return; // FIXME: report an error?
this.Remove(); HOVER.ClearHoverTimer(); EVENT.ClearSelection();
//
// Find the jax
//
var JAX = MathJax.OutputJax[math.jaxID];
var jax = JAX.getJaxFromMath(math);
if (jax.hover) {HOVER.UnHover(jax)}
//
// Create the DOM elements for the zoom box
//
var Mw = Math.floor(.85*document.body.clientWidth),
Mh = Math.floor(.85*document.body.clientHeight);
Mh = Math.floor(.85*Math.max(document.body.clientHeight,document.documentElement.clientHeight));
var div = HTML.Element(
"span",{
style: {position:"relative", display:"inline-block", height:0, width:0},
@ -164,48 +138,57 @@
},[
["span",{id:"MathJax_ZoomOverlay", onmousedown:this.Remove}],
["span",{
id:"MathJax_Zoom", onclick: this.Remove,
id:"MathJax_Zoom", onclick:this.Remove,
style:{
visibility:"hidden", fontSize:this.settings.zscale,
"max-width":Mw+"px", "max-height":Mh+"px"
}
},[["span"]]]
]
},[["span",{style:{display:"inline-block", "white-space":"nowrap"}}]]
]]
);
var zoom = div.lastChild, span = zoom.firstChild, overlay = div.firstChild;
math.parentNode.insertBefore(div,math);
if (span.addEventListener) {span.addEventListener("mousedown",this.Remove,true)}
if (this.msieTrapEventBug) {
var trap = HTML.Element("span",{id:"MathJax_ZoomEventTrap", onmousedown:this.Remove});
div.insertBefore(trap,zoom);
}
//
// Display the zoomed math
//
if (this.msieZIndexBug) {
// MSIE doesn't do z-index properly, so move the div to the document.body,
// and use an empty span as a tracker for the usual position
var tracker = HTML.Element("img",{
src:"about:blank", id:"MathJax_ZoomTracker",
// and use an image as a tracker for the usual position
var tracker = HTML.addElement(document.body,"img",{
src:"about:blank", id:"MathJax_ZoomTracker", width:0, height:0,
style:{width:0, height:0, position:"relative"}
});
document.body.appendChild(div);
div.style.position = "absolute";
div.style.position = "relative";
div.style.zIndex = CONFIG.styles["#MathJax_ZoomOverlay"]["z-index"];
div = tracker;
}
var bbox = (this["Zoom"+JAX])(root,span,math);
var bbox = JAX.Zoom(jax,span,math,Mw,Mh);
//
// Fix up size and position for browsers with bugs (IE)
//
if (this.msiePositionBug) {
if (this.msieIE8Bug) {
// IE8 gets height completely wrong
span.style.position = "absolute"; zoom.style.height = span.offsetHeight; span.style.position = "";
if (zoom.offsetHeight <= Mh && zoom.offsetWidth <= Mw) {zoom.style.overflow = "visible"}
}
if (this.msieWidthBug) {zoom.style.width = Math.min(Mw,bbox.w)}
else if (bbox.w > Mw) {zoom.style.width = Mw}
if (zoom.offsetHeight > Mh) {zoom.style.Height = Mh+"px"} // IE doesn't do max-height?
if (math.nextSibling) {math.parentNode.insertBefore(div,math.nextSibling)}
else {parent.appendChild(div)} // needs to be after to be above?
} else if (this.operaPositionBug) {
zoom.style.width = Math.min(Mw,span.offsetWidth)+"px"; // gets width as 0?
if (this.msieSizeBug)
{zoom.style.height = bbox.zH+"px"; zoom.style.width = bbox.zW+"px"} // IE8 gets the dimensions completely wrong
if (zoom.offsetHeight > Mh) {zoom.style.height = Mh+"px"; zoom.style.width = (bbox.zW+this.scrollSize)+"px"} // IE doesn't do max-height?
if (zoom.offsetWidth > Mw) {zoom.style.width = Mw+"px"; zoom.style.height = (bbox.zH+this.scrollSize)+"px"}
}
if (this.operaPositionBug) {zoom.style.width = Math.min(Mw,bbox.zW)+"px"} // Opera gets width as 0?
if (zoom.offsetWidth < Mw && zoom.offsetHeight < Mh) {zoom.style.overflow = "visible"}
this.Position(zoom,bbox);
if (this.msieTrapEventBug) {
trap.style.height = zoom.clientHeight+"px"; trap.style.width = zoom.clientWidth+"px";
trap.style.left = (parseFloat(zoom.style.left)+zoom.clientLeft)+"px";
trap.style.top = (parseFloat(zoom.style.top)+zoom.clientTop)+"px";
}
this.Position(zoom,bbox,(JAX === "MathML" && parent.nodeName.toLowerCase() === "div"));
zoom.style.visibility = "";
//
@ -216,53 +199,25 @@
else if (window.attachEvent) {attachEvent("onresize",this.Resize)}
else {this.onresize = window.onresize; window.onresize = this.Resize}
//
// Let others know about the zoomed math
//
HUB.signal.Post(["math zoomed",jax]);
//
// Canel further actions
//
return FALSE(event);
},
//
// Handle the jax-specific output
//
ZoomHTMLCSS: function (root,span,math) {
span.className = "MathJax";
HTMLCSS.idPostfix = "-zoom";
HTMLCSS.getScales(span,span);
root.toHTML(span,span);
var bbox = root.HTMLspanElement().bbox;
HTMLCSS.idPostfix = "";
if (bbox.width && bbox.width !== "100%") {
// Handle full-width displayed equations
// FIXME: this is a hack for now
var Mw = Math.floor(.85*document.body.clientWidth);
span.style.width = Mw+"px"; span.style.display="inline-block";
var id = (root.id||"MathJax-Span-"+root.spanID)+"-zoom";
var child = document.getElementById(id).firstChild;
while (child && child.style.width !== bbox.width) {child = child.nextSibling}
if (child) {child.style.width = "100%"}
}
span.appendChild(this.topImg); var top = this.topImg.offsetTop; span.removeChild(this.topImg);
var W = (this.msieWidthBug ? HTMLCSS.getW(math)*HTMLCSS.em : math.offsetWidth);
return {w:bbox.w*HTMLCSS.em, Y:-top, W:W};
},
ZoomMathML: function (root,span,math) {
root.toNativeMML(span,span); var top;
span.appendChild(this.topImg); top = this.topImg.offsetTop; span.removeChild(this.topImg);
var W = (this.ffMMLwidthBug ? math.parentNode : math).offsetWidth;
return {w:span.offsetWidth, Y:-top, W:W}
},
//
// Set the position of the zoom box and overlay
//
Position: function (zoom,bbox,MMLdisplay) {
var XY = this.Resize(), x = XY.x, y = XY.y, W = bbox.W;
if (this.msiePositionBug) {W = -W}
if (MMLdisplay && this.ffMMLcenterBug) {W = 0}
Position: function (zoom,bbox) {
var XY = this.Resize(), x = XY.x, y = XY.y, W = bbox.mW;
var dx = -Math.floor((zoom.offsetWidth-W)/2), dy = bbox.Y;
zoom.style.left = Math.max(dx,20-x)+"px"; zoom.style.top = Math.max(dy,20-y)+"px";
zoom.style.left = Math.max(dx,10-x)+"px"; zoom.style.top = Math.max(dy,10-y)+"px";
if (!ZOOM.msiePositionBug) {ZOOM.SetWH()} // refigure overlay width/height
},
//
@ -270,16 +225,13 @@
//
Resize: function (event) {
if (ZOOM.onresize) {ZOOM.onresize(event)}
var x = 0, y = 0,
var x = 0, y = 0, obj,
div = document.getElementById("MathJax_ZoomFrame"),
overlay = document.getElementById("MathJax_ZoomOverlay");
var obj = (ZOOM.msieZIndexBug ? document.getElementById("MathJax_ZoomTracker") : div);
obj = div; while (obj.offsetParent) {x += obj.offsetLeft; obj = obj.offsetParent}
if (ZOOM.operaPositionBug) {div.style.border = "1px solid"} // to get vertical position right
if (obj.offsetParent) {
do {x += obj.offsetLeft; y += obj.offsetTop} while (obj = obj.offsetParent);
}
obj = div; while (obj.offsetParent) {y += obj.offsetTop; obj = obj.offsetParent}
if (ZOOM.operaPositionBug) {div.style.border = ""}
if (ZOOM.msieZIndexBug) {div.style.left = x+"px"; div.style.top = y+"px"}
overlay.style.left = (-x)+"px"; overlay.style.top = (-y)+"px";
if (ZOOM.msiePositionBug) {setTimeout(ZOOM.SetWH,0)} else {ZOOM.SetWH()}
return {x:x, y:y};
@ -287,8 +239,9 @@
SetWH: function () {
var overlay = document.getElementById("MathJax_ZoomOverlay");
overlay.style.width = overlay.style.height = "1px"; // so scrollWidth/Height will be right below
overlay.style.width = document.body.scrollWidth + "px";
overlay.style.height = document.body.scrollHeight + "px";
var doc = document.documentElement || document.body;
overlay.style.width = doc.scrollWidth + "px";
overlay.style.height = Math.max(doc.clientHeight,doc.scrollHeight) + "px";
},
//
@ -297,6 +250,9 @@
Remove: function (event) {
var div = document.getElementById("MathJax_ZoomFrame");
if (div) {
var JAX = MathJax.OutputJax[div.nextSibling.jaxID];
var jax = JAX.getJaxFromMath(div.nextSibling);
HUB.signal.Post(["math unzoomed",jax]);
div.parentNode.removeChild(div);
div = document.getElementById("MathJax_ZoomTracker");
if (div) {div.parentNode.removeChild(div)}
@ -306,9 +262,9 @@
var overlay = HTML.addElement(document.body,"div",{
style:{position:"fixed", left:0, top:0, width:"100%", height:"100%",
backgroundColor:"white", opacity:0},
id: "MathJax_OperaDiv"
});
document.body.removeChild(overlay);
id: "MathJax_OperaDiv"
});
document.body.removeChild(overlay);
}
if (window.removeEventListener) {removeEventListener("resize",ZOOM.Resize,false)}
else if (window.detachEvent) {detachEvent("onresize",ZOOM.Resize)}
@ -319,88 +275,39 @@
};
//
// Hook into the HTML-CSS and NativeMML event handling
//
HUB.Register.StartupHook("HTML-CSS Jax Ready",function () {
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
HTMLCSS.Augment({HandleEvent: ZOOM.HandleEvent});
});
HUB.Register.StartupHook("NativeMML Jax Ready", function () {
nMML = MathJax.OutputJax.NativeMML;
nMML.Augment({
HandleEvent: ZOOM.HandleEvent,
MSIEmouseup: function (event,math,span) {
if (this.trapUp) {delete this.trapUp; return true}
if (this.MSIEzoomKeys(event)) {return true}
return false;
},
MSIEclick: function (event,math,span) {
if (this.trapClick) {delete this.trapClick; return true}
if (!this.MSIEzoomKeys(event)) return false;
if (!this.settings.zoom.match(/Click/)) return false;
return (ZOOM.Click(event,math) === false);
},
MSIEdblclick: function (event,math,span) {
if (!this.MSIEzoomKeys(event)) return false;
return (ZOOM.DblClick(event,math) === false);
},
MSIEmouseover: function (event,math,span) {
if (this.settings.zoom !== "Hover") {return false}
ZOOM.Timer(event,math); return true;
},
MSIEmouseout: function (event,math,span) {
if (this.settings.zoom !== "Hover") {return false}
ZOOM.ClearTimer(); return true;
},
MSIEmousemove: function (event,math,span) {
if (this.settings.zoom !== "Hover") {return false}
ZOOM.Timer(event,math); return true;
},
MSIEzoomKeys: function (event) {
if (this.settings.CTRL && !event.ctrlKey) return false;
if (this.settings.CMD && !event.metaKey) return false;
if (this.settings.ALT && !event.altKey) return false;
if (this.settings.Shift && !event.shiftKey) return false;
return true;
}
});
});
/*************************************************************/
HUB.Browser.Select({
MSIE: function (browser) {
var quirks = (document.compatMode === "BackCompat");
var isIE8 = browser.versionAtLeast("8.0") && document.documentMode > 7;
ZOOM.msiePositionBug = true;
ZOOM.msieWidthBug = !quirks;
ZOOM.msieIE8Bug = isIE8;
ZOOM.msieZIndexBug = !isIE8;
ZOOM.msieInlineBlockAlignBug = (!isIE8 || quirks);
if (document.documentMode >= 9) {delete CONFIG.styles["#MathJax_Zoom"].filter}
var mode = (document.documentMode || 0);
var isIE9 = (mode >= 9);
ZOOM.msiePositionBug = !isIE9;
ZOOM.msieSizeBug = browser.versionAtLeast("7.0") &&
(!document.documentMode || mode === 7 || mode === 8);
ZOOM.msieZIndexBug = (mode <= 7);
ZOOM.msieInlineBlockAlignBug = (mode <= 7);
ZOOM.msieTrapEventBug = !window.addEventListener;
if (document.compatMode === "BackCompat") {ZOOM.scrollSize = 52} // don't know why this is so far off
if (isIE9) {delete CONFIG.styles["#MathJax_Zoom"].filter}
},
Opera: function (browser) {
ZOOM.operaPositionBug = true;
ZOOM.operaRefreshBug = true;
},
Firefox: function (browser) {
ZOOM.ffMMLwidthBug = true;
ZOOM.ffMMLcenterBug = true;
}
});
ZOOM.topImg = (ZOOM.msieInlineBlockAlignBug ?
HTML.Element("img",{style:{width:0,height:0},src:"about:blank"}) :
HTML.Element("img",{style:{width:0,height:0,position:"relative"},src:"about:blank"}) :
HTML.Element("span",{style:{width:0,height:0,display:"inline-block"}})
);
if (ZOOM.operaPositionBug) {ZOOM.topImg.style.border="1px solid"}
if (ZOOM.operaPositionBug || ZOOM.msieTopBug) {ZOOM.topImg.style.border="1px solid"}
/*************************************************************/
MathJax.Callback.Queue(
["StartupHook",MathJax.Hub.Register,"Begin Styles",{}],
["Styles",AJAX,CONFIG.styles],
["Post",HUB.Startup.signal,"MathZoom Ready"],
["loadComplete",AJAX,"[MathJax]/extensions/MathZoom.js"]

View File

@ -6,7 +6,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,17 +21,31 @@
* limitations under the License.
*/
MathJax.Extension["TeX/AMSmath"] = {
version: "2.0",
number: 0, // current equation number
startNumber: 0, // current starting equation number (for when equation is restarted)
labels: {}, // the set of labels
eqlabels: {}, // labels in the current equation
refs: [] // array of jax with unresolved references
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var VERSION = "1.1";
var MML = MathJax.ElementJax.mml;
var TEX = MathJax.InputJax.TeX;
var TEXDEF = TEX.Definitions;
var STACKITEM = TEX.Stack.Item;
var MML = MathJax.ElementJax.mml,
TEX = MathJax.InputJax.TeX,
AMS = MathJax.Extension["TeX/AMSmath"];
var TEXDEF = TEX.Definitions,
STACKITEM = TEX.Stack.Item,
CONFIG = TEX.config.equationNumbers;
var COLS = function (W) {return W.join("em ") + "em"};
MathJax.Hub.Insert(TEXDEF,{
/******************************************************************************/
TEXDEF.Add({
macros: {
mathring: ['Accent','2DA'], // or 0x30A
@ -54,6 +68,9 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
tag: 'HandleTag',
notag: 'HandleNoTag',
label: 'HandleLabel',
ref: 'HandleRef',
eqref: ['HandleRef',true],
substack: ['Macro','\\begin{subarray}{c}#1\\end{subarray}',1],
@ -97,11 +114,14 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
'alignat*': ['AlignAt',null,false,true],
alignedat: ['AlignAt',null,false,false],
aligned: ['Array',null,null,null,'rlrlrlrlrlrl',COLS([5/18,2,5/18,2,5/18,2,5/18,2,5/18,2,5/18]),".5em",'D'],
gathered: ['Array',null,null,null,'c',null,".5em",'D'],
aligned: ['AlignedArray',null,null,null,'rlrlrlrlrlrl',COLS([5/18,2,5/18,2,5/18,2,5/18,2,5/18,2,5/18]),".5em",'D'],
gathered: ['AlignedArray',null,null,null,'c',null,".5em",'D'],
subarray: ['Array',null,null,null,null,COLS([0,0,0,0]),"0.1em",'S',1],
smallmatrix: ['Array',null,null,null,'c',COLS([1/3]),".2em",'S',1]
smallmatrix: ['Array',null,null,null,'c',COLS([1/3]),".2em",'S',1],
'equation': ['EquationBegin','Equation',true],
'equation*': ['EquationBegin','EquationStar',false]
},
delimiter: {
@ -110,36 +130,63 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
'\\lVert': ['2225',{texClass:MML.TEXCLASS.OPEN}],
'\\rVert': ['2225',{texClass:MML.TEXCLASS.CLOSE}]
}
});
},null,true);
/******************************************************************************/
TEX.Parse.Augment({
/*
* Add the tag to the environment to be added to the table row later
* Add the tag to the environment (to be added to the table row later)
*/
HandleTag: function (name) {
var arg = this.trimSpaces(this.GetArgument(name));
if (arg === "*") {arg = this.GetArgument(name)} else {arg = "("+arg+")"}
if (this.stack.global.notag)
{TEX.Error(name+" not allowed in "+this.stack.global.notag+" environment")}
if (this.stack.global.tag) {TEX.Error("Multiple "+name)}
this.stack.global.tag = MML.mtd.apply(MML,this.InternalMath(arg));
var star = this.GetStar();
var arg = this.trimSpaces(this.GetArgument(name)), tag = arg;
if (!star) {arg = CONFIG.formatTag(arg)}
var global = this.stack.global; global.tagID = tag;
if (global.notags) {TEX.Error(name+" not allowed in "+global.notags+" environment")}
if (global.tag) {TEX.Error("Multiple "+name)}
global.tag = MML.mtd.apply(MML,this.InternalMath(arg)).With({id:CONFIG.formatID(tag)});
},
HandleNoTag: function (name) {
if (this.stack.global.tag) {delete this.stack.global.tag}
this.stack.global.notag = true; // prevent auto-tagging
},
/*
* Record a label name for a tag
*/
HandleLabel: function (name) {
var global = this.stack.global, label = this.GetArgument(name);
if (!AMS.refUpdate) {
if (global.label) {TEX.Error("Multiple "+name+"'s")}
global.label = label;
if (AMS.labels[label] || AMS.eqlabels[label]) {TEX.Error("Label '"+label+"' mutiply defined")}
AMS.eqlabels[label] = "???"; // will be replaced by tag value later
}
},
/*
* Handle a label reference
*/
HandleRef: function (name,eqref) {
var label = this.GetArgument(name);
var ref = AMS.labels[label] || AMS.eqlabels[label];
if (!ref) {ref = "??"; AMS.badref = !AMS.refUpdate}
var tag = ref; if (eqref) {tag = CONFIG.formatTag(tag)}
if (CONFIG.useLabelIds) {ref = label}
this.Push(MML.mrow.apply(MML,this.InternalMath(tag)).With({
href:CONFIG.formatURL(CONFIG.formatID(ref)), "class":"MathJax_ref"
}));
},
/*
* Handle \DeclareMathOperator
*/
HandleDeclareOp: function (name) {
var limits = "";
var limits = (this.GetStar() ? "\\limits" : "");
var cs = this.trimSpaces(this.GetArgument(name));
if (cs == "*") {
limits = "\\limits";
cs = this.trimSpaces(this.GetArgument(name));
}
if (cs.charAt(0) == "\\") {cs = cs.substr(1)}
var op = this.GetArgument(name);
op = op.replace(/\*/g,'\\text{*}').replace(/-/g,'\\text{-}');
@ -147,12 +194,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
},
HandleOperatorName: function (name) {
var limits = "\\nolimits";
var limits = (this.GetStar() ? "\\limits" : "\\nolimits");
var op = this.trimSpaces(this.GetArgument(name));
if (op == "*") {
limits = "\\limits";
op = this.trimSpaces(this.GetArgument(name));
}
op = op.replace(/\*/g,'\\text{*}').replace(/-/g,'\\text{-}');
this.string = '\\mathop{\\rm '+op+'}'+limits+" "+this.string.slice(this.i);
this.i = 0;
@ -171,7 +214,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
* Handle \cfrac
*/
CFrac: function (name) {
var lr = this.trimSpaces(this.GetBrackets(name)),
var lr = this.trimSpaces(this.GetBrackets(name,"")),
num = this.GetArgument(name),
den = this.GetArgument(name);
var frac = MML.mfrac(TEX.Parse('\\strut\\textstyle{'+num+'}',this.stack.env).mml(),
@ -202,7 +245,6 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
if (STYLE === "D") {frac.displaystyle = true; frac.scriptlevel = 0}
else {frac.displaystyle = false; frac.scriptlevel = style - 1}
}
this.Push(frac);
},
@ -210,8 +252,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
* Implements multline environment (mostly handled through STACKITEM below)
*/
Multline: function (begin,numbered) {
this.Push(begin);
return STACKITEM.multline().With({
this.Push(begin); this.checkEqnEnv();
return STACKITEM.multline(numbered,this.stack).With({
arraydef: {
displaystyle: true,
rowspacing: ".5em",
@ -226,7 +268,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
* Handle AMS aligned environments
*/
AMSarray: function (begin,numbered,taggable,align,spacing) {
this.Push(begin);
this.Push(begin); if (taggable) {this.checkEqnEnv()}
align = align.replace(/[^clr]/g,'').split('').join(' ');
align = align.replace(/l/g,'left').replace(/r/g,'right').replace(/c/g,'center');
return STACKITEM.AMSarray(begin.name,numbered,taggable,this.stack).With({
@ -242,14 +284,40 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
});
},
/*
* Handle alignat environments
*/
AlignAt: function (begin,numbered,taggable) {
var n = this.GetArgument("\\begin{"+begin.name+"}");
var n, valign, align = "", spacing = [];
if (!taggable) {valign = this.GetBrackets("\\begin{"+begin.name+"}")}
n = this.GetArgument("\\begin{"+begin.name+"}");
if (n.match(/[^0-9]/)) {TEX.Error("Argument to \\begin{"+begin.name+"} must me a positive integer")}
align = ""; spacing = [];
while (n > 0) {align += "rl"; spacing.push("0em 0em"); n--}
spacing = spacing.join(" ");
if (taggable) {return this.AMSarray(begin,numbered,taggable,align,spacing)}
return this.Array(begin,null,null,align,spacing,".5em",'D');
var array = this.Array.call(this,begin,null,null,align,spacing,".5em",'D');
return this.setArrayAlign(array,valign);
},
/*
* Handle equation environment
*/
EquationBegin: function (begin,force) {
this.checkEqnEnv();
this.stack.global.forcetag = (force && CONFIG.autoNumber !== "none");
return begin;
},
EquationStar: function (begin,row) {
this.stack.global.tagged = true; // prevent automatic tagging
return row;
},
/*
* Check for bad nesting of equation environments
*/
checkEqnEnv: function () {
if (this.stack.global.eqnenv) {TEX.Error("Erroneous nesting of equation structures")}
this.stack.global.eqnenv = true;
},
/*
@ -268,6 +336,9 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
this.i = 0;
},
/*
* Handle stretchable arrows
*/
xArrow: function (name,chr,l,r) {
var def = {width: "+"+(l+r)+"mu", lspace: l+"mu"};
var bot = this.GetBrackets(name),
@ -290,8 +361,47 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
GetDelimiterArg: function (name) {
var c = this.trimSpaces(this.GetArgument(name));
if (c == "") {return null}
if (!TEXDEF.delimiter[c]) {TEX.Error("Missing or unrecognized delimiter for "+name)}
if (TEXDEF.delimiter[c] == null) {TEX.Error("Missing or unrecognized delimiter for "+name)}
return this.convertDelimiter(c);
},
/*
* Get a star following a control sequence name, if any
*/
GetStar: function () {
var star = (this.GetNext() === "*");
if (star) {this.i++}
return star;
}
});
/******************************************************************************/
STACKITEM.Augment({
/*
* Increment equation number and form tag mtd element
*/
autoTag: function () {
var global = this.global;
if (!global.notag) {
AMS.number++; global.tagID = CONFIG.formatNumber(AMS.number.toString());
var mml = TEX.Parse("\\text{"+CONFIG.formatTag(global.tagID)+"}",{}).mml();
global.tag = MML.mtd(mml.With({id:CONFIG.formatID(global.tagID)}));
}
},
/*
* Get the tag and record the label, if any
*/
getTag: function () {
var global = this.global, tag = global.tag; global.tagged = true;
if (global.label) {
AMS.eqlabels[global.label] = global.tagID;
if (CONFIG.useLabelIds) {tag.id = CONFIG.formatID(global.label)}
}
delete global.tag; delete global.tagID; delete global.label;
return tag;
}
});
@ -300,6 +410,12 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
*/
STACKITEM.multline = STACKITEM.array.Subclass({
type: "multline",
Init: function (numbered,stack) {
this.SUPER(arguments).Init.apply(this);
this.numbered = (numbered && CONFIG.autoNumber !== "none");
this.save = {notag: stack.global.notag};
stack.global.tagged = !numbered && !stack.global.forcetag; // prevent automatic tagging in starred environments
},
EndEntry: function () {
var mtd = MML.mtd.apply(MML,this.data);
if (this.data.shove) {mtd.columnalign = this.data.shove}
@ -313,41 +429,50 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
EndTable: function () {
this.SUPER(arguments).EndTable.call(this);
if (this.table.length) {
var m = this.table.length-1, i;
var m = this.table.length-1, i, label = -1;
if (!this.table[0][0].columnalign) {this.table[0][0].columnalign = MML.ALIGN.LEFT}
if (!this.table[m][0].columnalign) {this.table[m][0].columnalign = MML.ALIGN.RIGHT}
var mtr = MML.mtr;
if (this.global.tag) {
this.table[0] = [this.global.tag].concat(this.table[0]);
delete this.global.tag; mtr = MML.mlabeledtr;
if (!this.global.tag && this.numbered) {this.autoTag()}
if (this.global.tag && !this.global.notags) {
label = (this.arraydef.side === "left" ? 0 : this.table.length - 1);
this.table[label] = [this.getTag()].concat(this.table[label]);
}
for (i = 0, m = this.table.length; i < m; i++) {
var mtr = (i === label ? MML.mlabeledtr : MML.mtr);
this.table[i] = mtr.apply(MML,this.table[i]);
}
this.table[0] = mtr.apply(MML,this.table[0]);
for (i = 1, m = this.table.length; i < m; i++)
{this.table[i] = MML.mtr.apply(MML,this.table[i])}
}
this.global.notag = this.save.notag;
}
});
/*
* Save data about numbering and taging equations, and add
* tags at the ends of rows.
*/
STACKITEM.AMSarray = STACKITEM.array.Subclass({
type: "AMSarray",
Init: function (name,numbered,taggable,stack) {
this.SUPER(arguments).Init.apply(this);
this.numbered = numbered;
this.save_notag = stack.global.notag;
stack.global.notag = (taggable ? null : name);
this.numbered = (numbered && CONFIG.autoNumber !== "none");
this.save = {notags: stack.global.notags, notag: stack.global.notag};
stack.global.notags = (taggable ? null : name);
stack.global.tagged = !numbered && !stack.global.forcetag; // prevent automatic tagging in starred environments
},
EndRow: function () {
var mtr = MML.mtr;
if (this.global.tag) {
this.row = [this.global.tag].concat(this.row);
if (!this.global.tag && this.numbered) {this.autoTag()}
if (this.global.tag &&! this.global.notags) {
this.row = [this.getTag()].concat(this.row);
mtr = MML.mlabeledtr;
delete this.global.tag;
}
if (this.numbered) {delete this.global.notag}
this.table.push(mtr.apply(MML,this.row)); this.row = [];
},
EndTable: function () {
this.SUPER(arguments).EndTable.call(this);
this.global.notag = this.save_notag;
this.global.notags = this.save.notags;
this.global.notag = this.save.notag;
}
});
@ -358,9 +483,11 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
oldCheckItem: STACKITEM.start.prototype.checkItem,
checkItem: function (item) {
if (item.type === "stop") {
var mml = this.mmlData();
if (this.global.tag) {
var row = [this.global.tag,MML.mtd(mml)]; delete this.global.tag;
var mml = this.mmlData(), global = this.global;
if (AMS.display && !global.tag && !global.tagged && !global.isInner &&
(CONFIG.autoNumber === "all" || global.forcetag)) {this.autoTag()}
if (global.tag) {
var row = [this.getTag(),MML.mtd(mml)];
var def = {
side: TEX.config.TagSide,
minlabelspacing: TEX.config.TagIndent,
@ -383,10 +510,56 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}
return STACKITEM.mml(mml);
}
return this.SUPER(arguments).checkItem.call(this,item);
return this.oldCheckItem.call(this,item);
}
});
/******************************************************************************/
/*
* Add pre- and post-filters to handle the equation number maintainance.
*/
TEX.prefilterHooks.Add(function (data) {
AMS.display = data.display;
AMS.number = AMS.startNumber; // reset equation numbers (in case the equation restarted)
AMS.eqlabels = {}; AMS.badref = false;
if (AMS.refUpdate) {AMS.number = data.script.MathJax.startNumber}
});
TEX.postfilterHooks.Add(function (data) {
data.script.MathJax.startNumber = AMS.startNumber;
AMS.startNumber = AMS.number; // equation numbers for next equation
MathJax.Hub.Insert(AMS.labels,AMS.eqlabels); // save labels from this equation
if (AMS.badref && !data.math.texError) {AMS.refs.push(data.script)} // reprocess later
});
MathJax.Hub.Register.MessageHook("Begin Math Input",function () {
AMS.refs = []; // array of jax with bad references
AMS.refUpdate = false;
});
MathJax.Hub.Register.MessageHook("End Math Input",function (message) {
if (AMS.refs.length) {
AMS.refUpdate = true;
for (var i = 0, m = AMS.refs.length; i < m; i++)
{AMS.refs[i].MathJax.state = MathJax.ElementJax.STATE.UPDATE}
return MathJax.Hub.processInput({
scripts:AMS.refs,
start: new Date().getTime(),
i:0, j:0, jax:{}, jaxIDs:[]
});
}
return null;
});
//
// Clear the equation numbers and labels
//
TEX.resetEquationNumbers = function (n,keepLabels) {
AMS.startNumber = (n || 0);
if (!keepLabels) {AMS.labels = {}}
}
/******************************************************************************/
MathJax.Hub.Startup.signal.Post("TeX AMSmath Ready");
});

View File

@ -6,7 +6,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009-2011 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,12 +21,15 @@
* limitations under the License.
*/
MathJax.Extension["TeX/AMSsymbols"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var VERSION = "1.1.2";
var MML = MathJax.ElementJax.mml,
TEXDEF = MathJax.InputJax.TeX.Definitions;
var MML = MathJax.ElementJax.mml;
MathJax.Hub.Insert(MathJax.InputJax.TeX.Definitions,{
TEXDEF.Add({
mathchar0mi: {
// Lowercase Greek letters
@ -148,7 +151,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
backsim: '223D',
thicksim: ['223C',{variantForm: true}],
backsimeq: '22CD',
thickapprox: '2248',
thickapprox: ['2248',{variantForm: true}],
subseteqq: '2AC5',
supseteqq: '2AC6',
Subset: '22D0',
@ -295,10 +298,10 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
delimiter: {
// corners
"\\ulcorner": '250C',
"\\urcorner": '2510',
"\\llcorner": '2514',
"\\lrcorner": '2518'
"\\ulcorner": '231C',
"\\urcorner": '231D',
"\\llcorner": '231E',
"\\lrcorner": '231F'
},
macros: {
@ -306,7 +309,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
impliedby: ['Macro','\\;\\Longleftarrow\\;']
}
});
},null,true);
var REL = MML.mo.OPTYPES.REL;
@ -336,10 +339,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}
});
// if (MathJax.Hub.Browser.isMSIE) {
// MathJax.InputJax.TeX.Definitions.mathchar0mi.digamma = ['03DD',{variantForm: true}];
// MathJax.InputJax.TeX.Definitions.mathchar0mi.varkappa = ['03F0',{variantForm: true}];
// }
MathJax.Hub.Startup.signal.Post("TeX AMSsymbols Ready");
});
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
@ -382,9 +383,19 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
});
}
MathJax.Hub.Startup.signal.Post("TeX AMSsymbols Ready");
});
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var SVG = MathJax.OutputJax.SVG;
var VARIANT = SVG.FONTDATA.VARIANT;
VARIANT["-TeX-variant"] = {
fonts: ["MathJax_AMS","MathJax_Main","MathJax_Size1"],
remap: {0x2268: 0xE00C, 0x2269: 0xE00D, 0x2270: 0xE011, 0x2271: 0xE00E,
0x2A87: 0xE010, 0x2A88: 0xE00F, 0x2224: 0xE006, 0x2226: 0xE007,
0x2288: 0xE016, 0x2289: 0xE018, 0x228A: 0xE01A, 0x228B: 0xE01B,
0x2ACB: 0xE017, 0x2ACC: 0xE019, 0x03DC: 0xE008, 0x03F0: 0xE009}
};
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/AMSsymbols.js");

View File

@ -6,7 +6,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,16 +21,23 @@
* limitations under the License.
*/
MathJax.Extension["TeX/HTML"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var VERSION = "1.1";
var TEX = MathJax.InputJax.TeX;
var TEXDEF = TEX.Definitions;
TEXDEF.macros.href = 'HREF_attribute';
TEXDEF.macros["class"] = 'CLASS_attribute';
TEXDEF.macros.style = 'STYLE_attribute';
TEXDEF.macros.cssId = 'ID_attribute';
TEXDEF.Add({
macros: {
href: 'HREF_attribute',
"class": 'CLASS_attribute',
style: 'STYLE_attribute',
cssId: 'ID_attribute'
}
});
TEX.Parse.Augment({

View File

@ -0,0 +1,76 @@
/*************************************************************
*
* MathJax/extensions/TeX/action.js
*
* Implements the \mathtip, \texttip, and \toggle macros, which give
* access from TeX to the <maction> tag in the MathML that underlies
* MathJax's internal format.
*
* Usage:
*
* \mathtip{math}{tip} % use "tip" (in math mode) as tooltip for "math"
* \texttip{math}{tip} % use "tip" (in text mode) as tooltip for "math"
* \toggle{math1}{math2}...\endtoggle
* % show math1, and when clicked, show math2, and so on.
* % When the last one is clicked, go back to math1.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Extension["TeX/action"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
MML = MathJax.ElementJax.mml;
//
// Set up control sequenecs
//
TEX.Definitions.macros.toggle = 'Toggle';
TEX.Definitions.macros.mathtip = 'Mathtip';
TEX.Definitions.macros.texttip = ['Macro','\\mathtip{#1}{\\text{#2}}',2];
TEX.Parse.Augment({
//
// Implement \toggle {math1} {math2} ... \endtoggle
// (as an <maction actiontype="toggle">)
//
Toggle: function (name) {
var data = [], arg;
while ((arg = this.GetArgument(name)) !== "\\endtoggle")
{data.push(TEX.Parse(arg,this.stack.env).mml())}
this.Push(MML.maction.apply(MML,data).With({actiontype: MML.ACTIONTYPE.TOGGLE}));
},
//
// Implement \mathtip{math}{tip}
// (an an <maction actiontype="tooltip">)
//
Mathtip: function(name) {
var arg = this.ParseArg(name), tip = this.ParseArg(name);
this.Push(MML.maction(arg,tip).With({actiontype: MML.ACTIONTYPE.TOOLTIP}));
}
});
MathJax.Hub.Startup.signal.Post("TeX action Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/action.js");

View File

@ -5,7 +5,7 @@
* Adds \boldsymbol around mathematics that appears in a section
* of an HTML page that is in bold.
*
* Copyright (c) 2009 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,23 +20,23 @@
* limitations under the License.
*/
MathJax.Extension["TeX/autobold"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var VERSION = "1.1";
var TEX = MathJax.InputJax.TeX;
var oldPrefilter = TEX.prefilterMath;
TEX.prefilterMath = function (math,displaystyle,script) {
var span = script.parentNode.insertBefore(document.createElement("span"),script);
TEX.prefilterHooks.Add(function (data) {
var span = data.script.parentNode.insertBefore(document.createElement("span"),data.script);
span.visibility = "hidden";
span.style.fontFamily = "Times, serif";
span.appendChild(document.createTextNode("ABCXYZabcxyz"));
var W = span.offsetWidth;
span.style.fontWeight = "bold";
if (span.offsetWidth == W) {math = "\\bf {"+math+"}"}
if (W && span.offsetWidth === W) {data.math = "\\boldsymbol{"+data.math+"}"}
span.parentNode.removeChild(span);
return oldPrefilter.call(TEX,math,displaystyle,script);
};
});
MathJax.Hub.Startup.signal.Post("TeX autobold Ready");

View File

@ -0,0 +1,71 @@
/*************************************************************
*
* MathJax/extensions/TeX/autoload-all.js
*
* Provides pre-defined macros to autoload all the extensions
* so that all macros that MathJax knows about are available.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Extension["TeX/autoload-all"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
MACROS = TEX.Definitions.macros,
ENVS = TEX.Definitions.environment;
var EXTENSIONS = {
action: ["mathtip","texttip","toggle"],
AMSmath: ["mathring","nobreakspace","negmedspace","negthickspace","intI",
"iiiint","idotsint","dddot","ddddot","sideset","boxed",
"substack","injlim","projlim","varliminf","varlimsup",
"varinjlim","varprojlim","DeclareMathOperator","operatorname",
"genfrac","tfrac","dfrac","binom","tbinom","dbinom","cfrac",
"shoveleft","shoveright","xrightarrow","xleftarrow"],
begingroup: ["begingroup","endgroup","gdef","global"],
cancel: ["cancel","bcancel","xcancel","cancelto"],
color: ["color","colorbox","fcolorbox","DefineColor"],
enclose: ["enclose"],
extpfeil: ["Newextarrow","xlongequal","xmapsto","xtofrom",
"xtwoheadleftarrow","xtwoheadrightarrow"],
mhchem: ["ce","cee","cf"]
};
for (var name in EXTENSIONS) {if (EXTENSIONS.hasOwnProperty(name)) {
var macros = EXTENSIONS[name];
for (var i = 0, m = macros.length; i < m; i++) {
MACROS[macros[i]] = ["Extension",name];
}
}}
ENVS["subarray"] = ['ExtensionEnv',null,'AMSmath'];
ENVS["smallmatrix"] = ['ExtensionEnv',null,'AMSmath'];
ENVS["equation"] = ['ExtensionEnv',null,'AMSmath'];
ENVS["equation*"] = ['ExtensionEnv',null,'AMSmath'];
MathJax.Hub.Startup.signal.Post("TeX autoload-all Ready");
});
MathJax.Callback.Queue(
["Require",MathJax.Ajax,"[MathJax]/extensions/TeX/AMSsymbols.js"],
["loadComplete",MathJax.Ajax,"[MathJax]/extensions/TeX/autoload-all.js"]
);

90
modules/MathJax/extensions/TeX/bbox.js vendored Normal file
View File

@ -0,0 +1,90 @@
/*************************************************************
*
* MathJax/extensions/TeX/bbox.js
*
* This file implements the \bbox macro, which creates an box that
* can be styled (for background colors, and so on). You can include
* an optional dimension that tells how much extra padding to include
* around the bounding box for the mathematics, or a color specification
* for the background color to use, or both. E.g.,
*
* \bbox[2pt]{x+y} % an invisible box around x+y with 2pt of extra space
* \bbox[green]{x+y} % a green box around x+y
* \bbox[green,2pt]{x+y} % a green box with 2pt of extra space
*
* You can also specify style attributes, for example
*
* \bbox[red,border:3px solid blue,5px]{x+y}
*
* would give a red background with a 3px solid blue border that has 5px
* of padding between the border and the mathematics. Note that not all
* output formats support the style specifications. In particular, the
* NativeMML output depends on the browser to render the attributes, and
* not all MathML renderers will honor them (e.g., MathPlayer2 doesn't
* render border styles).
*
* This file will be loaded automatically when \bbox is first used.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Extension["TeX/bbox"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
MML = MathJax.ElementJax.mml;
TEX.Definitions.macros.bbox = "BBox";
TEX.Parse.Augment({
BBox: function (name) {
var bbox = this.GetBrackets(name,""),
math = this.ParseArg(name);
var parts = bbox.split(/,/), def, background, style;
for (var i in parts) {
var part = parts[i].replace(/^\s+/,'').replace(/\s+$/,'');
var match = part.match(/^(\.\d+|\d+(\.\d*)?)(pt|em|ex|mu|px|in|cm|mm)$/);
if (match) {
var pad = match[1]+match[3];
if (def) {TEX.Error("Padding specified twice in "+name)}
def = {height:"+"+pad, depth:"+"+pad, lspace:pad, width:"+"+(2*match[1])+match[3]};
} else if (part.match(/^([a-z0-9]+|\#[0-9a-f]{6}|\#[0-9a-f]{3})$/i)) {
if (background) {TEX.Error("Background specified twice in "+name)}
background = part;
} else if (part.match(/^[-a-z]+:/i)) {
if (style) {TEX.Error("Style specified twice in "+name)}
style = part;
} else if (part !== "") {
TEX.Error("'"+part+"' doesn't look like a color, a padding dimension, or a style");
}
}
if (def) {math = MML.mpadded(math).With(def)}
if (background || style) {
math = MML.mstyle(math).With({mathbackground:background, style:style});
}
this.Push(math);
}
});
MathJax.Hub.Startup.signal.Post("TeX bbox Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/bbox.js");

View File

@ -0,0 +1,296 @@
/*************************************************************
*
* MathJax/extensions/TeX/begingroup.js
*
* Implements \begingroup and \endgroup commands that make local
* definitions possible and are removed when the \endgroup occurs.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Extension["TeX/begingroup"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
TEXDEF = TEX.Definitions;
/****************************************************/
//
// A namespace for localizing macros and environments
// (\begingroup and \endgroup create and destroy these)
//
var NSFRAME = MathJax.Object.Subclass({
macros: null, // the local macro definitions
environments: null, // the local environments
Init: function (macros,environments) {
this.macros = (macros || {});
this.environments = (environments || {});
},
//
// Find a macro or environment by name
//
Find: function (name,type) {if (this[type][name]) {return this[type][name]}},
//
// Define or remove a macro or environment
//
Def: function (name,value,type) {this[type][name] = value},
Undef: function (name,type) {delete this[type][name]},
//
// Merge two namespaces (used when the equation namespace is combined with the root one)
//
Merge: function (frame) {
MathJax.Hub.Insert(this.macros,frame.macros);
MathJax.Hub.Insert(this.environments,frame.environments);
},
//
// Move global macros to the stack (globally) and remove from the frame
//
MergeGlobals: function (stack) {
var macros = this.macros;
for (var cs in macros) {if (macros.hasOwnProperty(cs) && macros[cs].global) {
stack.Def(cs,macros[cs],"macros",true);
delete macros[cs].global; delete macros[cs];
}}
},
//
// Clear the macro and environment lists
// (but not global macros unless "all" is true)
//
Clear: function (all) {
this.environments = {};
if (all) {this.macros = {}} else {
var macros = this.macros;
for (var cs in macros) {
if (macros.hasOwnProperty(cs) && !macros[cs].global) {delete macros[cs]}
}
}
return this;
}
});
/****************************************************/
//
// A Stack of namespace frames
//
var NSSTACK = TEX.nsStack = MathJax.Object.Subclass({
stack: null, // the namespace frames
top: 0, // the current top one (we don't pop for real until the equation completes)
isEqn: false, // true if this is the equation stack (not the global one)
//
// Set up the initial stack frame
//
Init: function (eqn) {
this.isEqn = eqn; this.stack = [];
if (!eqn) {this.Push(NSFRAME(TEXDEF.macros,TEXDEF.environments))}
else {this.Push(NSFRAME())}
},
//
// Define a macro or environment in the top frame
//
Def: function (name,value,type,global) {
var n = this.top-1;
if (global) {
//
// Define global macros in the base frame and remove that cs
// from all other frames. Mark the global ones in equations
// so they can be made global when merged with the root stack.
//
while (n > 0) {this.stack[n].Undef(name,type); n--}
if (!(value instanceof Array)) {value = [value]}
if (this.isEqn) {value.global = true}
}
this.stack[n].Def(name,value,type);
},
//
// Push a new namespace frame on the stack
//
Push: function (frame) {
this.stack.push(frame);
this.top = this.stack.length;
},
//
// Pop the top stack frame
// (if it is the root, just keep track of the pop so we can
// reset it if the equation is reprocessed)
//
Pop: function () {
var top;
if (this.top > 1) {
top = this.stack[--this.top];
if (this.isEqn) {this.stack.pop()}
} else if (this.isEqn) {
this.Clear();
}
return top;
},
//
// Search the stack from top to bottom for the first
// definition of the given control sequence in the given type
//
Find: function (name,type) {
for (var i = this.top-1; i >= 0; i--) {
var def = this.stack[i].Find(name,type);
if (def) {return def}
}
return null;
},
//
// Combine the equation stack with the global one
// (The bottom frame of the equation goes with the top frame of the global one,
// and the remainder are pushed on the global stack, truncated to the
// position where items were poped from it.)
//
Merge: function (stack) {
stack.stack[0].MergeGlobals(this);
this.stack[this.top-1].Merge(stack.stack[0]);
var data = [this.top,this.stack.length-this.top].concat(stack.stack.slice(1));
this.stack.splice.apply(this.stack,data);
this.top = this.stack.length;
},
//
// Put back the temporarily poped items
//
Reset: function () {this.top = this.stack.length},
//
// Clear the stack and start with a blank frame
//
Clear: function (all) {
this.stack = [this.stack[0].Clear()];
this.top = this.stack.length;
}
},{
nsFrame: NSFRAME
});
/****************************************************/
//
// Define the new macros
//
TEXDEF.macros.begingroup = "BeginGroup";
TEXDEF.macros.endgroup = "EndGroup";
TEXDEF.macros.global = ["Extension","newcommand"];
TEXDEF.macros.gdef = ["Extension","newcommand"];
TEX.Parse.Augment({
//
// Implement \begingroup
//
BeginGroup: function (name) {
TEX.eqnStack.Push(NSFRAME());
},
//
// Implements \endgroup
//
EndGroup: function (name) {
//
// If the equation has pushed frames, pop one,
// Otherwise clear the equation stack and pop the top global one
//
if (TEX.eqnStack.top > 1) {
TEX.eqnStack.Pop();
} else if (TEX.rootStack.top === 1) {
TEX.Error("Extra "+name+" or missing \\begingroup");
} else {
TEX.eqnStack.Clear();
TEX.rootStack.Pop();
}
},
//
// Replace the original routines with ones that looks through the
// equation and root stacks for the given name
//
csFindMacro: function (name) {
return (TEX.eqnStack.Find(name,"macros") || TEX.rootStack.Find(name,"macros"));
},
envFindName: function (name) {
return (TEX.eqnStack.Find(name,"environments") || TEX.rootStack.Find(name,"environments"));
}
});
/****************************************************/
TEX.rootStack = NSSTACK(); // the global namespace stack
TEX.eqnStack = NSSTACK(true); // the equation stack
//
// Reset the global stack and clear the equation stack
// (this gets us back to the initial stack state as it was
// before the equation was first processed, in case the equation
// get restarted due to an autoloaded file)
//
TEX.prefilterHooks.Add(function () {TEX.rootStack.Reset(); TEX.eqnStack.Clear(true)});
//
// We only get here if there were no errors and the equation is fully
// processed (all restarts are complete). So we merge the equation
// stack into the global stack, thus making the changes from this
// equation permanent.
//
TEX.postfilterHooks.Add(function () {TEX.rootStack.Merge(TEX.eqnStack)});
/*********************************************************/
MathJax.Hub.Register.StartupHook("TeX newcommand Ready",function () {
//
// Add the commands that depend on the newcommand code
//
TEXDEF.macros.global = "Global";
TEXDEF.macros.gdef = ["Macro","\\global\\def"];
TEX.Parse.Augment({
//
// Modify the way macros and environments are defined
// to make them go into the equation namespace stack
//
setDef: function (name,value) {
value.isUser = true;
TEX.eqnStack.Def(name,value,"macros",this.stack.env.isGlobal);
delete this.stack.env.isGlobal;
},
setEnv: function (name,value) {
value.isUser = true;
TEX.eqnStack.Def(name,value,"environments")
},
//
// Implement \global (for \global\let, \global\def and \global\newcommand)
//
Global: function (name) {
var i = this.i; var cs = this.GetCSname(name); this.i = i;
if (cs !== "let" && cs !== "def" && cs !== "newcommand")
{TEX.Error(name+" not followed by \\let, \\def, or \\newcommand")}
this.stack.env.isGlobal = true;
}
});
});
MathJax.Hub.Startup.signal.Post("TeX begingroup Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/begingroup.js");

View File

@ -7,7 +7,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,8 +22,11 @@
* limitations under the License.
*/
MathJax.Extension["TeX/boldsymbol"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var VERSION = "1.1";
var MML = MathJax.ElementJax.mml;
var TEX = MathJax.InputJax.TeX;
@ -62,6 +65,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}
});
MathJax.Hub.Startup.signal.Post("TeX boldsymbol Ready");
});
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
@ -102,9 +107,20 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
0xE26C: 0xE287}
};
}
MathJax.Hub.Startup.signal.Post("TeX boldsymbol Ready");
});
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var SVG = MathJax.OutputJax.SVG;
var FONTS = SVG.FONTDATA.FONTS;
var VARIANT = SVG.FONTDATA.VARIANT;
FONTS["MathJax_Caligraphic-bold"] = "Caligraphic/Bold/Main.js";
VARIANT["-tex-caligraphic-bold"] =
{fonts:["MathJax_Caligraphic-bold","MathJax_Main-bold","MathJax_Main","MathJax_Math","MathJax_Size1"],
offsetA: 0x41, variantA: "bold-italic"};
VARIANT["-tex-oldstyle-bold"] =
{fonts:["MathJax_Caligraphic-bold","MathJax_Main-bold","MathJax_Main","MathJax_Math","MathJax_Size1"]};
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/boldsymbol.js");

105
modules/MathJax/extensions/TeX/cancel.js vendored Normal file
View File

@ -0,0 +1,105 @@
/*************************************************************
*
* MathJax/extensions/TeX/cancel.js
*
* Implements the \cancel, \bcancel, \xcancel, and \cancelto macros.
*
* Usage:
*
* \cancel{math} % strikeout math from lower left to upper right
* \bcancel{math} % strikeout from upper left to lower right
* \xcancel{math} % strikeout with an X
* \cancelto{value}{math} % strikeout with arrow going to value
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Extension["TeX/cancel"] = {
version: "2.0",
//
// The attributes allowed in \enclose{notation}[attributes]{math}
//
ALLOWED: {
arrow: 1,
color: 1, mathcolor: 1,
background: 1, mathbackground: 1,
padding: 1,
thickness: 1
}
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
MACROS = TEX.Definitions.macros,
MML = MathJax.ElementJax.mml,
CANCEL = MathJax.Extension["TeX/cancel"];
CANCEL.setAttributes = function (def,attr) {
if (attr !== "") {
attr = attr.replace(/ /g,"").split(/,/);
for (var i = 0, m = attr.length; i < m; i++) {
var keyvalue = attr[i].split(/[:=]/);
if (CANCEL.ALLOWED[keyvalue[0]]) {
if (keyvalue[1] === "true") {keyvalue[1] = true}
if (keyvalue[1] === "false") {keyvalue[1] = false}
def[keyvalue[0]] = keyvalue[1];
}
}
}
return def;
};
//
// Set up macro
//
MACROS.cancel = ['Cancel',MML.NOTATION.UPDIAGONALSTRIKE];
MACROS.bcancel = ['Cancel',MML.NOTATION.DOWNDIAGONALSTRIKE];
MACROS.xcancel = ['Cancel',MML.NOTATION.UPDIAGONALSTRIKE+" "+MML.NOTATION.DOWNDIAGONALSTRIKE];
MACROS.cancelto = 'CancelTo';
TEX.Parse.Augment({
//
// Implement \cancel[attributes]{math},
// \bcancel[attributes]{math}, and
// \xcancel[attributes]{math}
//
Cancel: function(name,notation) {
var attr = this.GetBrackets(name,""), math = this.ParseArg(name);
var def = CANCEL.setAttributes({notation: notation},attr);
this.Push(MML.menclose(math).With(def));
},
//
// Implement \cancelto{value}[attributes]{math}
//
CancelTo: function(name,notation) {
var value = this.ParseArg(name),
attr = this.GetBrackets(name,""),
math = this.ParseArg(name);
var def = CANCEL.setAttributes({notation: MML.NOTATION.UPDIAGONALSTRIKE, arrow:true},attr);
value = MML.mpadded(value).With({depth:"-.1em",height:"+.1em",voffset:".1em"});
this.Push(MML.msup(MML.menclose(math).With(def),value));
}
});
MathJax.Hub.Startup.signal.Post("TeX cancel Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/cancel.js");

229
modules/MathJax/extensions/TeX/color.js vendored Normal file
View File

@ -0,0 +1,229 @@
/*************************************************************
*
* MathJax/extensions/TeX/color.js
*
* Implements LaTeX-compatible \color macro rather than MathJax's
* original (non-standard) version. It includes the rgb, gray, and
* named color models, and the \definecolor macro.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// The configuration defaults, augmented by the user settings
//
MathJax.Extension["TeX/color"] = {
version: "2.0",
config: MathJax.Hub.CombineConfig("TeX.color",{
padding: "5px",
border: "2px"
}),
colors: {
Apricot: "#FBB982",
Aquamarine: "#00B5BE",
Bittersweet: "#C04F17",
Black: "#221E1F",
Blue: "#2D2F92",
BlueGreen: "#00B3B8",
BlueViolet: "#473992",
BrickRed: "#B6321C",
Brown: "#792500",
BurntOrange: "#F7921D",
CadetBlue: "#74729A",
CarnationPink: "#F282B4",
Cerulean: "#00A2E3",
CornflowerBlue: "#41B0E4",
Cyan: "#00AEEF",
Dandelion: "#FDBC42",
DarkOrchid: "#A4538A",
Emerald: "#00A99D",
ForestGreen: "#009B55",
Fuchsia: "#8C368C",
Goldenrod: "#FFDF42",
Gray: "#949698",
Green: "#00A64F",
GreenYellow: "#DFE674",
JungleGreen: "#00A99A",
Lavender: "#F49EC4",
LimeGreen: "#8DC73E",
Magenta: "#EC008C",
Mahogany: "#A9341F",
Maroon: "#AF3235",
Melon: "#F89E7B",
MidnightBlue: "#006795",
Mulberry: "#A93C93",
NavyBlue: "#006EB8",
OliveGreen: "#3C8031",
Orange: "#F58137",
OrangeRed: "#ED135A",
Orchid: "#AF72B0",
Peach: "#F7965A",
Periwinkle: "#7977B8",
PineGreen: "#008B72",
Plum: "#92268F",
ProcessBlue: "#00B0F0",
Purple: "#99479B",
RawSienna: "#974006",
Red: "#ED1B23",
RedOrange: "#F26035",
RedViolet: "#A1246B",
Rhodamine: "#EF559F",
RoyalBlue: "#0071BC",
RoyalPurple: "#613F99",
RubineRed: "#ED017D",
Salmon: "#F69289",
SeaGreen: "#3FBC9D",
Sepia: "#671800",
SkyBlue: "#46C5DD",
SpringGreen: "#C6DC67",
Tan: "#DA9D76",
TealBlue: "#00AEB3",
Thistle: "#D883B7",
Turquoise: "#00B4CE",
Violet: "#58429B",
VioletRed: "#EF58A0",
White: "#FFFFFF",
WildStrawberry: "#EE2967",
Yellow: "#FFF200",
YellowGreen: "#98CC70",
YellowOrange: "#FAA21A"
},
/*
* Look up a color based on its model and definition
*/
getColor: function (model,def) {
if (!model) {model = "named"}
var fn = this["get_"+model];
if (!fn) {this.TEX.Error("Color model '"+model+"' not defined")}
return fn.call(this,def);
},
/*
* Get an RGB color
*/
get_rgb: function (rgb) {
rgb = rgb.split(/,/); var RGB = "#";
if (rgb.length !== 3) {this.TEX.Error("RGB colors require 3 decimal numbers")}
for (var i = 0; i < 3; i++) {
if (!rgb[i].match(/^(\d+(\.\d*)?|\.\d+)$/)) {this.TEX.Error("Invalid decimal number")}
var n = parseFloat(rgb[i]);
if (n < 0 || n > 1) {this.TEX.Error("RGB values must be between 0 and 1")}
n = Math.floor(n*255).toString(16); if (n.length < 2) {n = "0"+n}
RGB += n;
}
return RGB;
},
/*
* Get a gray-scale value
*/
get_gray: function (gray) {
if (!gray.match(/^(\d+(\.\d*)?|\.\d+)$/)) {this.TEX.Error("Invalid decimal number")}
var n = parseFloat(gray);
if (n < 0 || n > 1) {this.TEX.Error("Grey-scale values must be between 0 and 1")}
n = Math.floor(n*255).toString(16); if (n.length < 2) {n = "0"+n}
return "#"+n+n+n;
},
/*
* Get a named value
*/
get_named: function (name) {
if (this.colors[name]) {return this.colors[name]}
return name;
},
padding: function () {
var pad = "+"+this.config.padding;
var unit = this.config.padding.replace(/^.*?([a-z]*)$/,"$1");
var pad2 = "+"+(2*parseFloat(pad))+unit;
return {width:pad2, height:pad, depth:pad, lspace:this.config.padding};
}
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
MML = MathJax.ElementJax.mml;
var STACKITEM = TEX.Stack.Item;
var COLOR = MathJax.Extension["TeX/color"];
COLOR.TEX = TEX; // for reference in getColor above
TEX.Definitions.macros.color = "Color";
TEX.Definitions.macros.definecolor = "DefineColor";
TEX.Definitions.macros.colorbox = "ColorBox";
TEX.Definitions.macros.fcolorbox = "fColorBox";
TEX.Parse.Augment({
//
// Override \color macro definition
//
Color: function (name) {
var model = this.GetBrackets(name),
color = this.GetArgument(name);
color = COLOR.getColor(model,color);
var mml = STACKITEM.style().With({styles:{mathcolor:color}});
this.stack.env.color = color;
this.Push(mml);
},
//
// Define the \definecolor macro
//
DefineColor: function (name) {
var cname = this.GetArgument(name),
model = this.GetArgument(name),
def = this.GetArgument(name);
COLOR.colors[cname] = COLOR.getColor(model,def);
},
//
// Produce a text box with a colored background
//
ColorBox: function (name) {
var cname = this.GetArgument(name),
arg = this.InternalMath(this.GetArgument(name));
this.Push(MML.mpadded.apply(MML,arg).With({
mathbackground:COLOR.getColor("named",cname)
}).With(COLOR.padding()));
},
//
// Procude a framed text box with a colored background
//
fColorBox: function (name) {
var fname = this.GetArgument(name),
cname = this.GetArgument(name),
arg = this.InternalMath(this.GetArgument(name));
this.Push(MML.mpadded.apply(MML,arg).With({
mathbackground: COLOR.getColor("named",cname),
style: "border: "+COLOR.config.border+" solid "+COLOR.getColor("named",fname)
}).With(COLOR.padding()));
}
});
MathJax.Hub.Startup.signal.Post("TeX color Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/color.js");

View File

@ -0,0 +1,86 @@
/*************************************************************
*
* MathJax/extensions/TeX/enclose.js
*
* Implements the \enclose macros, which give access from TeX to the
* <menclose> tag in the MathML that underlies MathJax's internal format.
*
* Usage:
*
* \enclose{notation}{math} % enclose math using given notation
* \enclose{notation,notation,...}{math} % enclose with several notations
* \enclose{notation}[attributes]{math} % enclose with attributes
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Extension["TeX/enclose"] = {
version: "2.0",
//
// The attributes allowed in \enclose{notation}[attributes]{math}
//
ALLOWED: {
arrow: 1,
color: 1, mathcolor: 1,
background: 1, mathbackground: 1,
padding: 1,
thickness: 1
}
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
MML = MathJax.ElementJax.mml,
ALLOW = MathJax.Extension["TeX/enclose"].ALLOWED;
//
// Set up macro
//
TEX.Definitions.macros.enclose = 'Enclose';
TEX.Parse.Augment({
//
// Implement \enclose{notation}[attr]{math}
// (create <menclose notation="notation">math</menclose>)
//
Enclose: function(name) {
var notation = this.GetArgument(name),
attr = this.GetBrackets(name),
math = this.ParseArg(name);
var def = {notation: notation.replace(/,/g," ")};
if (attr) {
attr = attr.replace(/ /g,"").split(/,/);
for (var i = 0, m = attr.length; i < m; i++) {
var keyvalue = attr[i].split(/[:=]/);
if (ALLOW[keyvalue[0]]) {
keyvalue[1] = keyvalue[1].replace(/^"(.*)"$/,"$1");
if (keyvalue[1] === "true") {keyvalue[1] = true}
if (keyvalue[1] === "false") {keyvalue[1] = false}
def[keyvalue[0]] = keyvalue[1];
}
}
}
this.Push(MML.menclose(math).With(def));
}
});
MathJax.Hub.Startup.signal.Post("TeX enclose Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/enclose.js");

View File

@ -0,0 +1,87 @@
/*************************************************************
*
* MathJax/extensions/TeX/extpfeil.js
*
* Implements additional stretchy arrow macros.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Extension["TeX/extpfeil"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
TEXDEF = TEX.Definitions;
//
// Define the arrows to load the AMSmath extension
// (since they need its xArrow method)
//
MathJax.Hub.Insert(TEXDEF,{
macros: {
xtwoheadrightarrow: ['Extension','AMSmath'],
xtwoheadleftarrow: ['Extension','AMSmath'],
xmapsto: ['Extension','AMSmath'],
xlongequal: ['Extension','AMSmath'],
xtofrom: ['Extension','AMSmath'],
Newextarrow: ['Extension','AMSmath']
}
});
//
// Redefine the macros when AMSmath is loaded
//
MathJax.Hub.Register.StartupHook("TeX AMSmath Ready",function () {
MathJax.Hub.Insert(TEXDEF,{
macros: {
xtwoheadrightarrow: ['xArrow',0x21A0,12,16],
xtwoheadleftarrow: ['xArrow',0x219E,17,13],
xmapsto: ['xArrow',0x21A6,6,7],
xlongequal: ['xArrow',0x003D,7,7],
xtofrom: ['xArrow',0x21C4,12,12],
Newextarrow: 'NewExtArrow'
}
});
});
//
// Implements \Newextarrow to define a new arrow (not compatible with \newextarrow, but
// the equivalent for MathJax)
//
TEX.Parse.Augment({
NewExtArrow: function (name) {
var cs = this.GetArgument(name),
space = this.GetArgument(name),
chr = this.GetArgument(name);
if (!cs.match(/^\\([a-z]+|.)$/i))
{TEX.Error("First argument to "+name+" must be a control sequence name")}
if (!space.match(/^(\d+),(\d+)$/))
{TEX.Error("Second argument to "+name+" must be two integers separated by a comma")}
if (!chr.match(/^(\d+|0x[0-9A-F]+)$/i))
{TEX.Error("Third argument to "+name+" must be a unicode character number")}
cs = cs.substr(1); space = space.split(","); chr = parseInt(chr);
TEXDEF.macros[cs] = ['xArrow',chr,parseInt(space[0]),parseInt(space[1])];
}
});
MathJax.Hub.Startup.signal.Post("TeX extpfeil Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/extpfeil.js");

View File

@ -6,7 +6,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var VERSION = "1.1";
var VERSION = "2.0";
var MML = MathJax.ElementJax.mml;
var TEX = MathJax.InputJax.TeX;
@ -56,8 +56,19 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
toHTML: function (span) {
span = this.HTMLcreateSpan(span);
span.bbox = this.Core().toHTML(span).bbox;
// Firefox doesn't correctly handle a span with a negatively sized content,
// so move marginLeft to main span (this is a hack to get \iiiint to work).
// FIXME: This is a symptom of a more general problem with Firefox, and
// there probably needs to be a more general solution (e.g., modifying
// HTMLhandleSpace() to get the width and adjust the right margin to
// compensate for negative-width contents)
if (span.firstChild && span.firstChild.style.marginLeft) {
span.style.marginLeft = span.firstChild.style.marginLeft;
span.firstChild.style.marginLeft = "";
}
return span;
}
},
toSVG: function () {return this.Core().toSVG()}
});
MathJax.Hub.Startup.signal.Post("TeX mathchoice Ready");

413
modules/MathJax/extensions/TeX/mhchem.js vendored Normal file
View File

@ -0,0 +1,413 @@
/*************************************************************
*
* MathJax/extensions/TeX/mhchem.js
*
* Implements the \ce command for handling chemical formulas
* from the mhchem LaTeX package.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Extension["TeX/mhchem"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
MACROS = TEX.Definitions.macros;
/*
* This is the main class for handing the \ce and related commands.
* Its main method is Parse() which takes the argument to \ce and
* returns the corresponding TeX string.
*/
var CE = MathJax.Object.Subclass({
string: "", // the \ce string being parsed
i: 0, // the current position in the string
tex: "", // the processed TeX result
atom: false, // last processed token is an atom
sup: "", // pending superscript
sub: "", // pending subscript
//
// Store the string when a CE object is created
//
Init: function (string) {this.string = string},
//
// These are the special characters and the methods that
// handle them. All others are passed through verbatim.
//
ParseTable: {
'-': "Minus",
'+': "Plus",
'(': "Open",
')': "Close",
'[': "Open",
']': "Close",
'<': "Less",
'^': "Superscript",
'_': "Subscript",
'*': "Dot",
'.': "Dot",
'=': "Equal",
'#': "Pound",
'$': "Math",
'\\': "Macro",
' ': "Space"
},
//
// Basic arrow names for reactions
//
Arrows: {
'->': "rightarrow",
'<-': "leftarrow",
'<->': "leftrightarrow",
'<=>': "rightleftharpoons",
'<=>>': "Rightleftharpoons",
'^': "uparrow",
'v': "downarrow"
},
//
// Implementations for the various bonds
// (the ~ ones are hacks that don't work well in NativeMML)
//
Bonds: {
'-': "-",
'=': "=",
'#': "\\equiv",
'~': "\\tripledash",
'~-': "\\begin{CEstack}{}\\tripledash\\\\-\\end{CEstack}",
'~=': "\\raise2mu{\\begin{CEstack}{}\\tripledash\\\\-\\\\-\\end{CEstack}}",
'~--': "\\raise2mu{\\begin{CEstack}{}\\tripledash\\\\-\\\\-\\end{CEstack}}",
'-~-': "\\raise2mu{\\begin{CEstack}{}-\\\\\\tripledash\\\\-\\end{CEstack}}",
'...': "{\\cdot}{\\cdot}{\\cdot}",
'....': "{\\cdot}{\\cdot}{\\cdot}{\\cdot}",
'->': "\\rightarrow",
'<-': "\\leftarrow",
'??': "\\text{??}" // unknown bond
},
//
// This converts the CE string to a TeX string.
// It loops through the string and calls the proper
// method depending on the ccurrent character.
//
Parse: function () {
this.tex = ""; this.atom = false;
while (this.i < this.string.length) {
var c = this.string.charAt(this.i);
if (c.match(/[a-z]/i)) {this.ParseLetter()}
else if (c.match(/[0-9]/)) {this.ParseNumber()}
else {this["Parse"+(this.ParseTable[c]||"Other")](c)}
}
this.FinishAtom();
return this.tex;
},
//
// Make an atom name or a down arrow
//
ParseLetter: function () {
this.FinishAtom();
if (this.Match(/^v( |$)/)) {
this.tex += "{\\"+this.Arrows["v"]+"}";
} else {
this.tex += "\\text{"+this.Match(/^[a-z]+/i)+"}";
this.atom = true;
}
},
//
// Make a number of fraction preceeding an atom,
// or a subscript for an atom.
//
ParseNumber: function () {
var n = this.Match(/^\d+/);
if (this.atom && !this.sub) {
this.sub = n;
} else {
this.FinishAtom();
var match = this.Match(/^\/\d+/);
if (match) {
var frac = "\\frac{"+n+"}{"+match.substr(1)+"}";
this.tex += "\\mathchoice{\\textstyle"+frac+"}{"+frac+"}{"+frac+"}{"+frac+"}";
} else {
this.tex += n;
if (this.i < this.string.length) {this.tex += "\\,"}
}
}
},
//
// Make a superscript minus, or an arrow, or a single bond.
//
ParseMinus: function (c) {
if (this.atom && (this.i === this.string.length-1 || this.string.charAt(this.i+1) === " ")) {
this.sup += c;
} else {
this.FinishAtom();
if (this.string.substr(this.i,2) === "->") {this.i += 2; this.AddArrow("->"); return}
else {this.tex += "{-}"}
}
this.i++;
},
//
// Make a superscript plus, or pass it through
//
ParsePlus: function (c) {
if (this.atom) {this.sup += c} else {this.FinishAtom(); this.tex += c}
this.i++;
},
//
// Handle dots and double or triple bonds
//
ParseDot: function (c) {this.FinishAtom(); this.tex += "\\cdot "; this.i++},
ParseEqual: function (c) {this.FinishAtom(); this.tex += "{=}"; this.i++},
ParsePound: function (c) {this.FinishAtom(); this.tex += "{\\equiv}"; this.i++},
//
// Look for (v) or (^), or pass it through
//
ParseOpen: function (c) {
this.FinishAtom();
var match = this.Match(/^\([v^]\)/);
if (match) {this.tex += "{\\"+this.Arrows[match.charAt(1)]+"}"}
else {this.tex += "{"+c; this.i++}
},
//
// Allow ) and ] to get super- and subscripts
//
ParseClose: function (c) {this.FinishAtom(); this.atom = true; this.tex += c+"}"; this.i++},
//
// Make the proper arrow
//
ParseLess: function (c) {
this.FinishAtom();
var arrow = this.Match(/^(<->?|<=>>?)/);
if (!arrow) {this.tex += c; this.i++} else {this.AddArrow(arrow)}
},
//
// Look for a superscript, or an up arrow
//
ParseSuperscript: function (c) {
c = this.string.charAt(++this.i);
if (c === "{") {
this.i++; var m = this.Find("}");
if (m === "-.") {this.sup += "{-}{\\cdot}"} else if (m) {this.sup += CE(m).Parse()}
} else if (c === " " || c === "") {
this.tex += "{\\"+this.Arrows["^"]+"}"; this.i++;
} else {
var n = this.Match(/^(\d+|-\.)/);
if (n) {this.sup += n}
}
},
//
// Look for subscripts
//
ParseSubscript: function (c) {
if (this.string.charAt(++this.i) == "{") {
this.i++; this.sub += CE(this.Find("}")).Parse();
} else {
var n = this.Match(/^\d+/);
if (n) {this.sub += n}
}
},
//
// Look for raw TeX code to include
//
ParseMath: function (c) {
this.FinishAtom();
this.i++; this.tex += this.Find(c);
},
//
// Look for specific macros for bonds
// and allow \} to have subscripts
//
ParseMacro: function (c) {
this.FinishAtom();
this.i++; var match = this.Match(/^([a-z]+|.)/i)||" ";
if (match === "sbond") {this.tex += "{-}"}
else if (match === "dbond") {this.tex += "{=}"}
else if (match === "tbond") {this.tex += "{\\equiv}"}
else if (match === "bond") {
var bond = (this.Match(/^\{.*?\}/)||"");
bond = bond.substr(1,bond.length-2);
this.tex += "{"+(this.Bonds[bond]||"\\text{??}")+"}";
}
else if (match === "{") {this.tex += "{\\{"}
else if (match === "}") {this.tex += "\\}}"; this.atom = true}
else {this.tex += c+match}
},
//
// Ignore spaces
//
ParseSpace: function (c) {this.FinishAtom(); this.i++},
//
// Pass anything else on verbatim
//
ParseOther: function (c) {this.FinishAtom(); this.tex += c; this.i++},
//
// Process an arrow (looking for brackets for above and below)
//
AddArrow: function (arrow) {
var c = this.Match(/^[CT]\[/);
if (c) {this.i--; c = c.charAt(0)}
var above = this.GetBracket(c), below = this.GetBracket(c);
arrow = this.Arrows[arrow];
if (above || below) {
if (below) {arrow += "["+below+"]"}
arrow += "{"+above+"}";
arrow = "\\mathrel{\\x"+arrow+"}";
} else {
arrow = "\\long"+arrow+" ";
}
this.tex += arrow;
},
//
// Handle the super and subscripts for an atom
//
FinishAtom: function () {
if (this.sup || this.sub) {
if (this.sup && this.sub && !this.atom) {
//
// right-justify super- and subscripts when they are before the atom
//
var n = Math.abs(this.sup.length-this.sub.length);
if (n) {
var zeros = "0000000000".substr(0,n);
var script = (this.sup.length > this.sub.length ? "sub" : "sup");
this[script] = "\\phantom{"+zeros+"}" + this[script];
}
}
if (!this.sup) {this.sup = "\\Space{0pt}{0pt}{.2em}"} // forces subscripts to align properly
this.tex += "^{"+this.sup+"}_{"+this.sub+"}";
this.sup = this.sub = "";
}
this.atom = false;
},
//
// Find a bracket group and handle C and T prefixes
//
GetBracket: function (c) {
if (this.string.charAt(this.i) !== "[") {return ""}
this.i++; var bracket = this.Find("]");
if (c === "C") {bracket = "\\ce{"+bracket+"}"} else
if (c === "T") {
if (!bracket.match(/^\{.*\}$/)) {bracket = "{"+bracket+"}"}
bracket = "\\text"+bracket;
};
return bracket;
},
//
// Check if the string matches a regular expression
// and move past it if so, returning the match
//
Match: function (regex) {
var match = regex.exec(this.string.substr(this.i));
if (match) {match = match[0]; this.i += match.length}
return match;
},
//
// Find a particular character, skipping over braced groups
//
Find: function (c) {
var m = this.string.length, i = this.i, braces = 0;
while (this.i < m) {
var C = this.string.charAt(this.i++);
if (C === c && braces === 0) {return this.string.substr(i,this.i-i-1)}
if (C === "{") {braces++} else
if (C === "}") {
if (braces) {braces--}
else {TEX.Error("Extra close brace or missing open brace")}
}
}
if (braces) {TEX.Error("Missing close brace")};
TEX.Error("Can't find closing "+c);
}
});
/***************************************************************************/
//
// Set up the macros for chemistry
//
MACROS.ce = 'CE';
MACROS.cf = 'CE';
MACROS.cee = 'CE';
//
// Include some missing arrows (some are hacks)
//
MACROS.xleftrightarrow = ['xArrow',0x2194,6,6];
MACROS.xrightleftharpoons = ['xArrow',0x21CC,5,7]; // FIXME: doesn't stretch in HTML-CSS output
MACROS.xRightleftharpoons = ['xArrow',0x21CC,5,7]; // FIXME: how should this be handled?
// FIXME: These don't work well in FF NativeMML mode
MACROS.longrightleftharpoons = ["Macro","\\stackrel{\\textstyle{{-}\\!\\!{\\rightharpoonup}}}{\\smash{{\\leftharpoondown}\\!\\!{-}}}"];
MACROS.longRightleftharpoons = ["Macro","\\stackrel{\\textstyle{-}\\!\\!{\\rightharpoonup}}{\\small\\smash\\leftharpoondown}"];
//
// Needed for \bond for the ~ forms
//
MACROS.tripledash = ["Macro","\\raise3mu{\\tiny\\text{-}\\kern2mu\\text{-}\\kern2mu\\text{-}}"];
TEX.Definitions.environment.CEstack = ['Array',null,null,null,'r',null,"0.001em",'T',1]
//
// Add \hyphen used in some mhchem examples
//
MACROS.hyphen = ["Macro","\\text{-}"];
TEX.Parse.Augment({
//
// Implements \ce and friends
//
CE: function (name) {
var arg = this.GetArgument(name);
var tex = CE(arg).Parse();
this.string = tex + this.string.substr(this.i); this.i = 0;
}
});
//
// Indicate that the extension is ready
//
MathJax.Hub.Startup.signal.Post("TeX mhchem Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/mhchem.js");

View File

@ -7,7 +7,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,20 +22,25 @@
* limitations under the License.
*/
MathJax.Extension["TeX/newcommand"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var VERSION = "1.1";
var TEX = MathJax.InputJax.TeX;
var TEXDEF = TEX.Definitions;
MathJax.Hub.Insert(TEXDEF,{
TEXDEF.Add({
macros: {
newcommand: 'NewCommand',
renewcommand: 'NewCommand',
newenvironment: 'NewEnvironment',
def: 'MacroDef'
newcommand: 'NewCommand',
renewcommand: 'NewCommand',
newenvironment: 'NewEnvironment',
renewenvironment: 'NewEnvironment',
def: 'MacroDef',
let: 'Let'
}
})
},null,true);
TEX.Parse.Augment({
@ -44,26 +49,31 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
*/
NewCommand: function (name) {
var cs = this.trimSpaces(this.GetArgument(name)),
n = this.trimSpaces(this.GetBrackets(name)),
n = this.GetBrackets(name),
opt = this.GetBrackets(name),
def = this.GetArgument(name);
if (n === '') {n = null}
if (cs.charAt(0) === "\\") {cs = cs.substr(1)}
if (!cs.match(/^(.|[a-z]+)$/i)) {TEX.Error("Illegal control sequence name for "+name)}
if (n != null && !n.match(/^[0-9]+$/)) {TEX.Error("Illegal number of parameters specified in "+name)}
TEXDEF.macros[cs] = ['Macro',def,n];
if (n) {
n = this.trimSpaces(n);
if (!n.match(/^[0-9]+$/)) {TEX.Error("Illegal number of parameters specified in "+name)}
}
this.setDef(cs,['Macro',def,n,opt]);
},
/*
* Implement \newenvironment{name}[n]{begincmd}{endcmd}
* Implement \newenvironment{name}[n][default]{begincmd}{endcmd}
*/
NewEnvironment: function (name) {
var env = this.trimSpaces(this.GetArgument(name)),
n = this.trimSpaces(this.GetBrackets(name)),
n = this.GetBrackets(name),
bdef = this.GetArgument(name),
edef = this.GetArgument(name);
if (n === '') {n = null}
if (n != null && !n.match(/^[0-9]+$/)) {TEX.Error("Illegal number of parameters specified in "+name)}
TEXDEF.environment[env] = ['BeginEnv','EndEnv',bdef,edef,n];
if (n) {
n = this.trimSpaces(n);
if (!n.match(/^[0-9]+$/)) {TEX.Error("Illegal number of parameters specified in "+name)}
}
this.setEnv(env,['BeginEnv','EndEnv',bdef,edef,n]);
},
/*
@ -73,10 +83,46 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var cs = this.GetCSname(name),
params = this.GetTemplate(name,"\\"+cs),
def = this.GetArgument(name);
if (!(params instanceof Array)) {TEXDEF.macros[cs] = ['Macro',def,params]}
else {TEXDEF.macros[cs] = ['MacroWithTemplate',def,params[0],params[1]]}
if (!(params instanceof Array)) {this.setDef(cs,['Macro',def,params])}
else {this.setDef(cs,['MacroWithTemplate',def].concat(params))}
},
/*
* Implements the \let command
*/
Let: function (name) {
var cs = this.GetCSname(name), macro;
var c = this.GetNext(); if (c === "=") {this.i++; c = this.GetNext()}
//
// All \let commands create entries in the macros array, but we
// have to look in the various mathchar and delimiter arrays if
// the source isn't a macro already, and attach the data to a
// macro with the proper routine to process it.
//
// A command of the form \let\cs=char produces a macro equivalent
// to \def\cs{char}, which is as close as MathJax can get for this.
// So \let\bgroup={ is possible, but doesn't work as it does in TeX.
//
if (c === "\\") {
name = this.GetCSname(name);
macro = this.csFindMacro(name);
if (!macro) {
if (TEXDEF.mathchar0mi[name]) {macro = ["csMathchar0mi",TEXDEF.mathchar0mi[name]]} else
if (TEXDEF.mathchar0mo[name]) {macro = ["csMathchar0mo",TEXDEF.mathchar0mo[name]]} else
if (TEXDEF.mathchar7[name]) {macro = ["csMathchar7",TEXDEF.mathchar7[name]]} else
if (TEXDEF.delimiter["\\"+name] != null) {macro = ["csDelimiter",TEXDEF.delimiter["\\"+name]]}
}
} else {macro = ["Macro",c]; this.i++}
this.setDef(cs,macro);
},
/*
* Routines to set the macro and environment definitions
* (overridden by begingroup to make localized versions)
*/
setDef: function (name,value) {value.isUser = true; TEXDEF.macros[name] = value},
setEnv: function (name,value) {value.isUser = true; TEXDEF.environment[name] = value},
/*
* Get a CS name or give an error
*/
@ -181,6 +227,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
TEX.Environment = function (name) {
TEXDEF.environment[name] = ['BeginEnv','EndEnv'].concat([].slice.call(arguments,1));
TEXDEF.environment[name].isUser = true;
}
MathJax.Hub.Startup.signal.Post("TeX newcommand Ready");

View File

@ -15,10 +15,11 @@
* inlineDelimiters: ["",""], // or ["$","$"] or ["\\(","\\)"]
* multiLine: true, // false for TeX on all one line
* style: {
* "font-family": "serif",
* "font-size": "80%",
* "font-size": "90%",
* "text-align": "left",
* "color": "black",
* "border": "1px solid"
* "padding": "1px 3px",
* "border": "1px solid"
* // add any additional CSS styles that you want
* // (be sure there is no extra comma at the end of the last item)
* }
@ -51,7 +52,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -66,15 +67,15 @@
* limitations under the License.
*/
(function () {
var VERSION = "1.1";
(function (HUB,HTML) {
var VERSION = "2.0";
var CONFIG = MathJax.Hub.CombineConfig("TeX.noErrors",{
var CONFIG = HUB.CombineConfig("TeX.noErrors",{
disabled: false, // set to true to return to original error messages
multiLine: true,
inlineDelimiters: ["",""], // or use ["$","$"] or ["\\(","\\)"]
style: {
"font-family": "serif",
"font-size": "80%",
"font-size": "90%",
"text-align": "left",
"color": "black",
"padding": "1px 3px",
@ -92,7 +93,9 @@
config: CONFIG
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
HUB.Register.StartupHook("TeX Jax Ready",function () {
var FORMAT = MathJax.InputJax.TeX.formatError;
MathJax.InputJax.TeX.Augment({
//
// Make error messages be the original TeX code
@ -100,6 +103,9 @@
// multi-line TeX, make spaces non-breakable (to get formatting right)
//
formatError: function (err,math,displaystyle,script) {
if (CONFIG.disabled) {return FORMAT.apply(this,arguments)}
var message = err.message.replace(/\n.*/,"");
HUB.signal.Post(["TeX Jax - parse error",message,math,displaystyle,script]);
var delim = CONFIG.inlineDelimiters;
var multiLine = (displaystyle || CONFIG.multiLine);
if (!displaystyle) {math = delim[0] + math + delim[1]}
@ -108,115 +114,193 @@
}
});
});
/*******************************************************************
*
* Fix HTML-CSS output
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Config",function () {
MathJax.Hub.Config({
HUB.Register.StartupHook("HTML-CSS Jax Config",function () {
HUB.Config({
"HTML-CSS": {
styles: {
".MathJax .merror": MathJax.Hub.Insert({
"font-style": null,
"background-color": null,
"vertical-align": (MathJax.Hub.Browser.isMSIE && CONFIG.multiLine ? "-2px" : "")
".MathJax .noError": HUB.Insert({
"vertical-align": (HUB.Browser.isMSIE && CONFIG.multiLine ? "-2px" : "")
},CONFIG.style)
}
}
});
});
HUB.Register.StartupHook("HTML-CSS Jax Ready",function () {
var MML = MathJax.ElementJax.mml;
var HTMLCSS = MathJax.OutputJax["HTML-CSS"];
var MATH = MML.math.prototype.toHTML,
MERROR = MML.merror.prototype.toHTML;
//
// Override math toHTML routine so that error messages
// don't have the clipping and other unneeded overhead
//
MML.math.Augment({
toHTML: function (span,node) {
var data = this.data[0];
if (data && data.data[0] && data.data[0].isError) {
span.style.fontSize = "";
span = this.HTMLcreateSpan(span);
span.bbox = data.data[0].toHTML(span).bbox;
} else {
span = MATH.call(this,span,node);
}
return span;
}
});
//
// Override merror toHTML routine so that it puts out the
// TeX code in an inline-block with line breaks as in the original
//
MML.merror.Augment({
toHTML: function (span) {
if (!this.isError) {return MERROR.call(this,span)}
span = this.HTMLcreateSpan(span); span.className = "noError"
if (this.multiLine) {span.style.display = "inline-block"}
var text = this.data[0].data[0].data.join("").split(/\n/);
for (var i = 0, m = text.length; i < m; i++) {
HTMLCSS.addText(span,text[i]);
if (i !== m-1) {HTMLCSS.addElement(span,"br",{isMathJax:true})}
}
var HD = HTMLCSS.getHD(span.parentNode), W = HTMLCSS.getW(span.parentNode);
if (m > 1) {
var H = (HD.h + HD.d)/2, x = HTMLCSS.TeX.x_height/2;
span.parentNode.style.verticalAlign = HTMLCSS.Em(HD.d+(x-H));
HD.h = x + H; HD.d = H - x;
}
span.bbox = {h: HD.h, d: HD.d, w: W, lw: 0, rw: W};
return span;
}
});
});
/*******************************************************************
*
* Fix SVG output
*/
HUB.Register.StartupHook("SVG Jax Config",function () {
HUB.Config({
"SVG": {
styles: {
".MathJax_SVG .noError": HUB.Insert({
"vertical-align": (HUB.Browser.isMSIE && CONFIG.multiLine ? "-2px" : "")
},CONFIG.style)
}
}
});
});
})();
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var MML = MathJax.ElementJax.mml;
var HTMLCSS = MathJax.OutputJax["HTML-CSS"];
//
// Override math toHTML routine so that error messages
// don't have the clipping and other unneeded overhead
//
var math_toHTML = MML.math.prototype.toHTML;
MML.math.Augment({
toHTML: function (span,node) {
if (this.data[0] && this.data[0].data[0] && this.data[0].data[0].isError) {
return this.data[0].data[0].toHTML(span);
HUB.Register.StartupHook("SVG Jax Ready",function () {
var MML = MathJax.ElementJax.mml;
var MATH = MML.math.prototype.toSVG,
MERROR = MML.merror.prototype.toSVG;
//
// Override math toSVG routine so that error messages
// don't have the clipping and other unneeded overhead
//
MML.math.Augment({
toSVG: function (span,node) {
var data = this.data[0];
if (data && data.data[0] && data.data[0].isError)
{span = data.data[0].toSVG(span)} else {span = MATH.call(this,span,node)}
return span;
}
return math_toHTML.call(this,span,node);
}
});
//
// Override merror toSVG routine so that it puts out the
// TeX code in an inline-block with line breaks as in the original
//
MML.merror.Augment({
toSVG: function (span) {
if (!this.isError || this.Parent().type !== "math") {return MERROR.call(this,span)}
span = HTML.addElement(span,"span",{className: "noError", isMathJax:true});
if (this.multiLine) {span.style.display = "inline-block"}
var text = this.data[0].data[0].data.join("").split(/\n/);
for (var i = 0, m = text.length; i < m; i++) {
HTML.addText(span,text[i]);
if (i !== m-1) {HTML.addElement(span,"br",{isMathJax:true})}
}
if (m > 1) {
var H = span.offsetHeight/2;
span.style.verticalAlign = (-H+(H/m))+"px";
}
return span;
}
});
});
//
// Override merror toHTML routine so that it puts out the
// TeX code in an inline-block with line breaks as in the original
//
MML.merror.Augment({
toHTML: function (span) {
if (!this.isError) {return MML.mbase.prototype.toHTML.call(this,span)}
span = this.HTMLcreateSpan(span);
if (this.multiLine) {span.style.display = "inline-block"}
var text = this.data[0].data[0].data.join("").split(/\n/);
for (var i = 0, m = text.length; i < m; i++) {
HTMLCSS.addText(span,text[i]);
if (i !== m-1) {HTMLCSS.addElement(span,"br")}
/*******************************************************************
*
* Fix NativeMML output
*/
HUB.Register.StartupHook("NativeMML Jax Ready",function () {
var MML = MathJax.ElementJax.mml;
var CONFIG = MathJax.Extension["TeX/noErrors"].config;
var MATH = MML.math.prototype.toNativeMML,
MERROR = MML.merror.prototype.toNativeMML;
//
// Override math toNativeMML routine so that error messages
// don't get placed inside math tags.
//
MML.math.Augment({
toNativeMML: function (span) {
var data = this.data[0];
if (data && data.data[0] && data.data[0].isError)
{span = data.data[0].toNativeMML(span)} else {span = MATH.call(this,span)}
return span;
}
var HD = HTMLCSS.getHD(span.parentNode), W = HTMLCSS.getW(span.parentNode);
if (m > 1) {
var H = (HD.h + HD.d)/2, x = HTMLCSS.TeX.x_height/2;
var scale = HTMLCSS.config.styles[".MathJax .merror"]["font-size"];
if (scale && scale.match(/%/)) {x *= parseInt(scale)/100}
span.parentNode.style.verticalAlign = HTMLCSS.Em(HD.d+(x-H));
HD.h = x + H; HD.d = H - x;
});
//
// Override merror toNativeMML routine so that it puts out the
// TeX code in an inline-block with line breaks as in the original
//
MML.merror.Augment({
toNativeMML: function (span) {
if (!this.isError) {return MERROR.call(this,span)}
span = span.appendChild(document.createElement("span"));
var text = this.data[0].data[0].data.join("").split(/\n/);
for (var i = 0, m = text.length; i < m; i++) {
span.appendChild(document.createTextNode(text[i]));
if (i !== m-1) {span.appendChild(document.createElement("br"))}
}
if (this.multiLine) {
span.style.display = "inline-block";
if (m > 1) {span.style.verticalAlign = "middle"}
}
for (var id in CONFIG.style) {if (CONFIG.style.hasOwnProperty(id)) {
var ID = id.replace(/-./g,function (c) {return c.charAt(1).toUpperCase()});
span.style[ID] = CONFIG.style[id];
}}
return span;
}
span.bbox = {h: HD.h, d: HD.d, w: W, lw: 0, rw: W};
return span;
}
});
});
MathJax.Hub.Startup.signal.Post("TeX noErrors Ready");
});
MathJax.Hub.Register.StartupHook("NativeMML Jax Ready",function () {
var MML = MathJax.ElementJax.mml;
var CONFIG = MathJax.Extension["TeX/noErrors"].config;
/*******************************************************************/
//
// Override math toNativeMML routine so that error messages
// don't get placed inside math tags.
//
var math_toNativeMML = MML.math.prototype.toNativeMML;
MML.math.Augment({
toNativeMML: function (span) {
if (this.data[0] && this.data[0].data[0] && this.data[0].data[0].isError) {
return this.data[0].data[0].toNativeMML(span);
}
return math_toNativeMML.call(this,span);
}
});
//
// Override merror toNativeMML routine so that it puts out the
// TeX code in an inline-block with line breaks as in the original
//
MML.merror.Augment({
toNativeMML: function (span) {
if (!this.isError) {return MML.mbase.prototype.toNativeMML.call(this,span)}
span = span.appendChild(document.createElement("span"));
var text = this.data[0].data[0].data.join("").split(/\n/);
for (var i = 0, m = text.length; i < m; i++) {
span.appendChild(document.createTextNode(text[i]));
if (i !== m-1) {span.appendChild(document.createElement("br"))}
}
if (this.multiLine) {
span.style.display = "inline-block";
if (m > 1) {span.style.verticalAlign = "middle"}
}
for (var id in CONFIG.style) {if (CONFIG.style.hasOwnProperty(id)) {
var ID = id.replace(/-./g,function (c) {return c.charAt(1).toUpperCase()});
span.style[ID] = CONFIG.style[id];
}}
return span;
}
});
HUB.Startup.signal.Post("TeX noErrors Ready");
MathJax.Hub.Startup.signal.Post("TeX noErrors Ready");
});
})(MathJax.Hub,MathJax.HTML);
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/noErrors.js");

View File

@ -22,7 +22,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,10 +39,11 @@
//
// The configuration defaults, augmented by the user settings
//
//
MathJax.Extension["TeX/noUndefined"] = {
version: "1.1",
version: "2.0",
config: MathJax.Hub.CombineConfig("TeX.noUndefined",{
disabled: false, // set to true to return to original error messages
attributes: {
mathcolor: "red"
}
@ -52,9 +53,12 @@ MathJax.Extension["TeX/noUndefined"] = {
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var CONFIG = MathJax.Extension["TeX/noUndefined"].config;
var MML = MathJax.ElementJax.mml;
var UNDEFINED = MathJax.InputJax.TeX.Parse.prototype.csUndefined;
MathJax.InputJax.TeX.Parse.Augment({
csUndefined: function (name) {
if (CONFIG.disabled) {return UNDEFINED.apply(this,arguments)}
MathJax.Hub.signal.Post(["TeX Jax - undefined control sequence",name]);
this.Push(MML.mtext(name).With(CONFIG.attributes));
}
});

View File

@ -14,7 +14,7 @@
* \unicode[.55,0.05][Geramond]{x22D6} % same taken from Geramond font
* \unicode[Garamond]{x22D6} % same, but with default height, depth of .8,.2
*
* Once a size and font are provided for a given conde point, they need
* Once a size and font are provided for a given code point, they need
* not be specified again in subsequent \unicode calls for that character.
* Note that a font list can be given, but Internet Explorer has a buggy
* implementation of font-family where it only looks in the first
@ -40,7 +40,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -59,7 +59,7 @@
// The configuration defaults, augmented by the user settings
//
MathJax.Extension["TeX/unicode"] = {
version: "1.1",
version: "2.0",
unicode: {},
config: MathJax.Hub.CombineConfig("TeX.unicode",{
fonts: "STIXGeneral,'Arial Unicode MS'"
@ -69,7 +69,6 @@ MathJax.Extension["TeX/unicode"] = {
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX;
var MML = MathJax.ElementJax.mml;
var FONTS = MathJax.Extension["TeX/unicode"].config.fonts;
var UNICODE = MathJax.Extension["TeX/unicode"].unicode;
//
@ -83,50 +82,83 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
Unicode: function(name) {
var HD = this.GetBrackets(name), font;
if (HD) {
HD = HD.replace(/ /g,"");
if (HD.match(/^(\d+(\.\d*)?|\.\d+),(\d+(\.\d*)?|\.\d+)$/))
{HD = HD.split(/,/); font = this.GetBrackets(name)} else {font = HD; HD = null}
if (HD.replace(/ /g,"").match(/^(\d+(\.\d*)?|\.\d+),(\d+(\.\d*)?|\.\d+)$/))
{HD = HD.replace(/ /g,"").split(/,/); font = this.GetBrackets(name)}
else {font = HD; HD = null}
}
var n = this.trimSpaces(this.GetArgument(name)),
N = parseInt(n.match(/^x/) ? "0"+n : n);
UNICODE[N] = [800,200,500,0,500,{isUnknown:true, isUnicode:true, font:FONTS}];
if (!UNICODE[N]) {UNICODE[N] = [800,200,font,N]}
else if (!font) {font = UNICODE[N][2]}
if (HD) {
UNICODE[N][0] = Math.floor(HD[0]*1000);
UNICODE[N][1] = Math.floor(HD[1]*1000);
}
var variant = this.stack.env.font, def = {};
if (font) {
def.fontfamily = font;
UNICODE[N][2] = def.fontfamily = font.replace(/"/g,"'");
if (variant) {
if (variant.match(/bold/)) {def.fontweight = "bold"}
if (variant.match(/italic/)) {def.fontstyle = "italic"}
if (variant.match(/italic|-mathit/)) {def.fontstyle = "italic"}
}
UNICODE[N][5].font = font+","+FONTS
} else if (variant) {def.mathvariant = variant}
def.unicode = [].concat(UNICODE[N]); // make a copy
this.Push(MML.mtext(MML.entity("#"+n)).With(def));
}
});
});
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"];
var UNICODE = MathJax.Extension["TeX/unicode"].unicode;
//
// Override lookupChar to add unicode character to font
//
var save_lookupChar = HTMLCSS.lookupChar;
HTMLCSS.Augment({
lookupChar: function (variant,n) {
var font = save_lookupChar.call(this,variant,n);
if (font[n][5] && font[n][5].isUnknown && UNICODE[n]) {font[n] = UNICODE[n]}
return font;
}
});
MathJax.Hub.Startup.signal.Post("TeX unicode Ready");
});
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var MML = MathJax.ElementJax.mml;
var FONTS = MathJax.Extension["TeX/unicode"].config.fonts;
//
// Override getVariant to make one that includes the font and size
//
var GETVARIANT = MML.mbase.prototype.HTMLgetVariant;
MML.mbase.Augment({
HTMLgetVariant: function () {
var variant = GETVARIANT.call(this);
if (variant.unicode) {delete variant.unicode; delete variant.FONTS} // clear font cache in case of restart
if (!this.unicode) {return variant}
variant.unicode = true;
if (!variant.defaultFont) {
variant = MathJax.Hub.Insert({},variant); // make a copy
variant.defaultFont = {family:FONTS};
}
var family = this.unicode[2]; if (family) {family += ","+FONTS} else {family = FONTS}
variant.defaultFont[this.unicode[3]] = [
this.unicode[0],this.unicode[1],500,0,500,
{isUnknown:true, isUnicode:true, font:family}
];
return variant;
}
});
});
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var MML = MathJax.ElementJax.mml;
var FONTS = MathJax.Extension["TeX/unicode"].config.fonts;
//
// Override getVariant to make one that includes the font and size
//
var GETVARIANT = MML.mbase.prototype.SVGgetVariant;
MML.mbase.Augment({
SVGgetVariant: function () {
var variant = GETVARIANT.call(this);
if (variant.unicode) {delete variant.unicode; delete variant.FONTS} // clear font cache in case of restart
if (!this.unicode) {return variant}
variant.unicode = true;
if (!variant.forceFamily) {variant = MathJax.Hub.Insert({},variant)} // make a copy
variant.defaultFamily = FONTS; variant.noRemap = true;
variant.h = this.unicode[0]; variant.d = this.unicode[1];
return variant;
}
});
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/unicode.js");

View File

@ -7,7 +7,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,8 +22,11 @@
* limitations under the License.
*/
MathJax.Extension["TeX/verb"] = {
version: "2.0"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var VERSION = "1.1";
var MML = MathJax.ElementJax.mml;
var TEX = MathJax.InputJax.TeX;

View File

@ -0,0 +1,228 @@
/*************************************************************
*
* MathJax/extensions/asciimath2jax.js
*
* Implements the AsciiMath to Jax preprocessor that locates AsciiMath
* code within the text of a document and replaces it with SCRIPT tags for
* processing by MathJax.
*
* Modified by David Lippman, based on tex2jax.js.
* Additional work by Davide P. Cervone.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Extension.asciimath2jax = {
version: "2.0",
config: {
delimiters: [['`','`']], // The star/stop delimiter pairs for asciimath code
skipTags: ["script","noscript","style","textarea","pre","code"],
// The names of the tags whose contents will not be
// scanned for math delimiters
ignoreClass: "asciimath2jax_ignore", // the class name of elements whose contents should
// NOT be processed by asciimath2jax. Note that this
// is a regular expression, so be sure to quote any
// regexp special characters
processClass: "asciimath2jax_process", // the class name of elements whose contents SHOULD
// be processed when they appear inside ones that
// are ignored. Note that this is a regular expression,
// so be sure to quote any regexp special characters
preview: "AsciiMath" // set to "none" to not insert MathJax_Preview spans
// or set to an array specifying an HTML snippet
// to use the same preview for every equation.
},
PreProcess: function (element) {
if (!this.configured) {
this.config = MathJax.Hub.CombineConfig("asciimath2jax",this.config);
if (this.config.Augment) {MathJax.Hub.Insert(this,this.config.Augment)}
this.configured = true;
}
if (typeof(element) === "string") {element = document.getElementById(element)}
if (!element) {element = document.body}
if (this.createPatterns()) {this.scanElement(element,element.nextSibling)}
},
createPatterns: function () {
var starts = [], i, m, config = this.config; this.match = {};
if (config.delimiters.length === 0) {return false}
for (i = 0, m = config.delimiters.length; i < m; i++) {
starts.push(this.patternQuote(config.delimiters[i][0]));
this.match[config.delimiters[i][0]] = {
mode: "",
end: config.delimiters[i][1],
pattern: this.endPattern(config.delimiters[i][1])
};
}
this.start = new RegExp(starts.sort(this.sortLength).join("|"),"g");
this.skipTags = new RegExp("^("+config.skipTags.join("|")+")$","i");
this.ignoreClass = new RegExp("(^| )("+config.ignoreClass+")( |$)");
this.processClass = new RegExp("(^| )("+config.processClass+")( |$)");
return true;
},
patternQuote: function (s) {return s.replace(/([\^$(){}+*?\-|\[\]\:\\])/g,'\\$1')},
endPattern: function (end) {
return new RegExp(this.patternQuote(end)+"|\\\\.","g");
},
sortLength: function (a,b) {
if (a.length !== b.length) {return b.length - a.length}
return (a == b ? 0 : (a < b ? -1 : 1));
},
scanElement: function (element,stop,ignore) {
var cname, tname, ignoreChild, process;
while (element && element != stop) {
if (element.nodeName.toLowerCase() === '#text') {
if (!ignore) {element = this.scanText(element)}
} else {
cname = (typeof(element.className) === "undefined" ? "" : element.className);
tname = (typeof(element.tagName) === "undefined" ? "" : element.tagName);
if (typeof(cname) !== "string") {cname = String(cname)} // jsxgraph uses non-string class names!
process = this.processClass.exec(cname);
if (element.firstChild && !cname.match(/(^| )MathJax/) &&
(process || !this.skipTags.exec(tname))) {
ignoreChild = (ignore || this.ignoreClass.exec(cname)) && !process;
this.scanElement(element.firstChild,stop,ignoreChild);
}
}
if (element) {element = element.nextSibling}
}
},
scanText: function (element) {
if (element.nodeValue.replace(/\s+/,'') == '') {return element}
var match, prev;
this.search = {start: true};
this.pattern = this.start;
while (element) {
this.pattern.lastIndex = 0;
while (element && element.nodeName.toLowerCase() === '#text' &&
(match = this.pattern.exec(element.nodeValue))) {
if (this.search.start) {element = this.startMatch(match,element)}
else {element = this.endMatch(match,element)}
}
if (this.search.matched) {element = this.encloseMath(element)}
if (element) {
do {prev = element; element = element.nextSibling}
while (element && (element.nodeName.toLowerCase() === 'br' ||
element.nodeName.toLowerCase() === '#comment'));
if (!element || element.nodeName !== '#text') {return prev}
}
}
return element;
},
startMatch: function (match,element) {
var delim = this.match[match[0]];
if (delim != null) {
this.search = {
end: delim.end, mode: delim.mode,
open: element, olen: match[0].length,
opos: this.pattern.lastIndex - match[0].length
};
this.switchPattern(delim.pattern);
}
return element;
},
endMatch: function (match,element) {
if (match[0] == this.search.end) {
this.search.close = element;
this.search.cpos = this.pattern.lastIndex;
this.search.clen = (this.search.isBeginEnd ? 0 : match[0].length);
this.search.matched = true;
element = this.encloseMath(element);
this.switchPattern(this.start);
}
return element;
},
switchPattern: function (pattern) {
pattern.lastIndex = this.pattern.lastIndex;
this.pattern = pattern;
this.search.start = (pattern === this.start);
},
encloseMath: function (element) {
var search = this.search, close = search.close, CLOSE, math;
if (search.cpos === close.length) {close = close.nextSibling}
else {close = close.splitText(search.cpos)}
if (!close) {CLOSE = close = MathJax.HTML.addText(search.close.parentNode,"")}
search.close = close;
math = (search.opos ? search.open.splitText(search.opos) : search.open);
while (math.nextSibling && math.nextSibling !== close) {
if (math.nextSibling.nodeValue !== null) {
if (math.nextSibling.nodeName === "#comment") {
math.nodeValue += math.nextSibling.nodeValue.replace(/^\[CDATA\[((.|\n|\r)*)\]\]$/,"$1");
} else {
math.nodeValue += math.nextSibling.nodeValue;
}
} else if (this.msieNewlineBug) {
math.nodeValue += (math.nextSibling.nodeName.toLowerCase() === "br" ? "\n" : " ");
} else {
math.nodeValue += " ";
}
math.parentNode.removeChild(math.nextSibling);
}
var AM = math.nodeValue.substr(search.olen,math.nodeValue.length-search.olen-search.clen);
math.parentNode.removeChild(math);
if (this.config.preview !== "none") {this.createPreview(search.mode,AM)}
math = this.createMathTag(search.mode,AM);
this.search = {}; this.pattern.lastIndex = 0;
if (CLOSE) {CLOSE.parentNode.removeChild(CLOSE)}
return math;
},
insertNode: function (node) {
var search = this.search;
search.close.parentNode.insertBefore(node,search.close);
},
createPreview: function (mode,asciimath) {
var preview;
if (this.config.preview === "AsciiMath") {preview = [this.filterPreview(asciimath)]}
else if (this.config.preview instanceof Array) {preview = this.config.preview}
if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
this.insertNode(preview);
}
},
createMathTag: function (mode,asciimath) {
var script = document.createElement("script");
script.type = "math/asciimath" + mode;
MathJax.HTML.setScript(script,asciimath);
this.insertNode(script);
return script;
},
filterPreview: function (asciimath) {return asciimath},
msieNewlineBug: (MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 9)
};
MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.asciimath2jax]);
MathJax.Ajax.loadComplete("[MathJax]/extensions/asciimath2jax.js");

View File

@ -15,7 +15,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,7 +31,7 @@
*/
MathJax.Extension.jsMath2jax = {
version: "1.1.1",
version: "2.0",
config: {
preview: "TeX" // Set to "none" to prevent preview strings from being inserted
@ -71,7 +71,7 @@ MathJax.Extension.jsMath2jax = {
createPreview: function (node) {
var preview;
if (this.config.preview === "TeX") {preview = [this.filterTeX(node.innerHTML)]}
if (this.config.preview === "TeX") {preview = [this.filterPreview(node.innerHTML)]}
else if (this.config.preview instanceof Array) {preview = this.config.preview}
if (preview) {
preview = MathJax.HTML.Element("span",{className: MathJax.Hub.config.preRemoveClass},preview);
@ -87,7 +87,7 @@ MathJax.Extension.jsMath2jax = {
return script;
},
filterTeX: function (tex) {return tex}
filterPreview: function (tex) {return tex}
};

View File

@ -8,7 +8,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,7 +24,7 @@
*/
MathJax.Extension.mml2jax = {
version: "1.1.2",
version: "2.0",
config: {
preview: "alttext" // Use the <math> element's alttext as the
// preview. Set to "none" for no preview,
@ -55,12 +55,27 @@ MathJax.Extension.mml2jax = {
//
// Handle math with namespaces in HTML
//
var html = document.getElementsByTagName("html")[0];
if (html) {
for (var i = 0, m = html.attributes.length; i < m; i++) {
var attr = html.attributes[i];
if (attr.nodeName.substr(0,6) === "xmlns:" && attr.nodeValue === this.MMLnamespace)
{this.ProcessMathArray(element.getElementsByTagName(attr.nodeName.substr(6)+":math"))}
var i, m;
if (document.namespaces) {
//
// IE namespaces are listed in document.namespaces
//
for (i = 0, m = document.namespaces.length; i < m; i++) {
var ns = document.namespaces[i];
if (ns.urn === this.MMLnamespace)
{this.ProcessMathArray(element.getElementsByTagName(ns.name+":math"))}
}
} else {
//
// Everybody else
//
var html = document.getElementsByTagName("html")[0];
if (html) {
for (i = 0, m = html.attributes.length; i < m; i++) {
var attr = html.attributes[i];
if (attr.nodeName.substr(0,6) === "xmlns:" && attr.nodeValue === this.MMLnamespace)
{this.ProcessMathArray(element.getElementsByTagName(attr.nodeName.substr(6)+":math"))}
}
}
}
},
@ -162,7 +177,7 @@ MathJax.Extension.mml2jax = {
var preview;
if (this.config.preview === "alttext") {
var text = math.getAttribute("alttext");
if (text != null) {preview = [this.filterText(text)]}
if (text != null) {preview = [this.filterPreview(text)]}
} else if (this.config.preview instanceof Array) {preview = this.config.preview}
if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
@ -170,7 +185,7 @@ MathJax.Extension.mml2jax = {
}
},
filterText: function (text) {return text},
filterPreview: function (text) {return text},
InitBrowser: function () {
var test = MathJax.HTML.Element("span",{id:"<", className: "mathjax", innerHTML: "<math><mi>x</mi><mspace /></math>"});

View File

@ -8,7 +8,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009-2011 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,7 +24,7 @@
*/
MathJax.Extension.tex2jax = {
version: "1.1.3",
version: "2.0",
config: {
inlineMath: [ // The start/stop pairs for in-line math
// ['$','$'], // (comment out any you don't want, or add your own, but
@ -36,6 +36,10 @@ MathJax.Extension.tex2jax = {
['\\[','\\]'] // be sure that you don't have an extra comma at the end)
],
balanceBraces: true, // determines whether tex2jax requires braces to be
// balanced within math delimiters (allows for nested
// dollar signs). Set to false to get pre-v2.0 compatibility.
skipTags: ["script","noscript","style","textarea","pre","code"],
// The names of the tags whose contents will not be
// scanned for math delimiters
@ -56,6 +60,9 @@ MathJax.Extension.tex2jax = {
processEnvironments: true, // set to true to process \begin{xxx}...\end{xxx} outside
// of math mode, false to prevent that
processRefs: true, // set to true to process \ref{...} outside of math mode
preview: "TeX" // set to "none" to not insert MathJax_Preview spans
// or set to an array specifying an HTML snippet
// to use the same preview for every equation.
@ -72,12 +79,11 @@ MathJax.Extension.tex2jax = {
}
if (typeof(element) === "string") {element = document.getElementById(element)}
if (!element) {element = document.body}
this.createPatterns();
this.scanElement(element,element.nextSibling);
if (this.createPatterns()) {this.scanElement(element,element.nextSibling)}
},
createPatterns: function () {
var starts = [], i, m, config = this.config;
var starts = [], parts = [], i, m, config = this.config;
this.match = {};
for (i = 0, m = config.inlineMath.length; i < m; i++) {
starts.push(this.patternQuote(config.inlineMath[i][0]));
@ -95,20 +101,21 @@ MathJax.Extension.tex2jax = {
pattern: this.endPattern(config.displayMath[i][1])
};
}
this.start = new RegExp(
starts.sort(this.sortLength).join("|") +
(config.processEnvironments ? "|\\\\begin\\{([^}]*)\\}" : "") +
(config.processEscapes ? "|\\\\*\\\\\\\$" : ""), "g"
);
if (starts.length) {parts.push(starts.sort(this.sortLength).join("|"))}
if (config.processEnvironments) {parts.push("\\\\begin\\{([^}]*)\\}")}
if (config.processEscapes) {parts.push("\\\\*\\\\\\\$")}
if (config.processRefs) {parts.push("\\\\(eq)?ref\\{[^}]*\\}")}
this.start = new RegExp(parts.join("|"),"g");
this.skipTags = new RegExp("^("+config.skipTags.join("|")+")$","i");
this.ignoreClass = new RegExp("(^| )("+config.ignoreClass+")( |$)");
this.processClass = new RegExp("(^| )("+config.processClass+")( |$)");
return (parts.length > 0);
},
patternQuote: function (s) {return s.replace(/([\^$(){}+*?\-|\[\]\:\\])/g,'\\$1')},
endPattern: function (end) {
return new RegExp(this.patternQuote(end)+"|\\\\.","g");
return new RegExp(this.patternQuote(end)+"|\\\\.|[{}]","g");
},
sortLength: function (a,b) {
@ -117,7 +124,7 @@ MathJax.Extension.tex2jax = {
},
scanElement: function (element,stop,ignore) {
var cname, tname, ignoreChild;
var cname, tname, ignoreChild, process;
while (element && element != stop) {
if (element.nodeName.toLowerCase() === '#text') {
if (!ignore) {element = this.scanText(element)}
@ -125,8 +132,10 @@ MathJax.Extension.tex2jax = {
cname = (typeof(element.className) === "undefined" ? "" : element.className);
tname = (typeof(element.tagName) === "undefined" ? "" : element.tagName);
if (typeof(cname) !== "string") {cname = String(cname)} // jsxgraph uses non-string class names!
if (element.firstChild && !cname.match(/(^| )MathJax/) && !this.skipTags.exec(tname)) {
ignoreChild = (ignore || this.ignoreClass.exec(cname)) && !this.processClass.exec(cname);
process = this.processClass.exec(cname);
if (element.firstChild && !cname.match(/(^| )MathJax/) &&
(process || !this.skipTags.exec(tname))) {
ignoreChild = (ignore || this.ignoreClass.exec(cname)) && !process;
this.scanElement(element.firstChild,stop,ignoreChild);
}
}
@ -151,7 +160,8 @@ MathJax.Extension.tex2jax = {
do {prev = element; element = element.nextSibling}
while (element && (element.nodeName.toLowerCase() === 'br' ||
element.nodeName.toLowerCase() === '#comment'));
if (!element || element.nodeName !== '#text') {return prev}
if (!element || element.nodeName !== '#text')
{return (this.search.close ? this.prevEndMatch() : prev)}
}
}
return element;
@ -161,17 +171,23 @@ MathJax.Extension.tex2jax = {
var delim = this.match[match[0]];
if (delim != null) { // a start delimiter
this.search = {
end: delim.end, mode: delim.mode,
end: delim.end, mode: delim.mode, pcount: 0,
open: element, olen: match[0].length, opos: this.pattern.lastIndex - match[0].length
};
this.switchPattern(delim.pattern);
} else if (match[0].substr(0,6) === "\\begin") { // \begin{...}
this.search = {
end: "\\end{"+match[1]+"}", mode: "; mode=display",
end: "\\end{"+match[1]+"}", mode: "; mode=display", pcount: 0,
open: element, olen: 0, opos: this.pattern.lastIndex - match[0].length,
isBeginEnd: true
};
this.switchPattern(this.endPattern(this.search.end));
} else if (match[0].substr(0,4) === "\\ref" || match[0].substr(0,6) === "\\eqref") {
this.search = {
mode: "", end: "", open: element, pcount: 0,
olen: 0, opos: this.pattern.lastIndex - match[0].length
}
return this.endMatch([""],element);
} else { // escaped dollar signs
// put $ in a span so it doesn't get processed again
// split off backslashes so they don't get removed later
@ -189,14 +205,27 @@ MathJax.Extension.tex2jax = {
},
endMatch: function (match,element) {
if (match[0] == this.search.end) {
this.search.close = element;
this.search.cpos = this.pattern.lastIndex;
this.search.clen = (this.search.isBeginEnd ? 0 : match[0].length);
this.search.matched = true;
element = this.encloseMath(element);
this.switchPattern(this.start);
var search = this.search;
if (match[0] == search.end) {
if (!search.close || search.pcount === 0) {
search.close = element;
search.cpos = this.pattern.lastIndex;
search.clen = (search.isBeginEnd ? 0 : match[0].length);
}
if (search.pcount === 0) {
search.matched = true;
element = this.encloseMath(element);
this.switchPattern(this.start);
}
}
else if (match[0] === "{") {search.pcount++}
else if (match[0] === "}" && search.pcount) {search.pcount--}
return element;
},
prevEndMatch: function () {
this.search.matched = true;
var element = this.encloseMath(this.search.close);
this.switchPattern(this.start);
return element;
},
@ -243,7 +272,7 @@ MathJax.Extension.tex2jax = {
createPreview: function (mode,tex) {
var preview;
if (this.config.preview === "TeX") {preview = [this.filterTeX(tex)]}
if (this.config.preview === "TeX") {preview = [this.filterPreview(tex)]}
else if (this.config.preview instanceof Array) {preview = this.config.preview}
if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
@ -259,7 +288,7 @@ MathJax.Extension.tex2jax = {
return script;
},
filterTeX: function (tex) {return tex},
filterPreview: function (tex) {return tex},
msieNewlineBug: (MathJax.Hub.Browser.isMSIE && document.documentMode < 9)

View File

@ -7,7 +7,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,16 +23,17 @@
*/
MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
var VERSION = "1.1.1";
var VERSION = "2.0";
var MML = MathJax.ElementJax.mml;
var MML = MathJax.ElementJax.mml
SETTINGS = MathJax.Hub.config.menuSettings;
MML.mbase.Augment({
toMathML: function (space) {
var inferred = (this.inferred && this.parent.inferRow);
if (space == null) {space = ""}
var tag = this.type, attr = this.MathMLattributes();
var tag = this.type, attr = this.toMathMLattributes();
if (tag === "mspace") {return space + "<"+tag+attr+" />"}
var data = []; var SPACE = (this.isToken ? "" : space+(inferred ? "" : " "));
for (var i = 0, m = this.data.length; i < m; i++) {
@ -46,35 +47,61 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
return space + "<"+tag+attr+">\n"+data.join("\n")+"\n"+ space +"</"+tag+">";
},
MathMLattributes: function () {
toMathMLattributes: function () {
var attr = [], defaults = this.defaults;
var copy = this.copyAttributes,
skip = this.skipAttributes;
var copy = (this.attrNames||MML.copyAttributeNames), skip = MML.skipAttributes;
if (this.type === "math") {attr.push('xmlns="http://www.w3.org/1998/Math/MathML"')}
if (this.type === "mstyle") {defaults = MML.math.prototype.defaults}
for (var id in defaults) {if (!skip[id] && defaults.hasOwnProperty(id)) {
var force = (id === "open" || id === "close");
if (this[id] != null && (force || this[id] !== defaults[id])) {
var value = this[id]; delete this[id];
if (force || this.Get(id) !== value)
{attr.push(id+'="'+this.quoteHTML(value)+'"')}
this[id] = value;
}
}}
for (var i = 0, m = copy.length; i < m; i++) {
if (this[copy[i]] != null) {attr.push(copy[i]+'="'+this.quoteHTML(this[copy[i]])+'"')}
if (!this.attrNames) {
if (this.type === "mstyle") {defaults = MML.math.prototype.defaults}
for (var id in defaults) {if (!skip[id] && defaults.hasOwnProperty(id)) {
var force = (id === "open" || id === "close");
if (this[id] != null && (force || this[id] !== defaults[id])) {
var value = this[id]; delete this[id];
if (force || this.Get(id) !== value)
{attr.push(id+'="'+this.toMathMLattribute(value)+'"')}
this[id] = value;
}
}}
}
for (var i = 0, m = copy.length; i < m; i++) {
if (copy[i] === "class") continue; // this is handled separately below
value = (this.attr||{})[copy[i]]; if (value == null) {value = this[copy[i]]}
if (value != null) {attr.push(copy[i]+'="'+this.toMathMLquote(value)+'"')}
}
this.toMathMLclass(attr);
if (attr.length) {return " "+attr.join(" ")} else {return ""}
},
copyAttributes: [
"fontfamily","fontsize","fontweight","fontstyle",
"color","background",
"id","class","href","style"
],
skipAttributes: {texClass: 1, useHeight: 1, texprimestyle: 1},
toMathMLclass: function (attr) {
var CLASS = []; if (this["class"]) {CLASS.push(this["class"])}
if (this.isa(MML.TeXAtom) && SETTINGS.texHints) {
var TEXCLASS = ["ORD","OP","BIN","REL","OPEN","CLOSE","PUNCT","INNER","VCENTER"][this.texClass];
if (TEXCLASS) {CLASS.push("MJX-TeXAtom-"+TEXCLASS)}
}
if (this.mathvariant && this.toMathMLvariants[this.mathvariant])
{CLASS.push("MJX"+this.mathvariant)}
if (this.arrow) {CLASS.push("MJX-arrow")}
if (this.variantForm) {CLASS.push("MJX-variant")}
if (CLASS.length) {attr.unshift('class="'+CLASS.join(" ")+'"')}
},
toMathMLattribute: function (value) {
if (typeof(value) === "string" &&
value.replace(/ /g,"").match(/^(([-+])?(\d+(\.\d*)?|\.\d+))mu$/)) {
// FIXME: should take scriptlevel into account
return ((1/18)*RegExp.$1).toFixed(3).replace(/\.?0+$/,"")+"em";
}
else if (this.toMathMLvariants[value]) {return this.toMathMLvariants[value]}
return this.toMathMLquote(value);
},
toMathMLvariants: {
"-tex-caligraphic": MML.VARIANT.SCRIPT,
"-tex-caligraphic-bold": MML.VARIANT.BOLDSCRIPT,
"-tex-oldstyle": MML.VARIANT.NORMAL,
"-tex-oldstyle-bold": MML.VARIANT.BOLD,
"-tex-mathit": MML.VARIANT.ITALIC
},
quoteHTML: function (string) {
toMathMLquote: function (string) {
string = String(string).split("");
for (var i = 0, m = string.length; i < m; i++) {
var n = string[i].charCodeAt(0);
@ -94,7 +121,7 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
var tag = this.type;
if (this.data[this.sup] == null) {tag = "msub"}
if (this.data[this.sub] == null) {tag = "msup"}
var attr = this.MathMLattributes();
var attr = this.toMathMLattributes();
delete this.data[0].inferred;
var data = [];
for (var i = 0, m = this.data.length; i < m; i++)
@ -108,7 +135,7 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
var tag = this.type;
if (this.data[this.under] == null) {tag = "mover"}
if (this.data[this.over] == null) {tag = "munder"}
var attr = this.MathMLattributes();
var attr = this.toMathMLattributes();
delete this.data[0].inferred;
var data = [];
for (var i = 0, m = this.data.length; i < m; i++)
@ -120,12 +147,14 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
MML.TeXAtom.Augment({
toMathML: function (space) {
// FIXME: Handle spacing using mpadded?
return space+"<mrow>\n"+this.data[0].toMathML(space+" ")+"\n"+space+"</mrow>";
var attr = this.toMathMLattributes();
if (!attr && this.data[0].data.length === 1) {return space.substr(2) + this.data[0].toMathML(space)}
return space+"<mrow"+attr+">\n" + this.data[0].toMathML(space+" ")+"\n"+space+"</mrow>";
}
});
MML.chars.Augment({
toMathML: function (space) {return (space||"") + this.quoteHTML(this.toString())}
toMathML: function (space) {return (space||"") + this.toMathMLquote(this.toString())}
});
MML.entity.Augment({

View File

@ -1,6 +1,6 @@
/*************************************************************
*
* MathJax/extension/v1.0-warning.js
* MathJax/extensions/v1.0-warning.js
*
* This extension file is loaded when no jax are configured
* as a backward-compatible measure to help people convert to the
@ -8,7 +8,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011 Design Science, Inc.
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,12 +24,12 @@
*/
(function (HUB,HTML) {
var VERSION = "1.1";
var VERSION = "2.0";
var CONFIG = {
style: {
position:"fixed", bottom:"4em", left:"3em", width:"40em",
border: "3px solid #880000", "background-color": "#E0E0E0",
border: "3px solid #880000", "background-color": "#E0E0E0", color: "black",
padding: "1em", "font-size":"small", "white-space":"normal",
"border-radius": ".75em", // Opera 10.5 and IE9

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
modules/MathJax/images/CloseX-31.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
modules/MathJax/images/MenuArrow-15.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

View File

@ -8,7 +8,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009-2011 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ MathJax.ElementJax.mml = MathJax.ElementJax({
mimeType: "jax/mml"
},{
id: "mml",
version: "1.1.1",
version: "2.0",
directory: MathJax.ElementJax.directory + "/mml",
extensionDir: MathJax.ElementJax.extensionDir + "/mml",
optableDir: MathJax.ElementJax.directory + "/mml/optable"
@ -37,9 +37,15 @@ MathJax.ElementJax.mml.Augment({
Init: function () {
if (arguments.length === 1 && arguments[0].type === "math") {this.root = arguments[0]}
else {this.root = MathJax.ElementJax.mml.math.apply(this,arguments)}
if (this.root.mode) {
if (!this.root.display && this.root.mode === "display") {this.root.display = "block"}
delete this.root.mode;
if (this.root.attr && this.root.attr.mode) {
if (!this.root.display && this.root.attr.mode === "display") {
this.root.display = "block";
this.root.attrNames.push("display");
}
delete this.root.attr.mode;
for (var i = 0, m = this.root.attrNames.length; i < m; i++) {
if (this.root.attrNames[i] === "mode") {this.root.attrNames.splice(i,1); break}
}
}
}
},{
@ -202,24 +208,38 @@ MathJax.ElementJax.mml.Augment({
VCENTER: 8,
NONE: -1
},
PLANE1: String.fromCharCode(0xD835)
TEXCLASSNAMES: ["ORD", "OP", "BIN", "REL", "OPEN", "CLOSE", "PUNCT", "INNER", "VCENTER"],
copyAttributes: {
fontfamily:true, fontsize:true, fontweight:true, fontstyle:true,
color:true, background:true,
id:true, "class":true, href:true, style:true
},
skipAttributes: {texClass: true, useHeight: true, texprimestyle: true},
copyAttributeNames: [
"fontfamily", "fontsize", "fontweight", "fontstyle",
"color", "background",
"id", "class", "href", "style"
]
});
(function (MML) {
var FALSE = false; var TRUE = true;
MML.mbase = MathJax.Object.Subclass({
type: "base", isToken: FALSE,
type: "base", isToken: false,
defaults: {
mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT
},
noInherit: {},
noInheritAttribute: {
texClass: true
},
linebreakContainer: false,
Init: function () {
this.data = [];
if (this.inferRow && !(arguments.length === 1 && arguments[0].inferred))
{this.Append(MML.mrow().With({inferred: TRUE}))}
{this.Append(MML.mrow().With({inferred: true}))}
this.Append.apply(this,arguments);
},
With: function (def) {
@ -249,7 +269,8 @@ MathJax.ElementJax.mml.Augment({
return parent;
},
Get: function (name,nodefault) {
if (typeof(this[name]) !== "undefined") {return this[name]}
if (this[name] != null) {return this[name]}
if (this.attr && this.attr[name] != null) {return this.attr[name]}
// FIXME: should cache these values and get from cache
// (clear cache when appended to a new object?)
var parent = this.Parent();
@ -257,9 +278,10 @@ MathJax.ElementJax.mml.Augment({
{return (parent["adjustChild_"+name])(parent.childPosition(this))}
var obj = this.inherit; var root = obj;
while (obj) {
if (typeof(obj[name]) !== "undefined") {
var value = obj[name]; if (value == null && obj.attr) {value = obj.attr[name]}
if (value != null && !obj.noInheritAttribute[name]) {
var noInherit = obj.noInherit[this.type];
if (!(noInherit && noInherit[name])) {return obj[name]}
if (!(noInherit && noInherit[name])) {return value}
}
root = obj; obj = obj.inherit;
}
@ -339,21 +361,25 @@ MathJax.ElementJax.mml.Augment({
[ 1,-1, 2, 3, 1, 0, 1, 1] // INNER
],
autoDefault: function (name) {return ""},
isSpacelike: function () {return FALSE},
isEmbellished: function () {return FALSE},
isSpacelike: function () {return false},
isEmbellished: function () {return false},
Core: function () {return this},
CoreMO: function () {return this},
lineBreak: function () {
if (this.isEmbellished()) {return this.CoreMO().lineBreak()} else {return "none"}
hasNewline: function () {
if (this.isEmbellished()) {return this.CoreMO().hasNewline()}
if (this.isToken || this.linebreakContainer) {return false}
for (var i = 0, m = this.data.length; i < m; i++) {
if (this.data[i] && this.data[i].hasNewline()) {return true}
}
return false;
},
array: function () {if (this.inferred) {return this.data} else {return [this]}},
toString: function () {return this.type+"("+this.data.join(",")+")"}
},{
childrenSpacelike: function () {
for (var i = 0; i < this.data.length; i++) {
if (!this.data[i].isSpacelike()) {return FALSE}
}
return TRUE;
for (var i = 0, m = this.data.length; i < m; i++)
{if (!this.data[i].isSpacelike()) {return false}}
return true;
},
childEmbellished: function () {
return (this.data[0] && this.data[0].isEmbellished());
@ -387,7 +413,7 @@ MathJax.ElementJax.mml.Augment({
});
MML.mi = MML.mbase.Subclass({
type: "mi", isToken: TRUE,
type: "mi", isToken: true,
texClass: MML.TEXCLASS.ORD,
defaults: {
mathvariant: MML.AUTO,
@ -398,7 +424,8 @@ MathJax.ElementJax.mml.Augment({
autoDefault: function (name) {
if (name === "mathvariant") {
var mi = (this.data[0]||"").toString();
return (mi.length === 1 || (mi.length === 2 && mi.charCodeAt(0) === this.PLANE1) ?
return (mi.length === 1 ||
(mi.length === 2 && mi.charCodeAt(0) >= 0xD800 && mi.charCodeAt(0) < 0xDC00) ?
MML.VARIANT.ITALIC : MML.VARIANT.NORMAL);
}
return "";
@ -406,7 +433,7 @@ MathJax.ElementJax.mml.Augment({
});
MML.mn = MML.mbase.Subclass({
type: "mn", isToken: TRUE,
type: "mn", isToken: true,
texClass: MML.TEXCLASS.ORD,
defaults: {
mathvariant: MML.INHERIT,
@ -417,7 +444,7 @@ MathJax.ElementJax.mml.Augment({
});
MML.mo = MML.mbase.Subclass({
type: "mo", isToken: TRUE,
type: "mo", isToken: true,
defaults: {
mathvariant: MML.INHERIT,
mathsize: MML.INHERIT,
@ -450,17 +477,17 @@ MathJax.ElementJax.mml.Augment({
},
defaultDef: {
form: MML.FORM.INFIX,
fence: FALSE,
separator: FALSE,
fence: false,
separator: false,
lspace: MML.LENGTH.THICKMATHSPACE,
rspace: MML.LENGTH.THICKMATHSPACE,
stretchy: FALSE,
symmetric: TRUE,
stretchy: false,
symmetric: true,
maxsize: MML.SIZE.INFINITY,
minsize: '0em', //'1em',
largeop: FALSE,
movablelimits: FALSE,
accent: FALSE,
largeop: false,
movablelimits: false,
accent: false,
linebreak: MML.LINEBREAK.AUTO,
lineleading: "1ex",
linebreakstyle: "before",
@ -499,7 +526,7 @@ MathJax.ElementJax.mml.Augment({
},
CheckRange: function (mo) {
var n = mo.charCodeAt(0);
if (mo.charAt(0) === MML.PLANE1) {n = mo.charCodeAt(1) + 0x1D400 - 0xDC00}
if (n >= 0xD800 && n < 0xDC00) {n = (((n-0xD800)<<10)+(mo.charCodeAt(1)-0xDC00))+0x10000}
for (var i = 0, m = this.RANGES.length; i < m && this.RANGES[i][0] <= n; i++) {
if (n <= this.RANGES[i][1]) {
if (this.RANGES[i][3]) {
@ -507,7 +534,7 @@ MathJax.ElementJax.mml.Augment({
this.RANGES[i][3] = null;
MathJax.Hub.RestartAfter(MathJax.Ajax.Require(file));
}
var data = (["ORD","OP","BIN","REL","OPEN","CLOSE","PUNCT","INNER"])[this.RANGES[i][2]];
var data = MML.TEXCLASSNAMES[this.RANGES[i][2]];
data = this.OPTABLE.infix[mo] = MML.mo.OPTYPES[data === "BIN" ? "BIN3" : data];
return this.makeDef(data);
}
@ -520,6 +547,9 @@ MathJax.ElementJax.mml.Augment({
var def = MathJax.Hub.Insert({},data[3]);
def.lspace = this.SPACE[data[0]]; def.rspace = this.SPACE[data[1]];
def.texClass = data[2];
if (def.texClass === MML.TEXCLASS.REL &&
(this.movablelimits || this.data.join("").match(/^[a-z]+$/i)))
{def.texClass = MML.TEXCLASS.OP} // mark named operators as OP
return def;
},
getForm: function () {
@ -532,20 +562,12 @@ MathJax.ElementJax.mml.Augment({
}
return MML.FORM.INFIX;
},
isEmbellished: function () {return TRUE},
lineBreak: function () {
var values = this.getValues("linebreak","linebreakstyle");
if (values.linebreak === MML.LINEBREAK.NEWLINE) {
if (values.linebreakstyle === MML.LINEBREAKSTYLE.INFIXLINEBREAKSTYLE)
{values.linebreakstyle = this.Get("infixlinebreakstyle")}
return values.linebreakstyle;
}
return "none";
},
isEmbellished: function () {return true},
hasNewline: function () {return (this.Get("linebreak") === MML.LINEBREAK.NEWLINE)},
setTeXclass: function (prev) {
this.getValues("lspace","rspace"); // sets useMMLspacing
if (this.useMMLspacing) {this.texClass = MML.TEXCLASS.NONE; return this}
this.texClass = this.Get("texClass");
this.texClass = this.Get("texClass"); if (this.texClass === MML.TEXCLASS.NONE) {return prev}
if (prev) {this.prevClass = prev.texClass || MML.TEXCLASS.ORD; this.prevLevel = prev.Get("scriptlevel")}
else {this.prevClass = MML.TEXCLASS.NONE}
if (this.texClass === MML.TEXCLASS.BIN &&
@ -567,8 +589,8 @@ MathJax.ElementJax.mml.Augment({
});
MML.mtext = MML.mbase.Subclass({
type: "mtext", isToken: TRUE,
isSpacelike: function () {return TRUE},
type: "mtext", isToken: true,
isSpacelike: function () {return true},
texClass: MML.TEXCLASS.ORD,
defaults: {
mathvariant: MML.INHERIT,
@ -579,8 +601,8 @@ MathJax.ElementJax.mml.Augment({
});
MML.mspace = MML.mbase.Subclass({
type: "mspace", isToken: TRUE,
isSpacelike: function () {return TRUE},
type: "mspace", isToken: true,
isSpacelike: function () {return true},
defaults: {
mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT,
@ -589,14 +611,11 @@ MathJax.ElementJax.mml.Augment({
depth: "0ex",
linebreak: MML.LINEBREAK.AUTO
},
lineBreak: function () {
return (this.Get("linebreak") === MML.LINEBREAK.NEWLINE ?
MML.LINEBREAKSTYLE.AFTER : "none");
}
hasNewline: function () {return (this.Get("linebreak") === MML.LINEBREAK.NEWLINE)}
});
MML.ms = MML.mbase.Subclass({
type: "ms", isToken: TRUE,
type: "ms", isToken: true,
texClass: MML.TEXCLASS.ORD,
defaults: {
mathvariant: MML.INHERIT,
@ -609,7 +628,7 @@ MathJax.ElementJax.mml.Augment({
});
MML.mglyph = MML.mbase.Subclass({
type: "mglyph", isToken: TRUE,
type: "mglyph", isToken: true,
texClass: MML.TEXCLASS.ORD,
defaults: {
mathbackground: MML.INHERIT,
@ -625,15 +644,15 @@ MathJax.ElementJax.mml.Augment({
MML.mrow = MML.mbase.Subclass({
type: "mrow",
isSpacelike: MML.mbase.childrenSpacelike,
inferred: FALSE,
inferred: false,
isEmbellished: function () {
var isEmbellished = FALSE;
var isEmbellished = false;
for (var i = 0, m = this.data.length; i < m; i++) {
if (this.data[i] == null) continue;
if (this.data[i].isEmbellished()) {
if (isEmbellished) {return FALSE}
isEmbellished = TRUE; this.core = i;
} else if (!this.data[i].isSpacelike()) {return FALSE}
if (isEmbellished) {return false}
isEmbellished = true; this.core = i;
} else if (!this.data[i].isSpacelike()) {return false}
}
return isEmbellished;
},
@ -675,6 +694,7 @@ MathJax.ElementJax.mml.Augment({
MML.mfrac = MML.mbase.Subclass({
type: "mfrac", num: 0, den: 1,
linebreakContainer: true,
texClass: MML.TEXCLASS.INNER,
isEmbellished: MML.mbase.childEmbellished,
Core: MML.mbase.childCore,
@ -685,9 +705,9 @@ MathJax.ElementJax.mml.Augment({
linethickness: MML.LINETHICKNESS.MEDIUM,
numalign: MML.ALIGN.CENTER,
denomalign: MML.ALIGN.CENTER,
bevelled: FALSE
bevelled: false
},
adjustChild_displaystyle: function (n) {return FALSE},
adjustChild_displaystyle: function (n) {return false},
adjustChild_scriptlevel: function (n) {
var level = this.Get("scriptlevel");
if (!this.Get("displaystyle") || level > 0) {level++}
@ -702,17 +722,19 @@ MathJax.ElementJax.mml.Augment({
MML.msqrt = MML.mbase.Subclass({
type: "msqrt",
inferRow: TRUE,
inferRow: true,
linebreakContainer: true,
texClass: MML.TEXCLASS.ORD,
setTeXclass: MML.mbase.setSeparateTeXclasses,
adjustChild_texprimestyle: function (n) {return TRUE}
adjustChild_texprimestyle: function (n) {return true}
});
MML.mroot = MML.mbase.Subclass({
type: "mroot",
linebreakContainer: true,
texClass: MML.TEXCLASS.ORD,
adjustChild_displaystyle: function (n) {
if (n === 1) {return FALSE}
if (n === 1) {return false}
return this.Get("displaystyle");
},
adjustChild_scriptlevel: function (n) {
@ -721,7 +743,7 @@ MathJax.ElementJax.mml.Augment({
return level;
},
adjustChild_texprimestyle: function (n) {
if (n === 0) {return TRUE};
if (n === 0) {return true};
return this.Get("texprimestyle");
},
setTeXclass: MML.mbase.setSeparateTeXclasses
@ -733,7 +755,7 @@ MathJax.ElementJax.mml.Augment({
isEmbellished: MML.mbase.childEmbellished,
Core: MML.mbase.childCore,
CoreMO: MML.mbase.childCoreMO,
inferRow: TRUE,
inferRow: true,
defaults: {
scriptlevel: MML.INHERIT,
displaystyle: MML.INHERIT,
@ -756,23 +778,24 @@ MathJax.ElementJax.mml.Augment({
}
return level;
},
inheritFromMe: TRUE,
inheritFromMe: true,
noInherit: {
mpadded: {width: TRUE, height: TRUE, depth: TRUE, lspace: TRUE, voffset: TRUE},
mtable: {width: TRUE, height: TRUE, depth: TRUE, align: TRUE}
mpadded: {width: true, height: true, depth: true, lspace: true, voffset: true},
mtable: {width: true, height: true, depth: true, align: true}
},
setTeXclass: MML.mbase.setChildTeXclass
});
MML.merror = MML.mbase.Subclass({
type: "merror",
inferRow: TRUE,
inferRow: true,
linebreakContainer: true,
texClass: MML.TEXCLASS.ORD
});
MML.mpadded = MML.mbase.Subclass({
type: "mpadded",
inferRow: TRUE,
inferRow: true,
isSpacelike: MML.mbase.childrenSpacelike,
isEmbellished: MML.mbase.childEmbellished,
Core: MML.mbase.childCore,
@ -792,7 +815,7 @@ MathJax.ElementJax.mml.Augment({
MML.mphantom = MML.mbase.Subclass({
type: "mphantom",
texClass: MML.TEXCLASS.ORD,
inferRow: TRUE,
inferRow: true,
isSpacelike: MML.mbase.childrenSpacelike,
isEmbellished: MML.mbase.childEmbellished,
Core: MML.mbase.childCore,
@ -851,7 +874,8 @@ MathJax.ElementJax.mml.Augment({
MML.menclose = MML.mbase.Subclass({
type: "menclose",
inferRow: TRUE,
inferRow: true,
linebreakContainer: true,
defaults: {
mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT,
@ -863,6 +887,7 @@ MathJax.ElementJax.mml.Augment({
MML.msubsup = MML.mbase.Subclass({
type: "msubsup", base: 0, sub: 1, sup: 2,
linebreakContainer: true,
isEmbellished: MML.mbase.childEmbellished,
Core: MML.mbase.childCore,
CoreMO: MML.mbase.childCoreMO,
@ -879,7 +904,7 @@ MathJax.ElementJax.mml.Augment({
return 0;
},
adjustChild_displaystyle: function (n) {
if (n > 0) {return FALSE}
if (n > 0) {return false}
return this.Get("displaystyle");
},
adjustChild_scriptlevel: function (n) {
@ -888,7 +913,7 @@ MathJax.ElementJax.mml.Augment({
return level;
},
adjustChild_texprimestyle: function (n) {
if (n === this.sub) {return TRUE}
if (n === this.sub) {return true}
return this.Get("texprimestyle");
},
setTeXclass: MML.mbase.setBaseTeXclasses
@ -899,7 +924,7 @@ MathJax.ElementJax.mml.Augment({
MML.mmultiscripts = MML.msubsup.Subclass({
type: "mmultiscripts",
adjustChild_texprimestyle: function (n) {
if (n % 2 === 1) {return TRUE}
if (n % 2 === 1) {return true}
return this.Get("texprimestyle");
}
});
@ -910,6 +935,7 @@ MathJax.ElementJax.mml.Augment({
type: "munderover",
base: 0, under: 1, over: 2, sub: 1, sup: 2,
ACCENTS: ["", "accentunder", "accent"],
linebreakContainer: true,
isEmbellished: MML.mbase.childEmbellished,
Core: MML.mbase.childCore,
CoreMO: MML.mbase.childCoreMO,
@ -928,20 +954,22 @@ MathJax.ElementJax.mml.Augment({
{return (this.isEmbellished() ? this.CoreMO().Get(name) : MML.TEXCLASS.ORD)}
if (name === "accent" && this.data[this.over]) {return this.data[this.over].CoreMO().Get("accent")}
if (name === "accentunder" && this.data[this.under]) {return this.data[this.under].CoreMO().Get("accent")}
return FALSE;
return false;
},
adjustChild_displaystyle: function (n) {
if (n > 0) {return FALSE}
if (n > 0) {return false}
return this.Get("displaystyle");
},
adjustChild_scriptlevel: function (n) {
var level = this.Get("scriptlevel");
if (n == this.under && !this.Get("accentunder")) {level++}
if (n == this.over && !this.Get("accent")) {level++}
var force = (this.data[this.base] && !this.Get("displaystyle") &&
this.data[this.base].CoreMO().Get("movablelimits"));
if (n == this.under && (force || !this.Get("accentunder"))) {level++}
if (n == this.over && (force || !this.Get("accent"))) {level++}
return level;
},
adjustChild_texprimestyle: function (n) {
if (n === this.base && this.data[this.over]) {return TRUE}
if (n === this.base && this.data[this.over]) {return true}
return this.Get("texprimestyle");
},
setTeXclass: MML.mbase.setBaseTeXclasses
@ -962,7 +990,7 @@ MathJax.ElementJax.mml.Augment({
rowalign: MML.ALIGN.BASELINE,
columnalign: MML.ALIGN.CENTER,
groupalign: "{left}",
alignmentscope: TRUE,
alignmentscope: true,
columnwidth: MML.WIDTH.AUTO,
width: MML.WIDTH.AUTO,
rowspacing: "1ex",
@ -971,24 +999,25 @@ MathJax.ElementJax.mml.Augment({
columnlines: MML.LINES.NONE,
frame: MML.LINES.NONE,
framespacing: "0.4em 0.5ex",
equalrows: FALSE,
equalcolumns: FALSE,
displaystyle: FALSE,
equalrows: false,
equalcolumns: false,
displaystyle: false,
side: MML.SIDE.RIGHT,
minlabelspacing: "0.8em",
texClass: MML.TEXCLASS.ORD,
useHeight: 1
},
inheritFromMe: TRUE,
inheritFromMe: true,
noInherit: {
mtable: {
align: TRUE, rowalign: TRUE, columnalign: TRUE, groupalign: TRUE,
alignmentscope: TRUE, columnwidth: TRUE, width: TRUE, rowspacing: TRUE,
columnspacing: TRUE, rowlines: TRUE, columnlines: TRUE, frame: TRUE,
framespacing: TRUE, equalrows: TRUE, equalcolumns: TRUE,
side: TRUE, minlabelspacing: TRUE, texClass: TRUE, useHeight: 1
align: true, rowalign: true, columnalign: true, groupalign: true,
alignmentscope: true, columnwidth: true, width: true, rowspacing: true,
columnspacing: true, rowlines: true, columnlines: true, frame: true,
framespacing: true, equalrows: true, equalcolumns: true,
side: true, minlabelspacing: true, texClass: true, useHeight: 1
}
},
linebreakContainer: true,
Append: function () {
for (var i = 0, m = arguments.length; i < m; i++) {
if (!((arguments[i] instanceof MML.mtr) ||
@ -1008,11 +1037,12 @@ MathJax.ElementJax.mml.Augment({
columnalign: MML.INHERIT,
groupalign: MML.INHERIT
},
inheritFromMe: TRUE,
inheritFromMe: true,
noInherit: {
mrow: {rowalign: TRUE, columnalign: TRUE, groupalign: TRUE},
mtable: {rowalign: TRUE, columnalign: TRUE, groupalign: TRUE}
mrow: {rowalign: true, columnalign: true, groupalign: true},
mtable: {rowalign: true, columnalign: true, groupalign: true}
},
linebreakContainer: true,
Append: function () {
for (var i = 0, m = arguments.length; i < m; i++) {
if (!(arguments[i] instanceof MML.mtd)) {arguments[i] = MML.mtd(arguments[i])}
@ -1024,7 +1054,8 @@ MathJax.ElementJax.mml.Augment({
MML.mtd = MML.mbase.Subclass({
type: "mtd",
inferRow: TRUE,
inferRow: true,
linebreakContainer: true,
isEmbellished: MML.mbase.childEmbellished,
Core: MML.mbase.childCore,
CoreMO: MML.mbase.childCoreMO,
@ -1042,16 +1073,16 @@ MathJax.ElementJax.mml.Augment({
MML.maligngroup = MML.mbase.Subclass({
type: "malign",
isSpacelike: function () {return TRUE},
isSpacelike: function () {return true},
defaults: {
mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT,
groupalign: MML.INHERIT
},
inheritFromMe: TRUE,
inheritFromMe: true,
noInherit: {
mrow: {groupalign: TRUE},
mtable: {groupalign: TRUE}
mrow: {groupalign: true},
mtable: {groupalign: true}
}
});
@ -1062,7 +1093,7 @@ MathJax.ElementJax.mml.Augment({
mathcolor: MML.INHERIT,
edge: MML.SIDE.LEFT
},
isSpacelike: function () {return TRUE}
isSpacelike: function () {return true}
});
MML.mlabeledtr = MML.mtr.Subclass({
@ -1097,7 +1128,8 @@ MathJax.ElementJax.mml.Augment({
setTeXclass: MML.mbase.setChildTeXclass
});
MML.annotation = MML.mbase.Subclass({
type: "annotation", isToken: TRUE,
type: "annotation", isToken: true,
linebreakContainer: true,
defaults: {
definitionURL: null,
encoding: null,
@ -1108,6 +1140,7 @@ MathJax.ElementJax.mml.Augment({
});
MML["annotation-xml"] = MML.mbase.Subclass({
type: "annotation-xml",
linebreakContainer: true,
defaults: {
definitionURL: null,
encoding: null,
@ -1143,13 +1176,16 @@ MathJax.ElementJax.mml.Augment({
indentalign: MML.INDENTALIGN.AUTO,
indentalignfirst: MML.INDENTALIGN.INDENTALIGN,
indentshiftfirst: MML.INDENTSHIFT.INDENTSHIFT,
indentalignlast: MML.INDENTALIGN.INDENTALIGN,
indentshiftlast: MML.INDENTSHIFT.INDENTSHIFT,
decimalseparator: ".",
texprimestyle: FALSE // is it in TeX's C' style?
texprimestyle: false // is it in TeX's C' style?
},
autoDefault: function (name) {
if (name === "displaystyle") {return this.Get("display") === "block"}
return "";
},
linebreakContainer: true,
setTeXclass: MML.mbase.setChildTeXclass
});
@ -1171,7 +1207,9 @@ MathJax.ElementJax.mml.Augment({
toString: function () {
var n = this.value();
if (n <= 0xFFFF) {return String.fromCharCode(n)}
return this.PLANE1 + String.fromCharCode(n-0x1D400+0xDC00);
n -= 0x10000;
return String.fromCharCode((n>>10)+0xD800)
+ String.fromCharCode((n&0x3FF)+0xDC00);
}
});
@ -1221,7 +1259,7 @@ MathJax.ElementJax.mml.Augment({
MML.TeXAtom = MML.mbase.Subclass({
type: "texatom",
inferRow: TRUE,
inferRow: true,
texClass: MML.TEXCLASS.ORD,
setTeXclass: function (prev) {
this.getPrevClass(prev);
@ -1247,13 +1285,15 @@ MathJax.ElementJax.mml.Augment({
BIN3: [3,3,TEXCLASS.BIN],
BIN4: [4,4,TEXCLASS.BIN],
BIN01: [0,1,TEXCLASS.BIN],
BIN5: [5,5,TEXCLASS.BIN],
TALLBIN: [4,4,TEXCLASS.BIN,{stretchy: true}],
BINOP: [4,4,TEXCLASS.BIN,{largeop: true, movablelimits: true}],
REL: [5,5,TEXCLASS.REL],
REL1: [1,1,TEXCLASS.REL,{stretchy: true}],
REL4: [4,4,TEXCLASS.REL],
WIDEREL: [5,5,TEXCLASS.REL,{stretchy: true}],
RELACCENT: [5,5,TEXCLASS.REL,{accent: true, stretchy: true}],
RELSTRETCH: [5,5,TEXCLASS.REL,{stretchy: true}],
RELACCENT: [5,5,TEXCLASS.REL,{accent: true}],
WIDEREL: [5,5,TEXCLASS.REL,{accent: true, stretchy: true}],
OPEN: [0,0,TEXCLASS.OPEN,{fence: true, stretchy: true, symmetric: true}],
CLOSE: [0,0,TEXCLASS.CLOSE,{fence: true, stretchy: true, symmetric: true}],
INNER: [0,0,TEXCLASS.INNER],
@ -1290,20 +1330,19 @@ MathJax.ElementJax.mml.Augment({
[0x2200,0x22FF,TEXCLASS.BIN,"MathOperators"],
[0x2300,0x23FF,TEXCLASS.ORD,"MiscTechnical"],
[0x2460,0x24FF,TEXCLASS.ORD],
[0x2500,0x259F,TEXCLASS.ORD],
[0x25A0,0x25FF,TEXCLASS.ORD,"GeometricShapes"],
[0x2700,0x27BF,TEXCLASS.ORD,"Dingbats"],
[0x27C0,0x27EF,TEXCLASS.ORD,"MiscMathSymbolsA"],
[0x27F0,0x27FF,TEXCLASS.REL,"SupplementalArrowsA"],
[0x2900,0x297F,TEXCLASS.REL,"SupplementalArrowsB"],
[0x2980,0x29FF,TEXCLASS.ORD,"MiscMathSymbolsB"],
[0x2A00,0x2AFF,TEXCLASS.BIN,"SuppMathOperators"],
[0x2B00,0x2BFF,TEXCLASS.ORD],
[0x2B00,0x2BFF,TEXCLASS.ORD,"MiscSymbolsAndArrows"],
[0x1D400,0x1D7FF,TEXCLASS.ORD]
],
OPTABLE: {
prefix: {
'\u2111': MO.ORD11, // black-letter capital i
'\u2113': MO.ORD11, // script small l
'\u211C': MO.ORD11, // black-letter capital r
'\u2200': MO.ORD21, // for all
'\u2202': MO.ORD21, // partial differential
'\u2203': MO.ORD21, // there exists
@ -1324,6 +1363,7 @@ MathJax.ElementJax.mml.Augment({
'\u2308': MO.OPEN, // left ceiling
'\u230A': MO.OPEN, // left floor
'\u27E8': MO.OPEN, // mathematical left angle bracket
'\u27EE': MO.OPEN, // mathematical left flattened parenthesis
'\u2A00': MO.OP, // n-ary circled dot operator
'\u2A01': MO.OP, // n-ary circled plus operator
'\u2A02': MO.OP, // n-ary circled times operator
@ -1351,12 +1391,16 @@ MathJax.ElementJax.mml.Augment({
'\u266E': MO.ORD02, // music natural sign
'\u266F': MO.ORD02, // music sharp sign
'\u27E9': MO.CLOSE, // mathematical right angle bracket
'\u27EF': MO.CLOSE, // mathematical right flattened parenthesis
'\u02C6': MO.WIDEACCENT, // modifier letter circumflex accent
'\u02C7': MO.WIDEACCENT, // caron
'\u02C9': MO.WIDEACCENT, // modifier letter macron
'\u02CA': MO.ACCENT, // modifier letter acute accent
'\u02CB': MO.ACCENT, // modifier letter grave accent
'\u02D8': MO.ACCENT, // breve
'\u02D9': MO.ACCENT, // dot above
'\u02DC': MO.WIDEACCENT, // small tilde
'\u0302': MO.ACCENT, // combining circumflex accent
'\u0302': MO.WIDEACCENT, // combining circumflex accent
'\u00A8': MO.ACCENT, // diaeresis
'\u00AF': MO.WIDEACCENT, // macron
')': MO.CLOSE, // right parenthesis
@ -1369,38 +1413,39 @@ MathJax.ElementJax.mml.Augment({
'~': MO.WIDEACCENT // tilde
},
infix: {
'': MO.ORD, // empty <mo>
'%': [3,3,TEXCLASS.ORD], // percent sign
'\u2022': MO.BIN4, // bullet
'\u2026': MO.INNER, // horizontal ellipsis
'\u2044': MO.TALLBIN, // fraction slash
'\u2061': MO.ORD, // function application
'\u2062': MO.ORD, // invisible times
'\u2063': [0,0,TEXCLASS.ORD,{separator: true}], // invisible separator
'\u2063': [0,0,TEXCLASS.ORD,{linebreakstyle:"after", separator: true}], // invisible separator
'\u2064': MO.ORD, // invisible plus
'\u2190': MO.RELACCENT, // leftwards arrow
'\u2191': MO.WIDEREL, // upwards arrow
'\u2192': MO.RELACCENT, // rightwards arrow
'\u2193': MO.WIDEREL, // downwards arrow
'\u2194': MO.RELACCENT, // left right arrow
'\u2195': MO.WIDEREL, // up down arrow
'\u2196': MO.WIDEREL, // north west arrow
'\u2197': MO.WIDEREL, // north east arrow
'\u2198': MO.WIDEREL, // south east arrow
'\u2199': MO.WIDEREL, // south west arrow
'\u2190': MO.WIDEREL, // leftwards arrow
'\u2191': MO.RELSTRETCH, // upwards arrow
'\u2192': MO.WIDEREL, // rightwards arrow
'\u2193': MO.RELSTRETCH, // downwards arrow
'\u2194': MO.WIDEREL, // left right arrow
'\u2195': MO.RELSTRETCH, // up down arrow
'\u2196': MO.RELSTRETCH, // north west arrow
'\u2197': MO.RELSTRETCH, // north east arrow
'\u2198': MO.RELSTRETCH, // south east arrow
'\u2199': MO.RELSTRETCH, // south west arrow
'\u21A6': MO.WIDEREL, // rightwards arrow from bar
'\u21A9': MO.WIDEREL, // leftwards arrow with hook
'\u21AA': MO.WIDEREL, // rightwards arrow with hook
'\u21BC': MO.RELACCENT, // leftwards harpoon with barb upwards
'\u21BC': MO.WIDEREL, // leftwards harpoon with barb upwards
'\u21BD': MO.WIDEREL, // leftwards harpoon with barb downwards
'\u21C0': MO.RELACCENT, // rightwards harpoon with barb upwards
'\u21C0': MO.WIDEREL, // rightwards harpoon with barb upwards
'\u21C1': MO.WIDEREL, // rightwards harpoon with barb downwards
'\u21CC': MO.WIDEREL, // rightwards harpoon over leftwards harpoon
'\u21D0': MO.WIDEREL, // leftwards double arrow
'\u21D1': MO.WIDEREL, // upwards double arrow
'\u21D1': MO.RELSTRETCH, // upwards double arrow
'\u21D2': MO.WIDEREL, // rightwards double arrow
'\u21D3': MO.WIDEREL, // downwards double arrow
'\u21D3': MO.RELSTRETCH, // downwards double arrow
'\u21D4': MO.WIDEREL, // left right double arrow
'\u21D5': MO.WIDEREL, // up down double arrow
'\u21D5': MO.RELSTRETCH, // up down double arrow
'\u2208': MO.REL, // element of
'\u2209': MO.REL, // not an element of
'\u220B': MO.REL, // contains as member
@ -1459,20 +1504,20 @@ MathJax.ElementJax.mml.Augment({
'\u22EE': MO.ORD55, // vertical ellipsis
'\u22EF': MO.INNER, // midline horizontal ellipsis
'\u22F1': [5,5,TEXCLASS.INNER], // down right diagonal ellipsis
'\u2500': [0,0,TEXCLASS.ORD,{stretchy: true}], // box drawings light horizontal
'\u25B3': MO.BIN4, // white up-pointing triangle
'\u25B5': MO.BIN4, // white up-pointing small triangle
'\u25B9': MO.BIN4, // white right-pointing small triangle
'\u25BD': MO.BIN4, // white down-pointing triangle
'\u25BF': MO.BIN4, // white down-pointing small triangle
'\u25C3': MO.BIN4, // white left-pointing small triangle
'\u2758': [4,4,TEXCLASS.REL,{fence: true, stretchy: true, symmetric: true}], // light vertical bar
'\u27F5': MO.REL1, // long leftwards arrow
'\u27F6': MO.REL1, // long rightwards arrow
'\u27F7': MO.REL1, // long left right arrow
'\u27F8': MO.REL1, // long leftwards double arrow
'\u27F9': MO.REL1, // long rightwards double arrow
'\u27FA': MO.REL1, // long left right double arrow
'\u2758': MO.REL, // light vertical bar
'\u27F5': MO.WIDEREL, // long leftwards arrow
'\u27F6': MO.WIDEREL, // long rightwards arrow
'\u27F7': MO.WIDEREL, // long left right arrow
'\u27F8': MO.WIDEREL, // long leftwards double arrow
'\u27F9': MO.WIDEREL, // long rightwards double arrow
'\u27FA': MO.WIDEREL, // long left right double arrow
'\u27FC': MO.WIDEREL, // long rightwards arrow from bar
'\u2A2F': MO.BIN4, // vector or cross product
'\u2A3F': MO.BIN4, // amalgamation or coproduct
'\u2AAF': MO.REL, // precedes above single-line equals sign
@ -1483,26 +1528,24 @@ MathJax.ElementJax.mml.Augment({
'\u00F7': MO.BIN4, // division sign
'*': MO.BIN3, // asterisk
'+': MO.BIN4, // plus sign
',': [0,3,TEXCLASS.PUNCT,{separator: true}], // comma
',': [0,3,TEXCLASS.PUNCT,{linebreakstyle:"after", separator: true}], // comma
'-': MO.BIN4, // hyphen-minus
'.': [3,3,TEXCLASS.ORD], // full stop
'/': MO.ORD11, // solidus
':': [1,2,TEXCLASS.REL], // colon
';': [0,3,TEXCLASS.PUNCT,{separator: true}], // semicolon
';': [0,3,TEXCLASS.PUNCT,{linebreakstyle:"after", separator: true}], // semicolon
'<': MO.REL, // less-than sign
'=': MO.REL, // equals sign
'>': MO.REL, // greater-than sign
'?': [1,1,TEXCLASS.CLOSE], // question mark
'\\': MO.ORD, // reverse solidus
'^': MO.ORD11, // circumflex accent
'_': MO.ORD11, // low line
'|': [2,2,TEXCLASS.ORD,{fence: true, stretchy: true, symmetric: true}], // vertical line
'#': MO.ORD, // #
'$': MO.ORD, // $
'\u002E': [0,3,TEXCLASS.PUNCT,{separator: true}], // \ldotp
'\u02B9': MO.ORD, // prime
'\u02C9': MO.ACCENT, // \bar
'\u02CA': MO.ACCENT, // \acute
'\u02CB': MO.ACCENT, // \grave
'\u0300': MO.ACCENT, // \grave
'\u0301': MO.ACCENT, // \acute
'\u0303': MO.WIDEACCENT, // \tilde
@ -1518,7 +1561,10 @@ MathJax.ElementJax.mml.Augment({
'\u2020': MO.BIN3, // \dagger
'\u2021': MO.BIN3, // \ddagger
'\u20D7': MO.ACCENT, // \vec
'\u2111': MO.ORD, // \Im
'\u2113': MO.ORD, // \ell
'\u2118': MO.ORD, // \wp
'\u211C': MO.ORD, // \Re
'\u2205': MO.ORD, // \emptyset
'\u221E': MO.ORD, // \infty
'\u2305': MO.BIN3, // barwedge
@ -1531,14 +1577,12 @@ MathJax.ElementJax.mml.Augment({
'\u23AF': [0,0,TEXCLASS.ORD,{stretchy: true}], // \underline
'\u23B0': MO.OPEN, // \lmoustache
'\u23B1': MO.CLOSE, // \rmoustache
'\u2500': MO.ORD, // horizontal line
'\u25EF': MO.BIN3, // \bigcirc
'\u2660': MO.ORD, // \spadesuit
'\u2661': MO.ORD, // \heartsuit
'\u2662': MO.ORD, // \diamondsuit
'\u2663': MO.ORD, // \clubsuit
'\u27EE': MO.OPEN, // \lgroup
'\u27EF': MO.CLOSE, // \rgroup
'\u27FC': MO.REL4, // \longmapsto
'\u3008': MO.OPEN, // langle
'\u3009': MO.CLOSE, // rangle
'\uFE37': MO.WIDEACCENT, // horizontal brace down
@ -1549,6 +1593,13 @@ MathJax.ElementJax.mml.Augment({
OPTYPES: MO
});
//
// These are not in the W3C table, but FF works this way,
// and it makes sense, so add it here
//
MML.mo.prototype.OPTABLE.infix["^"] = MO.WIDEREL;
MML.mo.prototype.OPTABLE.infix["_"] = MO.WIDEREL;
})(MathJax.ElementJax.mml);
MathJax.ElementJax.mml.loadComplete("jax.js");

View File

@ -25,56 +25,56 @@
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
infix: {
'\u219A': MO.REL, // leftwards arrow with stroke
'\u219B': MO.REL, // rightwards arrow with stroke
'\u219A': MO.RELACCENT, // leftwards arrow with stroke
'\u219B': MO.RELACCENT, // rightwards arrow with stroke
'\u219C': MO.WIDEREL, // leftwards wave arrow
'\u219D': MO.WIDEREL, // rightwards wave arrow
'\u219E': MO.WIDEREL, // leftwards two headed arrow
'\u219F': MO.WIDEREL, // upwards two headed arrow
'\u21A0': MO.WIDEREL, // rightwards two headed arrow
'\u21A1': MO.WIDEREL, // downwards two headed arrow
'\u21A1': MO.RELSTRETCH, // downwards two headed arrow
'\u21A2': MO.WIDEREL, // leftwards arrow with tail
'\u21A3': MO.WIDEREL, // rightwards arrow with tail
'\u21A4': MO.WIDEREL, // leftwards arrow from bar
'\u21A5': MO.WIDEREL, // upwards arrow from bar
'\u21A7': MO.WIDEREL, // downwards arrow from bar
'\u21A8': MO.WIDEREL, // up down arrow with base
'\u21A5': MO.RELSTRETCH, // upwards arrow from bar
'\u21A7': MO.RELSTRETCH, // downwards arrow from bar
'\u21A8': MO.RELSTRETCH, // up down arrow with base
'\u21AB': MO.WIDEREL, // leftwards arrow with loop
'\u21AC': MO.WIDEREL, // rightwards arrow with loop
'\u21AD': MO.WIDEREL, // left right wave arrow
'\u21AE': MO.REL, // left right arrow with stroke
'\u21AF': MO.WIDEREL, // downwards zigzag arrow
'\u21B0': MO.WIDEREL, // upwards arrow with tip leftwards
'\u21B1': MO.WIDEREL, // upwards arrow with tip rightwards
'\u21B2': MO.WIDEREL, // downwards arrow with tip leftwards
'\u21B3': MO.WIDEREL, // downwards arrow with tip rightwards
'\u21B4': MO.WIDEREL, // rightwards arrow with corner downwards
'\u21B5': MO.WIDEREL, // downwards arrow with corner leftwards
'\u21B6': MO.REL, // anticlockwise top semicircle arrow
'\u21B7': MO.REL, // clockwise top semicircle arrow
'\u21AE': MO.RELACCENT, // left right arrow with stroke
'\u21AF': MO.RELSTRETCH, // downwards zigzag arrow
'\u21B0': MO.RELSTRETCH, // upwards arrow with tip leftwards
'\u21B1': MO.RELSTRETCH, // upwards arrow with tip rightwards
'\u21B2': MO.RELSTRETCH, // downwards arrow with tip leftwards
'\u21B3': MO.RELSTRETCH, // downwards arrow with tip rightwards
'\u21B4': MO.RELSTRETCH, // rightwards arrow with corner downwards
'\u21B5': MO.RELSTRETCH, // downwards arrow with corner leftwards
'\u21B6': MO.RELACCENT, // anticlockwise top semicircle arrow
'\u21B7': MO.RELACCENT, // clockwise top semicircle arrow
'\u21B8': MO.REL, // north west arrow to long bar
'\u21B9': MO.WIDEREL, // leftwards arrow to bar over rightwards arrow to bar
'\u21BA': MO.REL, // anticlockwise open circle arrow
'\u21BB': MO.REL, // clockwise open circle arrow
'\u21BE': MO.WIDEREL, // upwards harpoon with barb rightwards
'\u21BF': MO.WIDEREL, // upwards harpoon with barb leftwards
'\u21C2': MO.WIDEREL, // downwards harpoon with barb rightwards
'\u21C3': MO.WIDEREL, // downwards harpoon with barb leftwards
'\u21BE': MO.RELSTRETCH, // upwards harpoon with barb rightwards
'\u21BF': MO.RELSTRETCH, // upwards harpoon with barb leftwards
'\u21C2': MO.RELSTRETCH, // downwards harpoon with barb rightwards
'\u21C3': MO.RELSTRETCH, // downwards harpoon with barb leftwards
'\u21C4': MO.WIDEREL, // rightwards arrow over leftwards arrow
'\u21C5': MO.WIDEREL, // upwards arrow leftwards of downwards arrow
'\u21C5': MO.RELSTRETCH, // upwards arrow leftwards of downwards arrow
'\u21C6': MO.WIDEREL, // leftwards arrow over rightwards arrow
'\u21C7': MO.WIDEREL, // leftwards paired arrows
'\u21C8': MO.WIDEREL, // upwards paired arrows
'\u21C8': MO.RELSTRETCH, // upwards paired arrows
'\u21C9': MO.WIDEREL, // rightwards paired arrows
'\u21CA': MO.WIDEREL, // downwards paired arrows
'\u21CA': MO.RELSTRETCH, // downwards paired arrows
'\u21CB': MO.WIDEREL, // leftwards harpoon over rightwards harpoon
'\u21CD': MO.REL, // leftwards double arrow with stroke
'\u21CE': MO.REL, // left right double arrow with stroke
'\u21CF': MO.REL, // rightwards double arrow with stroke
'\u21D6': MO.WIDEREL, // north west double arrow
'\u21D7': MO.WIDEREL, // north east double arrow
'\u21D8': MO.WIDEREL, // south east double arrow
'\u21D9': MO.WIDEREL, // south west double arrow
'\u21CD': MO.RELACCENT, // leftwards double arrow with stroke
'\u21CE': MO.RELACCENT, // left right double arrow with stroke
'\u21CF': MO.RELACCENT, // rightwards double arrow with stroke
'\u21D6': MO.RELSTRETCH, // north west double arrow
'\u21D7': MO.RELSTRETCH, // north east double arrow
'\u21D8': MO.RELSTRETCH, // south east double arrow
'\u21D9': MO.RELSTRETCH, // south west double arrow
'\u21DA': MO.WIDEREL, // leftwards triple arrow
'\u21DB': MO.WIDEREL, // rightwards triple arrow
'\u21DC': MO.WIDEREL, // leftwards squiggle arrow
@ -82,34 +82,34 @@
'\u21DE': MO.REL, // upwards arrow with double stroke
'\u21DF': MO.REL, // downwards arrow with double stroke
'\u21E0': MO.WIDEREL, // leftwards dashed arrow
'\u21E1': MO.WIDEREL, // upwards dashed arrow
'\u21E1': MO.RELSTRETCH, // upwards dashed arrow
'\u21E2': MO.WIDEREL, // rightwards dashed arrow
'\u21E3': MO.WIDEREL, // downwards dashed arrow
'\u21E3': MO.RELSTRETCH, // downwards dashed arrow
'\u21E4': MO.WIDEREL, // leftwards arrow to bar
'\u21E5': MO.WIDEREL, // rightwards arrow to bar
'\u21E6': MO.WIDEREL, // leftwards white arrow
'\u21E7': MO.WIDEREL, // upwards white arrow
'\u21E7': MO.RELSTRETCH, // upwards white arrow
'\u21E8': MO.WIDEREL, // rightwards white arrow
'\u21E9': MO.WIDEREL, // downwards white arrow
'\u21EA': MO.WIDEREL, // upwards white arrow from bar
'\u21EB': MO.WIDEREL, // upwards white arrow on pedestal
'\u21EC': MO.WIDEREL, // upwards white arrow on pedestal with horizontal bar
'\u21ED': MO.WIDEREL, // upwards white arrow on pedestal with vertical bar
'\u21EE': MO.WIDEREL, // upwards white double arrow
'\u21EF': MO.WIDEREL, // upwards white double arrow on pedestal
'\u21E9': MO.RELSTRETCH, // downwards white arrow
'\u21EA': MO.RELSTRETCH, // upwards white arrow from bar
'\u21EB': MO.RELSTRETCH, // upwards white arrow on pedestal
'\u21EC': MO.RELSTRETCH, // upwards white arrow on pedestal with horizontal bar
'\u21ED': MO.RELSTRETCH, // upwards white arrow on pedestal with vertical bar
'\u21EE': MO.RELSTRETCH, // upwards white double arrow
'\u21EF': MO.RELSTRETCH, // upwards white double arrow on pedestal
'\u21F0': MO.WIDEREL, // rightwards white arrow from wall
'\u21F1': MO.REL, // north west arrow to corner
'\u21F2': MO.REL, // south east arrow to corner
'\u21F3': MO.WIDEREL, // up down white arrow
'\u21F4': MO.REL, // right arrow with small circle
'\u21F5': MO.WIDEREL, // downwards arrow leftwards of upwards arrow
'\u21F3': MO.RELSTRETCH, // up down white arrow
'\u21F4': MO.RELACCENT, // right arrow with small circle
'\u21F5': MO.RELSTRETCH, // downwards arrow leftwards of upwards arrow
'\u21F6': MO.WIDEREL, // three rightwards arrows
'\u21F7': MO.REL, // leftwards arrow with vertical stroke
'\u21F8': MO.REL, // rightwards arrow with vertical stroke
'\u21F9': MO.REL, // left right arrow with vertical stroke
'\u21FA': MO.REL, // leftwards arrow with double vertical stroke
'\u21FB': MO.REL, // rightwards arrow with double vertical stroke
'\u21FC': MO.REL, // left right arrow with double vertical stroke
'\u21F7': MO.RELACCENT, // leftwards arrow with vertical stroke
'\u21F8': MO.RELACCENT, // rightwards arrow with vertical stroke
'\u21F9': MO.RELACCENT, // left right arrow with vertical stroke
'\u21FA': MO.RELACCENT, // leftwards arrow with double vertical stroke
'\u21FB': MO.RELACCENT, // rightwards arrow with double vertical stroke
'\u21FC': MO.RELACCENT, // left right arrow with double vertical stroke
'\u21FD': MO.WIDEREL, // leftwards open-headed arrow
'\u21FE': MO.WIDEREL, // rightwards open-headed arrow
'\u21FF': MO.WIDEREL // left right open-headed arrow

View File

@ -24,13 +24,19 @@
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
prefix: {
'||': [0,0,TEXCLASS.BIN,{fence: true, stretchy: true, symmetric: true}], // multiple character operator: ||
'|||': [0,0,TEXCLASS.ORD,{fence: true, stretchy: true, symmetric: true}] // multiple character operator: |||
},
postfix: {
'!!': [1,0,TEXCLASS.BIN], // multiple character operator: !!
'\'': MO.ACCENT, // apostrophe
'++': [0,0,TEXCLASS.BIN], // multiple character operator: ++
'--': [0,0,TEXCLASS.BIN], // multiple character operator: --
'..': [0,0,TEXCLASS.BIN], // multiple character operator: ..
'...': MO.ORD // multiple character operator: ...
'...': MO.ORD, // multiple character operator: ...
'||': [0,0,TEXCLASS.BIN,{fence: true, stretchy: true, symmetric: true}], // multiple character operator: ||
'|||': [0,0,TEXCLASS.ORD,{fence: true, stretchy: true, symmetric: true}] // multiple character operator: |||
},
infix: {
'!=': MO.BIN4, // multiple character operator: !=
@ -39,16 +45,17 @@
'*=': MO.BIN4, // multiple character operator: *=
'+=': MO.BIN4, // multiple character operator: +=
'-=': MO.BIN4, // multiple character operator: -=
'->': MO.BIN4, // multiple character operator: ->
'//': MO.BIN4, // multiple character operator: //
'->': MO.BIN5, // multiple character operator: ->
'//': [1,1,TEXCLASS.BIN], // multiple character operator: //
'/=': MO.BIN4, // multiple character operator: /=
':=': MO.BIN4, // multiple character operator: :=
'<=': MO.BIN4, // multiple character operator: <=
'<=': MO.BIN5, // multiple character operator: <=
'<>': [1,1,TEXCLASS.BIN], // multiple character operator: <>
'==': MO.BIN4, // multiple character operator: ==
'>=': MO.BIN4, // multiple character operator: >=
'>=': MO.BIN5, // multiple character operator: >=
'@': MO.ORD11, // commercial at
'||': MO.BIN3 // multiple character operator: ||
'||': [2,2,TEXCLASS.BIN,{fence: true, stretchy: true, symmetric: true}], // multiple character operator: ||
'|||': [2,2,TEXCLASS.ORD,{fence: true, stretchy: true, symmetric: true}] // multiple character operator: |||
}
}
});

View File

@ -25,7 +25,8 @@
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
postfix: {
'\u20DB': MO.ACCENT // combining three dots above
'\u20DB': MO.ACCENT, // combining three dots above
'\u20DC': MO.ACCENT // combining four dots above
}
}
});

View File

@ -24,8 +24,11 @@
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
infix: {
'\u2713': MO.WIDEACCENT // check mark
prefix: {
'\u2772': MO.OPEN // light left tortoise shell bracket ornament
},
postfix: {
'\u2773': MO.CLOSE // light right tortoise shell bracket ornament
}
}
});

View File

@ -25,10 +25,12 @@
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
prefix: {
'\u2016': [0,0,TEXCLASS.ORD,{fence: true, stretchy: true}], // double vertical line
'\u2018': [0,0,TEXCLASS.OPEN,{fence: true}], // left single quotation mark
'\u201C': [0,0,TEXCLASS.OPEN,{fence: true}] // left double quotation mark
},
postfix: {
'\u2016': [0,0,TEXCLASS.ORD,{fence: true, stretchy: true}], // double vertical line
'\u2019': [0,0,TEXCLASS.CLOSE,{fence: true}], // right single quotation mark
'\u201D': [0,0,TEXCLASS.CLOSE,{fence: true}] // right double quotation mark
}

View File

@ -24,8 +24,8 @@
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
prefix: {
'\u03C3': MO.ORD11 // greek small letter sigma
infix: {
'\u03F6': MO.REL // greek reversed lunate epsilon symbol
}
}
});

View File

@ -26,10 +26,7 @@
OPTABLE: {
prefix: {
'\u2145': MO.ORD21, // double-struck italic capital d
'\u2146': [2,0,TEXCLASS.ORD], // double-struck italic small d
'\u2147': MO.ORD, // double-struck italic small e
'\u2148': MO.ORD, // double-struck italic small i
'\u2149': MO.ORD // double-struck italic small j
'\u2146': [2,0,TEXCLASS.ORD] // double-struck italic small d
}
}
});

View File

@ -63,7 +63,7 @@
'\u223F': MO.BIN3, // sine wave
'\u2241': MO.REL, // not tilde
'\u2242': MO.REL, // minus tilde
'\u2242\u0338': MO.BIN4, // minus tilde with slash
'\u2242\u0338': MO.REL, // minus tilde with slash
'\u2244': MO.REL, // not asymptotically equal to
'\u2246': MO.REL, // approximately but not actually equal to
'\u2247': MO.REL, // neither approximately nor actually equal to
@ -72,9 +72,9 @@
'\u224B': MO.REL, // triple tilde
'\u224C': MO.REL, // all equal to
'\u224E': MO.REL, // geometrically equivalent to
'\u224E\u0338': MO.BIN4, // geometrically equivalent to with slash
'\u224E\u0338': MO.REL, // geometrically equivalent to with slash
'\u224F': MO.REL, // difference between
'\u224F\u0338': MO.BIN4, // difference between with slash
'\u224F\u0338': MO.REL, // difference between with slash
'\u2251': MO.REL, // geometrically equal to
'\u2252': MO.REL, // approximately equal to or the image of
'\u2253': MO.REL, // image of or approximately equal to
@ -92,12 +92,12 @@
'\u2262': MO.REL, // not identical to
'\u2263': MO.REL, // strictly equivalent to
'\u2266': MO.REL, // less-than over equal to
'\u2266\u0338': MO.BIN4, // less-than over equal to with slash
'\u2266\u0338': MO.REL, // less-than over equal to with slash
'\u2267': MO.REL, // greater-than over equal to
'\u2268': MO.REL, // less-than but not equal to
'\u2269': MO.REL, // greater-than but not equal to
'\u226A\u0338': MO.BIN4, // much less than with slash
'\u226B\u0338': MO.BIN4, // much greater than with slash
'\u226A\u0338': MO.REL, // much less than with slash
'\u226B\u0338': MO.REL, // much greater than with slash
'\u226C': MO.REL, // between
'\u226D': MO.REL, // not equivalent to
'\u226E': MO.REL, // not less-than
@ -116,11 +116,11 @@
'\u227D': MO.REL, // succeeds or equal to
'\u227E': MO.REL, // precedes or equivalent to
'\u227F': MO.REL, // succeeds or equivalent to
'\u227F\u0338': MO.BIN4, // succeeds or equivalent to with slash
'\u227F\u0338': MO.REL, // succeeds or equivalent to with slash
'\u2280': MO.REL, // does not precede
'\u2281': MO.REL, // does not succeed
'\u2282\u20D2': MO.BIN4, // subset of with vertical line
'\u2283\u20D2': MO.BIN4, // superset of with vertical line
'\u2282\u20D2': MO.REL, // subset of with vertical line
'\u2283\u20D2': MO.REL, // superset of with vertical line
'\u2284': MO.REL, // not a subset of
'\u2285': MO.REL, // not a superset of
'\u2288': MO.REL, // neither a subset of nor equal to
@ -130,9 +130,9 @@
'\u228C': MO.BIN4, // multiset
'\u228D': MO.BIN4, // multiset multiplication
'\u228F': MO.REL, // square image of
'\u228F\u0338': MO.BIN4, // square image of with slash
'\u228F\u0338': MO.REL, // square image of with slash
'\u2290': MO.REL, // square original of
'\u2290\u0338': MO.BIN4, // square original of with slash
'\u2290\u0338': MO.REL, // square original of with slash
'\u229A': MO.BIN4, // circled ring operator
'\u229B': MO.BIN4, // circled asterisk operator
'\u229C': MO.BIN4, // circled equals

View File

@ -25,10 +25,14 @@
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
prefix: {
'\u27E6': MO.OPEN // mathematical left white square bracket
'\u27E6': MO.OPEN, // mathematical left white square bracket
'\u27EA': MO.OPEN, // mathematical left double angle bracket
'\u27EC': MO.OPEN // mathematical left white tortoise shell bracket
},
postfix: {
'\u27E7': MO.CLOSE // mathematical right white square bracket
'\u27E7': MO.CLOSE, // mathematical right white square bracket
'\u27EB': MO.CLOSE, // mathematical right double angle bracket
'\u27ED': MO.CLOSE // mathematical right white tortoise shell bracket
}
}
});

View File

@ -25,6 +25,7 @@
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
prefix: {
'\u2980': [0,0,TEXCLASS.ORD,{fence: true, stretchy: true}], // triple vertical bar delimiter
'\u2983': MO.OPEN, // left white curly bracket
'\u2985': MO.OPEN, // left white parenthesis
'\u2987': MO.OPEN, // z notation left image bracket
@ -39,6 +40,7 @@
'\u29FC': MO.OPEN // left-pointing curved angle bracket
},
postfix: {
'\u2980': [0,0,TEXCLASS.ORD,{fence: true, stretchy: true}], // triple vertical bar delimiter
'\u2984': MO.CLOSE, // right white curly bracket
'\u2986': MO.CLOSE, // right white parenthesis
'\u2988': MO.CLOSE, // z notation right image bracket
@ -53,7 +55,6 @@
'\u29FD': MO.CLOSE // right-pointing curved angle bracket
},
infix: {
'\u2980': MO.ORD, // triple vertical bar delimiter
'\u2981': MO.BIN3, // z notation spot
'\u2982': MO.BIN3, // z notation type colon
'\u2999': MO.BIN3, // dotted fence
@ -111,9 +112,9 @@
'\u29CD': MO.BIN3, // triangle with serifs at bottom
'\u29CE': MO.REL, // right triangle above left triangle
'\u29CF': MO.REL, // left triangle beside vertical bar
'\u29CF\u0338': MO.BIN4, // left triangle beside vertical bar with slash
'\u29CF\u0338': MO.REL, // left triangle beside vertical bar with slash
'\u29D0': MO.REL, // vertical bar beside right triangle
'\u29D0\u0338': MO.BIN4, // vertical bar beside right triangle with slash
'\u29D0\u0338': MO.REL, // vertical bar beside right triangle with slash
'\u29D1': MO.REL, // bowtie with left half black
'\u29D2': MO.REL, // bowtie with right half black
'\u29D3': MO.REL, // black bowtie

View File

@ -0,0 +1,36 @@
/*************************************************************
*
* MathJax/jax/output/HTML-CSS/optable/MiscSymbolsAndArrows.js
*
* Copyright (c) 2010 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
(function (MML) {
var MO = MML.mo.OPTYPES;
var TEXCLASS = MML.TEXCLASS;
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
infix: {
'\u2B45': MO.RELSTRETCH, // leftwards quadruple arrow
'\u2B46': MO.RELSTRETCH // rightwards quadruple arrow
}
}
});
MathJax.Ajax.loadComplete(MML.optableDir+"/MiscSymbolsAndArrows.js");
})(MathJax.ElementJax.mml);

View File

@ -28,7 +28,9 @@
'\u23B4': MO.WIDEACCENT, // top square bracket
'\u23B5': MO.WIDEACCENT, // bottom square bracket
'\u23DC': MO.WIDEACCENT, // top parenthesis
'\u23DD': MO.WIDEACCENT // bottom parenthesis
'\u23DD': MO.WIDEACCENT, // bottom parenthesis
'\u23E0': MO.WIDEACCENT, // top tortoise shell bracket
'\u23E1': MO.WIDEACCENT // bottom tortoise shell bracket
}
}
});

View File

@ -25,8 +25,10 @@
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
postfix: {
'\u02CD': MO.WIDEACCENT, // modifier letter low macron
'\u02DA': MO.ACCENT, // ring above
'\u02DD': MO.ACCENT // double acute accent
'\u02DD': MO.ACCENT, // double acute accent
'\u02F7': MO.WIDEACCENT // modifier letter low tilde
}
}
});

View File

@ -148,9 +148,9 @@
'\u2A7B': MO.REL, // less-than with question mark above
'\u2A7C': MO.REL, // greater-than with question mark above
'\u2A7D': MO.REL, // less-than or slanted equal to
'\u2A7D\u0338': MO.BIN4, // less-than or slanted equal to with slash
'\u2A7D\u0338': MO.REL, // less-than or slanted equal to with slash
'\u2A7E': MO.REL, // greater-than or slanted equal to
'\u2A7E\u0338': MO.BIN4, // greater-than or slanted equal to with slash
'\u2A7E\u0338': MO.REL, // greater-than or slanted equal to with slash
'\u2A7F': MO.REL, // less-than or slanted equal to with dot inside
'\u2A80': MO.REL, // greater-than or slanted equal to with dot inside
'\u2A81': MO.REL, // less-than or slanted equal to with dot above
@ -186,9 +186,9 @@
'\u2A9F': MO.REL, // similar above less-than above equals sign
'\u2AA0': MO.REL, // similar above greater-than above equals sign
'\u2AA1': MO.REL, // double nested less-than
'\u2AA1\u0338': MO.BIN4, // double nested less-than with slash
'\u2AA1\u0338': MO.REL, // double nested less-than with slash
'\u2AA2': MO.REL, // double nested greater-than
'\u2AA2\u0338': MO.BIN4, // double nested greater-than with slash
'\u2AA2\u0338': MO.REL, // double nested greater-than with slash
'\u2AA3': MO.REL, // double nested less-than with underbar
'\u2AA4': MO.REL, // greater-than overlapping less-than
'\u2AA5': MO.REL, // greater-than beside less-than
@ -201,8 +201,8 @@
'\u2AAC': MO.REL, // smaller than or equal to
'\u2AAD': MO.REL, // larger than or equal to
'\u2AAE': MO.REL, // equals sign with bumpy above
'\u2AAF\u0338': MO.BIN4, // precedes above single-line equals sign with slash
'\u2AB0\u0338': MO.BIN4, // succeeds above single-line equals sign with slash
'\u2AAF\u0338': MO.REL, // precedes above single-line equals sign with slash
'\u2AB0\u0338': MO.REL, // succeeds above single-line equals sign with slash
'\u2AB1': MO.REL, // precedes above single-line not equal to
'\u2AB2': MO.REL, // succeeds above single-line not equal to
'\u2AB3': MO.REL, // precedes above equals sign

View File

@ -0,0 +1,40 @@
/*************************************************************
*
* MathJax/jax/output/HTML-CSS/optable/SupplementalArrowsA.js
*
* Copyright (c) 2010 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
(function (MML) {
var MO = MML.mo.OPTYPES;
var TEXCLASS = MML.TEXCLASS;
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
infix: {
'\u27F0': MO.RELSTRETCH, // upwards quadruple arrow
'\u27F1': MO.RELSTRETCH, // downwards quadruple arrow
'\u27FB': MO.WIDEREL, // long leftwards arrow from bar
'\u27FD': MO.WIDEREL, // long leftwards double arrow from bar
'\u27FE': MO.WIDEREL, // long rightwards double arrow from bar
'\u27FF': MO.WIDEREL // long rightwards squiggle arrow
}
}
});
MathJax.Ajax.loadComplete(MML.optableDir+"/SupplementalArrowsA.js");
})(MathJax.ElementJax.mml);

View File

@ -25,41 +25,41 @@
MathJax.Hub.Insert(MML.mo.prototype,{
OPTABLE: {
infix: {
'\u2900': MO.REL, // rightwards two-headed arrow with vertical stroke
'\u2901': MO.REL, // rightwards two-headed arrow with double vertical stroke
'\u2902': MO.REL, // leftwards double arrow with vertical stroke
'\u2903': MO.REL, // rightwards double arrow with vertical stroke
'\u2904': MO.REL, // left right double arrow with vertical stroke
'\u2905': MO.REL, // rightwards two-headed arrow from bar
'\u2906': MO.REL, // leftwards double arrow from bar
'\u2907': MO.REL, // rightwards double arrow from bar
'\u2900': MO.RELACCENT, // rightwards two-headed arrow with vertical stroke
'\u2901': MO.RELACCENT, // rightwards two-headed arrow with double vertical stroke
'\u2902': MO.RELACCENT, // leftwards double arrow with vertical stroke
'\u2903': MO.RELACCENT, // rightwards double arrow with vertical stroke
'\u2904': MO.RELACCENT, // left right double arrow with vertical stroke
'\u2905': MO.RELACCENT, // rightwards two-headed arrow from bar
'\u2906': MO.RELACCENT, // leftwards double arrow from bar
'\u2907': MO.RELACCENT, // rightwards double arrow from bar
'\u2908': MO.REL, // downwards arrow with horizontal stroke
'\u2909': MO.REL, // upwards arrow with horizontal stroke
'\u290A': MO.WIDEREL, // upwards triple arrow
'\u290B': MO.WIDEREL, // downwards triple arrow
'\u290A': MO.RELSTRETCH, // upwards triple arrow
'\u290B': MO.RELSTRETCH, // downwards triple arrow
'\u290C': MO.WIDEREL, // leftwards double dash arrow
'\u290D': MO.WIDEREL, // rightwards double dash arrow
'\u290E': MO.WIDEREL, // leftwards triple dash arrow
'\u290F': MO.WIDEREL, // rightwards triple dash arrow
'\u2910': MO.WIDEREL, // rightwards two-headed triple dash arrow
'\u2911': MO.REL, // rightwards arrow with dotted stem
'\u2912': MO.WIDEREL, // upwards arrow to bar
'\u2913': MO.WIDEREL, // downwards arrow to bar
'\u2914': MO.REL, // rightwards arrow with tail with vertical stroke
'\u2915': MO.REL, // rightwards arrow with tail with double vertical stroke
'\u2916': MO.REL, // rightwards two-headed arrow with tail
'\u2917': MO.REL, // rightwards two-headed arrow with tail with vertical stroke
'\u2918': MO.REL, // rightwards two-headed arrow with tail with double vertical stroke
'\u2919': MO.REL, // leftwards arrow-tail
'\u291A': MO.REL, // rightwards arrow-tail
'\u291B': MO.REL, // leftwards double arrow-tail
'\u291C': MO.REL, // rightwards double arrow-tail
'\u291D': MO.REL, // leftwards arrow to black diamond
'\u291E': MO.REL, // rightwards arrow to black diamond
'\u291F': MO.REL, // leftwards arrow from bar to black diamond
'\u2920': MO.REL, // rightwards arrow from bar to black diamond
'\u2921': MO.WIDEREL, // north west and south east arrow
'\u2922': MO.WIDEREL, // north east and south west arrow
'\u2911': MO.RELACCENT, // rightwards arrow with dotted stem
'\u2912': MO.RELSTRETCH, // upwards arrow to bar
'\u2913': MO.RELSTRETCH, // downwards arrow to bar
'\u2914': MO.RELACCENT, // rightwards arrow with tail with vertical stroke
'\u2915': MO.RELACCENT, // rightwards arrow with tail with double vertical stroke
'\u2916': MO.RELACCENT, // rightwards two-headed arrow with tail
'\u2917': MO.RELACCENT, // rightwards two-headed arrow with tail with vertical stroke
'\u2918': MO.RELACCENT, // rightwards two-headed arrow with tail with double vertical stroke
'\u2919': MO.RELACCENT, // leftwards arrow-tail
'\u291A': MO.RELACCENT, // rightwards arrow-tail
'\u291B': MO.RELACCENT, // leftwards double arrow-tail
'\u291C': MO.RELACCENT, // rightwards double arrow-tail
'\u291D': MO.RELACCENT, // leftwards arrow to black diamond
'\u291E': MO.RELACCENT, // rightwards arrow to black diamond
'\u291F': MO.RELACCENT, // leftwards arrow from bar to black diamond
'\u2920': MO.RELACCENT, // rightwards arrow from bar to black diamond
'\u2921': MO.RELSTRETCH, // north west and south east arrow
'\u2922': MO.RELSTRETCH, // north east and south west arrow
'\u2923': MO.REL, // north west arrow with hook
'\u2924': MO.REL, // north east arrow with hook
'\u2925': MO.REL, // south east arrow with hook
@ -76,81 +76,81 @@
'\u2930': MO.REL, // rising diagonal crossing south east arrow
'\u2931': MO.REL, // north east arrow crossing north west arrow
'\u2932': MO.REL, // north west arrow crossing north east arrow
'\u2933': MO.REL, // wave arrow pointing directly right
'\u2933': MO.RELACCENT, // wave arrow pointing directly right
'\u2934': MO.REL, // arrow pointing rightwards then curving upwards
'\u2935': MO.REL, // arrow pointing rightwards then curving downwards
'\u2936': MO.REL, // arrow pointing downwards then curving leftwards
'\u2937': MO.REL, // arrow pointing downwards then curving rightwards
'\u2938': MO.REL, // right-side arc clockwise arrow
'\u2939': MO.REL, // left-side arc anticlockwise arrow
'\u293A': MO.REL, // top arc anticlockwise arrow
'\u293B': MO.REL, // bottom arc anticlockwise arrow
'\u293C': MO.REL, // top arc clockwise arrow with minus
'\u293D': MO.REL, // top arc anticlockwise arrow with plus
'\u293A': MO.RELACCENT, // top arc anticlockwise arrow
'\u293B': MO.RELACCENT, // bottom arc anticlockwise arrow
'\u293C': MO.RELACCENT, // top arc clockwise arrow with minus
'\u293D': MO.RELACCENT, // top arc anticlockwise arrow with plus
'\u293E': MO.REL, // lower right semicircular clockwise arrow
'\u293F': MO.REL, // lower left semicircular anticlockwise arrow
'\u2940': MO.REL, // anticlockwise closed circle arrow
'\u2941': MO.REL, // clockwise closed circle arrow
'\u2942': MO.REL, // rightwards arrow above short leftwards arrow
'\u2943': MO.REL, // leftwards arrow above short rightwards arrow
'\u2944': MO.REL, // short rightwards arrow above leftwards arrow
'\u2945': MO.REL, // rightwards arrow with plus below
'\u2946': MO.REL, // leftwards arrow with plus below
'\u2947': MO.REL, // rightwards arrow through x
'\u2948': MO.REL, // left right arrow through small circle
'\u2942': MO.RELACCENT, // rightwards arrow above short leftwards arrow
'\u2943': MO.RELACCENT, // leftwards arrow above short rightwards arrow
'\u2944': MO.RELACCENT, // short rightwards arrow above leftwards arrow
'\u2945': MO.RELACCENT, // rightwards arrow with plus below
'\u2946': MO.RELACCENT, // leftwards arrow with plus below
'\u2947': MO.RELACCENT, // rightwards arrow through x
'\u2948': MO.RELACCENT, // left right arrow through small circle
'\u2949': MO.REL, // upwards two-headed arrow from small circle
'\u294A': MO.REL, // left barb up right barb down harpoon
'\u294B': MO.REL, // left barb down right barb up harpoon
'\u294A': MO.RELACCENT, // left barb up right barb down harpoon
'\u294B': MO.RELACCENT, // left barb down right barb up harpoon
'\u294C': MO.REL, // up barb right down barb left harpoon
'\u294D': MO.REL, // up barb left down barb right harpoon
'\u294E': MO.RELACCENT, // left barb up right barb up harpoon
'\u294F': MO.WIDEREL, // up barb right down barb right harpoon
'\u294E': MO.WIDEREL, // left barb up right barb up harpoon
'\u294F': MO.RELSTRETCH, // up barb right down barb right harpoon
'\u2950': MO.WIDEREL, // left barb down right barb down harpoon
'\u2951': MO.WIDEREL, // up barb left down barb left harpoon
'\u2951': MO.RELSTRETCH, // up barb left down barb left harpoon
'\u2952': MO.WIDEREL, // leftwards harpoon with barb up to bar
'\u2953': MO.WIDEREL, // rightwards harpoon with barb up to bar
'\u2954': MO.WIDEREL, // upwards harpoon with barb right to bar
'\u2955': MO.WIDEREL, // downwards harpoon with barb right to bar
'\u2956': MO.WIDEREL, // leftwards harpoon with barb down to bar
'\u2957': MO.WIDEREL, // rightwards harpoon with barb down to bar
'\u2958': MO.WIDEREL, // upwards harpoon with barb left to bar
'\u2959': MO.WIDEREL, // downwards harpoon with barb left to bar
'\u2954': MO.RELSTRETCH, // upwards harpoon with barb right to bar
'\u2955': MO.RELSTRETCH, // downwards harpoon with barb right to bar
'\u2956': MO.RELSTRETCH, // leftwards harpoon with barb down to bar
'\u2957': MO.RELSTRETCH, // rightwards harpoon with barb down to bar
'\u2958': MO.RELSTRETCH, // upwards harpoon with barb left to bar
'\u2959': MO.RELSTRETCH, // downwards harpoon with barb left to bar
'\u295A': MO.WIDEREL, // leftwards harpoon with barb up from bar
'\u295B': MO.WIDEREL, // rightwards harpoon with barb up from bar
'\u295C': MO.WIDEREL, // upwards harpoon with barb right from bar
'\u295D': MO.WIDEREL, // downwards harpoon with barb right from bar
'\u295C': MO.RELSTRETCH, // upwards harpoon with barb right from bar
'\u295D': MO.RELSTRETCH, // downwards harpoon with barb right from bar
'\u295E': MO.WIDEREL, // leftwards harpoon with barb down from bar
'\u295F': MO.WIDEREL, // rightwards harpoon with barb down from bar
'\u2960': MO.WIDEREL, // upwards harpoon with barb left from bar
'\u2961': MO.WIDEREL, // downwards harpoon with barb left from bar
'\u2962': MO.REL, // leftwards harpoon with barb up above leftwards harpoon with barb down
'\u2960': MO.RELSTRETCH, // upwards harpoon with barb left from bar
'\u2961': MO.RELSTRETCH, // downwards harpoon with barb left from bar
'\u2962': MO.RELACCENT, // leftwards harpoon with barb up above leftwards harpoon with barb down
'\u2963': MO.REL, // upwards harpoon with barb left beside upwards harpoon with barb right
'\u2964': MO.REL, // rightwards harpoon with barb up above rightwards harpoon with barb down
'\u2964': MO.RELACCENT, // rightwards harpoon with barb up above rightwards harpoon with barb down
'\u2965': MO.REL, // downwards harpoon with barb left beside downwards harpoon with barb right
'\u2966': MO.REL, // leftwards harpoon with barb up above rightwards harpoon with barb up
'\u2967': MO.REL, // leftwards harpoon with barb down above rightwards harpoon with barb down
'\u2968': MO.REL, // rightwards harpoon with barb up above leftwards harpoon with barb up
'\u2969': MO.REL, // rightwards harpoon with barb down above leftwards harpoon with barb down
'\u296A': MO.REL, // leftwards harpoon with barb up above long dash
'\u296B': MO.REL, // leftwards harpoon with barb down below long dash
'\u296C': MO.REL, // rightwards harpoon with barb up above long dash
'\u296D': MO.REL, // rightwards harpoon with barb down below long dash
'\u296E': MO.WIDEREL, // upwards harpoon with barb left beside downwards harpoon with barb right
'\u296F': MO.WIDEREL, // downwards harpoon with barb left beside upwards harpoon with barb right
'\u2970': MO.REL, // right double arrow with rounded head
'\u2971': MO.REL, // equals sign above rightwards arrow
'\u2972': MO.REL, // tilde operator above rightwards arrow
'\u2973': MO.REL, // leftwards arrow above tilde operator
'\u2974': MO.REL, // rightwards arrow above tilde operator
'\u2975': MO.REL, // rightwards arrow above almost equal to
'\u2976': MO.REL, // less-than above leftwards arrow
'\u2977': MO.REL, // leftwards arrow through less-than
'\u2978': MO.REL, // greater-than above rightwards arrow
'\u2979': MO.REL, // subset above rightwards arrow
'\u297A': MO.REL, // leftwards arrow through subset
'\u297B': MO.REL, // superset above leftwards arrow
'\u297C': MO.REL, // left fish tail
'\u297D': MO.REL, // right fish tail
'\u2966': MO.RELACCENT, // leftwards harpoon with barb up above rightwards harpoon with barb up
'\u2967': MO.RELACCENT, // leftwards harpoon with barb down above rightwards harpoon with barb down
'\u2968': MO.RELACCENT, // rightwards harpoon with barb up above leftwards harpoon with barb up
'\u2969': MO.RELACCENT, // rightwards harpoon with barb down above leftwards harpoon with barb down
'\u296A': MO.RELACCENT, // leftwards harpoon with barb up above long dash
'\u296B': MO.RELACCENT, // leftwards harpoon with barb down below long dash
'\u296C': MO.RELACCENT, // rightwards harpoon with barb up above long dash
'\u296D': MO.RELACCENT, // rightwards harpoon with barb down below long dash
'\u296E': MO.RELSTRETCH, // upwards harpoon with barb left beside downwards harpoon with barb right
'\u296F': MO.RELSTRETCH, // downwards harpoon with barb left beside upwards harpoon with barb right
'\u2970': MO.RELACCENT, // right double arrow with rounded head
'\u2971': MO.RELACCENT, // equals sign above rightwards arrow
'\u2972': MO.RELACCENT, // tilde operator above rightwards arrow
'\u2973': MO.RELACCENT, // leftwards arrow above tilde operator
'\u2974': MO.RELACCENT, // rightwards arrow above tilde operator
'\u2975': MO.RELACCENT, // rightwards arrow above almost equal to
'\u2976': MO.RELACCENT, // less-than above leftwards arrow
'\u2977': MO.RELACCENT, // leftwards arrow through less-than
'\u2978': MO.RELACCENT, // greater-than above rightwards arrow
'\u2979': MO.RELACCENT, // subset above rightwards arrow
'\u297A': MO.RELACCENT, // leftwards arrow through subset
'\u297B': MO.RELACCENT, // superset above leftwards arrow
'\u297C': MO.RELACCENT, // left fish tail
'\u297D': MO.RELACCENT, // right fish tail
'\u297E': MO.REL, // up fish tail
'\u297F': MO.REL // down fish tail
}

View File

@ -0,0 +1,41 @@
/*************************************************************
*
* MathJax/jax/input/AsciiMath/config.js
*
* Initializes the AsciiMath InputJax (the main definition is in
* MathJax/jax/input/AsciiMath/jax.js, which is loaded when needed).
*
* Originally adapted for MathJax by David Lippman.
* Additional work done by Davide P. Cervone.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.InputJax.AsciiMath = MathJax.InputJax({
id: "AsciiMath",
version: "2.0",
directory: MathJax.InputJax.directory + "/AsciiMath",
extensionDir: MathJax.InputJax.extensionDir + "/AsciiMath",
config: {
displaystyle: true, // put limits above and below operators
decimal: "." // can change to "," but watch out for "(1,2)"
}
});
MathJax.InputJax.AsciiMath.Register("math/asciimath");
MathJax.InputJax.AsciiMath.loadComplete("config.js");

1309
modules/MathJax/jax/input/AsciiMath/jax.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009-2011 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,7 +24,7 @@
MathJax.InputJax.MathML = MathJax.InputJax({
id: "MathML",
version: "1.1.4",
version: "2.0",
directory: MathJax.InputJax.directory + "/MathML",
extensionDir: MathJax.InputJax.extensionDir + "/MathML",
entityDir: MathJax.InputJax.directory + "/MathML/entities",

View File

@ -8,7 +8,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function (MATHML,BROWSER) {
@ -38,6 +38,12 @@
if (typeof math !== "string") {doc = math.parentNode} else {
if (math.match(/^<[a-z]+:/i) && !math.match(/^<[^<>]* xmlns:/))
{math = math.replace(/^<([a-z]+)(:math)/i,'<$1$2 xmlns:$1="http://www.w3.org/1998/Math/MathML"')}
// HTML5 removes xmlns: namespaces, so put them back for XML
var match = math.match(/^(<math( ('.*?'|".*?"|[^>])+)>)/i);
if (match && match[2].match(/ (?!xmlns=)[a-z]+=\"http:/i)) {
math = match[1].replace(/ (?!xmlns=)([a-z]+=(['"])http:.*?\2)/ig," xmlns:$1 $1") +
math.substr(match[0].length);
}
math = math.replace(/^\s*(?:\/\/)?<!(--)?\[CDATA\[((.|\n)*)(\/\/)?\]\]\1>\s*$/,"$2");
math = math.replace(/&([a-z][a-z0-9]*);/ig,this.replaceEntity);
doc = MATHML.ParseXML(math); if (doc == null) {MATHML.Error("Error parsing MathML")}
@ -59,29 +65,87 @@
// Convert the MathML structure to the MathJax Element jax structure
//
MakeMML: function (node) {
var type = node.nodeName.toLowerCase().replace(/^[a-z]+:/,"");
if (!(MML[type] && MML[type].isa && MML[type].isa(MML.mbase)))
{return MML.merror("Unknown node type: "+type)}
var mml = MML[type](), i, m, name, value;
for (i = 0, m = node.attributes.length; i < m; i++) {
name = node.attributes[i].name;
var CLASS = String(node.getAttribute("class")||""); // make sure CLASS is a string
var mml, type = node.nodeName.toLowerCase().replace(/^[a-z]+:/,"");
var match = (CLASS.match(/(^| )MJX-TeXAtom-([^ ]*)/));
if (match) {
mml = this.TeXAtom(match[2]);
} else if (!(MML[type] && MML[type].isa && MML[type].isa(MML.mbase))) {
MathJax.Hub.signal.Post(["MathML Jax - unknown node type",type]);
return MML.merror("Unknown node type: "+type);
} else {
mml = MML[type]();
}
this.AddAttributes(mml,node); this.CheckClass(mml,CLASS);
this.AddChildren(mml,node);
if (MATHML.config.useMathMLspacing) {mml.useMMLspacing = 0x08}
return mml;
},
TeXAtom: function (mclass) {
var mml = MML.TeXAtom().With({texClass:MML.TEXCLASS[mclass]});
if (mml.texClass === MML.TEXCLASS.OP) {mml.movesupsub = mml.movablelimits = true}
return mml;
},
CheckClass: function (mml,CLASS) {
CLASS = CLASS.split(/ /); var NCLASS = [];
for (var i = 0, m = CLASS.length; i < m; i++) {
if (CLASS[i].substr(0,4) === "MJX-") {
if (CLASS[i] === "MJX-arrow") {
mml.arrow = true;
} else if (CLASS[i] === "MJX-variant") {
mml.variantForm = true;
//
// Variant forms come from AMSsymbols, and it sets up the
// character mappings, so load that if needed.
//
if (!MathJax.Extension["TeX/AMSsymbols"])
{MathJax.Hub.RestartAfter(MathJax.Ajax.Require("[MathJax]/extensions/TeX/AMSsymbols.js"))}
} else if (CLASS[i].substr(0,11) !== "MJX-TeXAtom") {
mml.mathvariant = CLASS[i].substr(3);
//
// Caligraphic and oldstyle bold are set up in the boldsymbol
// extension, so load it if it isn't already loaded.
//
if (mml.mathvariant === "-tex-caligraphic-bold" ||
mml.mathvariant === "-tex-oldstyle-bold") {
if (!MathJax.Extension["TeX/boldsymbol"])
{MathJax.Hub.RestartAfter(MathJax.Ajax.Require("[MathJax]/extensions/TeX/boldsymbol.js"))}
}
}
} else {NCLASS.push(CLASS[i])}
}
if (NCLASS.length) {mml["class"] = NCLASS.join(" ")} else {delete mml["class"]}
},
//
// Add the attributes to the mml node
//
AddAttributes: function (mml,node) {
mml.attr = {}; mml.attrNames = [];
for (var i = 0, m = node.attributes.length; i < m; i++) {
var name = node.attributes[i].name;
if (name == "xlink:href") {name = "href"}
if (name.match(/:/)) continue;
value = node.attributes[i].value;
var value = node.attributes[i].value;
if (value.toLowerCase() === "true") {value = true}
else if (value.toLowerCase() === "false") {value = false}
mml[name] = value;
if (mml.defaults[name] != null || MML.copyAttributes[name])
{mml[name] = value} else {mml.attr[name] = value}
mml.attrNames.push(name);
}
for (i = 0, m = node.childNodes.length; i < m; i++) {
},
//
// Create the children for the mml node
//
AddChildren: function (mml,node) {
for (var i = 0, m = node.childNodes.length; i < m; i++) {
var child = node.childNodes[i];
if (child.nodeName === "#comment") continue;
if (child.nodeName === "#text") {
if (mml.isToken && !mml.mmlSelfClosing) {
var text = this.trimSpace(child.nodeValue);
if (mml.isa(MML.mo) && text.length === 1 && this.Remap[text.charAt(0)])
{text = this.Remap[text.charAt(0)]}
text = text.replace(/&([a-z][a-z0-9]*);/ig,this.replaceEntity);
mml.Append(MML.chars(text));
var text = child.nodeValue.replace(/&([a-z][a-z0-9]*);/ig,this.replaceEntity);
mml.Append(MML.chars(this.trimSpace(text)));
} else if (child.nodeValue.match(/\S/)) {
MATHML.Error("Unexpected text node: '"+child.nodeValue+"'");
}
@ -93,16 +157,22 @@
{mml.Append.apply(mml,cmml.data); cmml.data = []}
}
}
if (MATHML.config.useMathMLspacing) {mml.useMMLspacing = 0x08}
return mml;
},
//
// Remove attribute whitespace
//
trimSpace: function (string) {
return string.replace(/^[ \t\n\r]+/,"") // initial whitespace
.replace(/[ \t\n\r]+$/,"") // trailing whitespace
.replace(/[ \t\n\r][ \t\n\r]+/g," "); // internal multiple whitespace
return string.replace(/[\t\n\r]/g," ") // whitespace to spaces
.replace(/^ +/,"") // initial whitespace
.replace(/ +$/,"") // trailing whitespace
.replace(/ +/g," "); // internal multiple whitespace
},
//
// Replace a named entity by its value
// (look up from external files if necessary)
//
replaceEntity: function (match,entity) {
if (entity.match(/^(lt|amp|quot)$/)) {return match} // these mess up attribute parsing
if (MATHML.Parse.Entity[entity]) {return MATHML.Parse.Entity[entity]}
@ -114,32 +184,30 @@
MathJax.Hub.RestartAfter(MathJax.Ajax.Require(MATHML.entityDir+"/"+file+".js"));
}
return match;
},
Remap: {
'\u0027': '\u2032', // '
'\u002A': '\u2217', // *
'\u002D': '\u2212' // -
}
}, {
loaded: []
loaded: [] // the entity files that are loaded
});
/************************************************************************/
MATHML.Augment({
sourceMenuTitle: "Original MathML",
prefilterHooks: MathJax.Callback.Hooks(true), // hooks to run before processing MathML
postfilterHooks: MathJax.Callback.Hooks(true), // hooks to run after processing MathML
Translate: function (script) {
if (!this.ParseXML) {this.ParseXML = this.createParser()}
var mml, math;
var mml, math, data = {script:script};
if (script.firstChild &&
script.firstChild.nodeName.toLowerCase().replace(/^[a-z]+:/,"") === "math") {
math = this.prefilterMathML(script.firstChild);
data.math = script.firstChild;
this.prefilterHooks.Execute(data); math = data.math;
} else {
math = script.innerHTML.replace(/^\s+/,"").replace(/\s+$/,"");
math = MathJax.HTML.getScript(script);
if (BROWSER.isMSIE) {math = math.replace(/(&nbsp;)+$/,"")}
else if (BROWSER.isKonqueror)
{math = math.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}
math = this.prefilterMath(math,script);
data.math = math; this.prefilterHooks.Execute(data); math = data.math;
}
try {
mml = MATHML.Parse(math).mml;
@ -147,12 +215,15 @@
if (!err.mathmlError) {throw err}
mml = this.formatError(err,math,script);
}
return MML(mml);
data.math = MML(mml); this.postfilterHooks.Execute(data);
return data.math;
},
prefilterMath: function (math,script) {return math},
prefilterMathML: function (math) {return math},
prefilterMathML: function (math,script) {return math},
formatError: function (err,math,script) {
return MML.merror(err.message.replace(/\n.*/,""));
var message = err.message.replace(/\n.*/,"");
MathJax.Hub.signal.Post(["MathML Jax - parse error",message,math,script]);
return MML.merror(message);
},
Error: function (message) {
throw MathJax.Hub.Insert(Error(message),{mathmlError: true});
@ -206,10 +277,19 @@
MML = MathJax.ElementJax.mml;
MML.mspace.Augment({mmlSelfClosing: true});
MML.none.Augment({mmlSelfClosing: true});
MML.mprescripts.Augment({mmlSelfClossing:true});
MML.mprescripts.Augment({mmlSelfClosing:true});
}
});
//
// Add the default pre-filter (for backward compatibility)
//
MATHML.prefilterHooks.Add(function (data) {
data.math = (typeof(data.math) === "string" ?
MATHML.prefilterMath(data.math,data.script) :
MATHML.prefilterMathML(data.math,data.script));
});
MATHML.Parse.Entity = {
ApplyFunction: '\u2061',
Backslash: '\u2216',

View File

@ -7,7 +7,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2009-2011 Design Science, Inc.
* Copyright (c) 2009-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,14 +24,24 @@
MathJax.InputJax.TeX = MathJax.InputJax({
id: "TeX",
version: "1.1.1",
version: "2.0",
directory: MathJax.InputJax.directory + "/TeX",
extensionDir: MathJax.InputJax.extensionDir + "/TeX",
config: {
TagSide: "right",
TagIndent: "0.8em",
MultLineWidth: "85%"
MultLineWidth: "85%",
equationNumbers: {
autoNumber: "none", // "AMS" for standard AMS numbering,
// or "all" for all displayed equations
formatNumber: function (n) {return n},
formatTag: function (n) {return '('+n+')'},
formatID: function (n) {return 'mjx-eqn-'+String(n).replace(/[:"'<>&]/g,"")},
formatURL: function (id) {return '#'+escape(id)},
useLabelIds: true
}
}
});
MathJax.InputJax.TeX.Register("math/tex");

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2011 Design Science, Inc.
* Copyright (c) 2011-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var VERSION = "1.1";
var VERSION = "2.0";
var MML = MathJax.ElementJax.mml,
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
@ -37,7 +37,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
return span;
},
HTMLgetScale: function () {
return this.SUPER(arguments).HTMLgetScale.call(this) * (100/HTMLCSS.scale)
return this.SUPER(arguments).HTMLgetScale.call(this) / HTMLCSS.scale;
}
});

View File

@ -6,7 +6,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var VERSION = "1.1.2";
var VERSION = "2.0";
var MML = MathJax.ElementJax.mml,
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
@ -42,35 +42,39 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
toHTML: function (span,HW,D) {
span = this.HTMLhandleSize(this.HTMLcreateSpan(span)); span.bbox = null;
var values = this.getValues("actiontype","selection"), frame;
var selected = this.data[values.selection-1];
var selected = this.selected();
if (selected) {
HTMLCSS.Measured(selected.toHTML(span),span);
var box = selected.toHTML(span);
if (D != null) {HTMLCSS.Remeasured(selected.HTMLstretchV(span,HW,D),span)}
else if (HW != null) {HTMLCSS.Remeasured(selected.HTMLstretchH(span,HW),span)}
if (HTMLCSS.msieHitBoxBug) {
// margin-left doesn't work on inline-block elements in IE, so put it in a SPAN
var box = HTMLCSS.addElement(span,"span");
frame = HTMLCSS.createFrame(box,span.bbox.h,span.bbox.d,span.bbox.w,0,"none");
span.insertBefore(box,span.firstChild); // move below the content
box.style.marginRight = HTMLCSS.Em(-span.bbox.w);
if (HTMLCSS.msieInlineBlockAlignBug)
{frame.style.verticalAlign = HTMLCSS.Em(HTMLCSS.getHD(span).d-span.bbox.d)}
} else {
frame = HTMLCSS.createFrame(span,span.bbox.h,span.bbox.d,span.bbox.w,0,"none");
span.insertBefore(frame,span.firstChild); // move below the content
frame.style.marginRight = HTMLCSS.Em(-span.bbox.w);
}
frame.className = "MathJax_HitBox";
frame.id = "MathJax-HitBox-"+this.spanID;
if (this.HTMLaction[values.actiontype])
{this.HTMLaction[values.actiontype].call(this,span,frame,values.selection)}
else {HTMLCSS.Measured(box,span)}
this.HTMLhandleHitBox(span);
}
this.HTMLhandleSpace(span);
this.HTMLhandleColor(span);
return span;
},
HTMLhandleHitBox: function (span,postfix) {
var frame;
if (HTMLCSS.msieHitBoxBug) {
// margin-left doesn't work on inline-block elements in IE, so put it in a SPAN
var box = HTMLCSS.addElement(span,"span",{isMathJax:true});
frame = HTMLCSS.createFrame(box,span.bbox.h,span.bbox.d,span.bbox.w,0,"none");
span.insertBefore(box,span.firstChild); // move below the content
box.style.marginRight = HTMLCSS.Em(-span.bbox.w);
if (HTMLCSS.msieInlineBlockAlignBug)
{frame.style.verticalAlign = HTMLCSS.Em(HTMLCSS.getHD(span).d-span.bbox.d)}
} else {
frame = HTMLCSS.createFrame(span,span.bbox.h,span.bbox.d,span.bbox.w,0,"none");
span.insertBefore(frame,span.firstChild); // move below the content
frame.style.marginRight = HTMLCSS.Em(-span.bbox.w);
}
frame.className = "MathJax_HitBox";
frame.id = "MathJax-HitBox-" + this.spanID + (postfix||"") + HTMLCSS.idPostfix;
var type = this.Get("actiontype");
if (this.HTMLaction[type]) {this.HTMLaction[type].call(this,span,frame,this.Get("selection"))}
},
HTMLstretchH: MML.mbase.HTMLstretchH,
HTMLstretchV: MML.mbase.HTMLstretchV,
@ -110,13 +114,13 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
this.selection++;
if (this.selection > this.data.length) {this.selection = 1}
var math = this; while (math.type !== "math") {math = math.inherit}
MathJax.Hub.getJaxFor(math.inputID).Update();
if (!event) {event = window.event}
if (event.preventDefault) {event.preventDefault()}
if (event.stopPropagation) {event.stopPropagation()}
event.cancelBubble = true;
event.returnValue = false;
return false;
var jax = MathJax.Hub.getJaxFor(math.inputID), hover = !!jax.hover;
jax.Update();
if (hover) {
var span = document.getElementById(jax.inputID+"-Span");
MathJax.Extension.MathEvents.Hover.Hover(jax,span);
}
return MathJax.Extension.MathEvents.Event.False(event);
},
//
@ -159,13 +163,24 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
if (this === currentTip) return;
tip.style.left = x+"px"; tip.style.top = y+"px";
tip.innerHTML = '<span class="MathJax"><nobr></nobr></span>';
HTMLCSS.getScales(tip.firstChild,tip.firstChild);
//
// get em sizes (taken from HTMLCSS.preTranslate)
//
var emex = tip.insertBefore(HTMLCSS.EmExSpan.cloneNode(true),tip.firstChild);
var ex = emex.firstChild.offsetHeight/60,
em = emex.lastChild.firstChild.offsetHeight/60;
HTMLCSS.em = HTMLCSS.outerEm = MML.mbase.prototype.em = em;
var scale = Math.floor(Math.max(HTMLCSS.config.minScaleAdjust/100,(ex/HTMLCSS.TeX.x_height)/em) * HTMLCSS.config.scale);
tip.firstChild.style.fontSize = scale+"%";
emex.parentNode.removeChild(emex);
var stack = HTMLCSS.createStack(tip.firstChild.firstChild);
var box = HTMLCSS.createBox(stack);
try {HTMLCSS.Measured(this.data[1].toHTML(box),box)} catch(err) {
if (!err.restart) {throw err}
tip.style.display = "none";
MathJax.Callback.After(["HTMLtooltipPost",this,x,y],err.restart);
return;
}
HTMLCSS.placeBox(box,0,0);
HTMLCSS.createRule(tip.firstChild.firstChild,box.bbox.h,box.bbox.d,0);

View File

@ -2,11 +2,11 @@
*
* MathJax/jax/output/HTML-CSS/autoload/menclose.js
*
* Implements the HTML-CSS output for <mencode> elements.
* Implements the HTML-CSS output for <menclose> elements.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var VERSION = "1.1.1";
var VERSION = "2.0";
var MML = MathJax.ElementJax.mml,
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
@ -36,8 +36,9 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
if (values.color && !this.mathcolor) {values.mathcolor = values.color}
if (values.thickness == null) {values.thickness = ".075em"}
if (values.padding == null) {values.padding = ".2em"}
var p = HTMLCSS.length2em(values.padding);
var t = HTMLCSS.length2em(values.thickness);
var mu = this.HTMLgetMu(span), scale = this.HTMLgetScale();
var p = HTMLCSS.length2em(values.padding,mu,1/HTMLCSS.em) * scale;
var t = HTMLCSS.length2em(values.thickness,mu,1/HTMLCSS.em) * scale;
var SOLID = HTMLCSS.Em(t)+" solid";
span = this.HTMLcreateSpan(span);
@ -50,6 +51,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
HTMLCSS.addBox(stack,frame); stack.insertBefore(frame,base); // move base to above background
var notation = values.notation.split(/ /);
var T = 0, B = 0, R = 0, L = 0, dx = 0, dy = 0; var svg, vml;
var w, h, r;
if (!values.mathcolor) {values.mathcolor = "black"} else {span.style.color = values.mathcolor}
for (var i = 0, m = notation.length; i < m; i++) {
@ -62,8 +64,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
if (HTMLCSS.useVML) {
if (!vml) {vml = this.HTMLvml(stack,H,D,W,t,values.mathcolor)}
// roundrect.arcsize can't be set in IE8 standards mode, so use a path
var r = Math.floor(1000*Math.min(W,H+D)-2*t);
var w = Math.floor(4000*(W-2*t)), h = Math.floor(4000*(H+D-2*t));
r = Math.floor(1000*Math.min(W,H+D)-2*t);
w = Math.floor(4000*(W-2*t)), h = Math.floor(4000*(H+D-2*t));
this.HTMLvmlElement(vml,"shape",{
style: {width:this.HTMLpx(W-2*t),height:this.HTMLpx(H+D-2*t),
left:this.HTMLpx(t,.5),top:this.HTMLpx(t,.5)},
@ -127,12 +129,33 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
case MML.NOTATION.UPDIAGONALSTRIKE:
if (HTMLCSS.useVML) {
if (!vml) {vml = this.HTMLvml(stack,H,D,W,t,values.mathcolor)}
this.HTMLvmlElement(vml,"line",{from: "0,"+this.HTMLpx(H+D-t), to: this.HTMLpx(W)+",0"});
var line = this.HTMLvmlElement(vml,"line",{from: "0,"+this.HTMLpx(H+D-t), to: this.HTMLpx(W)+",0"});
if (this.arrow) {
this.HTMLvmlElement(line,"stroke",{endarrow:"classic"});
line.to = this.HTMLpx(W)+","+this.HTMLpx(t);
}
} else {
if (!svg) {svg = this.HTMLsvg(stack,H,D,W,t,values.mathcolor)}
this.HTMLsvgElement(svg.firstChild,"line",{
x1:1, y1:this.HTMLpx(H+D-t), x2:this.HTMLpx(W-t), y2:this.HTMLpx(t)
});
if (this.arrow) {
var l = Math.sqrt(W*W + (H+D)*(H+D)), f = 1/l * 10*scale/HTMLCSS.em * t/.075;
w = W * f; h = (H+D) * f; var x = W - t/2, y = t/2;
if (y+h-.4*w < 0) {y = .4*w-h}
this.HTMLsvgElement(svg.firstChild,"line",{
x1:1, y1:this.HTMLpx(H+D-t), x2:this.HTMLpx(x-.7*w), y2:this.HTMLpx(y+.7*h)
});
this.HTMLsvgElement(svg.firstChild,"polygon",{
points: this.HTMLpx(x)+","+this.HTMLpx(y)+" "
+this.HTMLpx(x-w-.4*h)+","+this.HTMLpx(y+h-.4*w)+" "
+this.HTMLpx(x-.7*w)+","+this.HTMLpx(y+.7*h)+" "
+this.HTMLpx(x-w+.4*h)+","+this.HTMLpx(y+h+.4*w)+" "
+this.HTMLpx(x)+","+this.HTMLpx(y),
fill:values.mathcolor, stroke:"none"
});
} else {
this.HTMLsvgElement(svg.firstChild,"line",{
x1:1, y1:this.HTMLpx(H+D-t), x2:this.HTMLpx(W-t), y2:this.HTMLpx(t)
});
}
}
break;
@ -213,7 +236,10 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
if (frame) {
// mathcolor is handled in toHTML above
var values = this.getValues("mathbackground","background");
if (this.style && span.style.backgroundColor) {values.mathbackground = span.style.backgroundColor}
if (this.style && span.style.backgroundColor) {
values.mathbackground = span.style.backgroundColor;
span.style.backgroundColor = "";
}
if (values.background && !this.mathbackground) {values.mathbackground = values.background}
if (values.mathbackground && values.mathbackground !== MML.COLOR.TRANSPARENT)
{frame.style.backgroundColor = values.mathbackground}
@ -229,7 +255,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
return svg;
},
HTMLsvgElement: function (svg,type,def) {
var obj = document.createElementNS(SVGNS,type);
var obj = document.createElementNS(SVGNS,type); obj.isMathJax = true;
if (def) {for (var id in def) {if (def.hasOwnProperty(id)) {obj.setAttributeNS(null,id,def[id].toString())}}}
svg.appendChild(obj);
return obj;
@ -241,12 +267,13 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
return vml;
},
HTMLvmlElement: function (vml,type,def) {
var obj = HTMLCSS.addElement(vml,vmlns+":"+type);
var obj = HTMLCSS.addElement(vml,vmlns+":"+type,{isMathJax:true});
obj.style.position = "absolute"; obj.style.left = obj.style.top = 0;
MathJax.Hub.Insert(obj,def); // IE8 needs to do this after obj is added to the page
if (!def.fillcolor) {obj.fillcolor = "none"}
if (!def.strokecolor) {obj.strokecolor = this.constructor.VMLcolor}
if (!def.strokeweight) {obj.strokeweight =this.constructor.VMLthickness}
return obj;
}
});

View File

@ -6,7 +6,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var VERSION = "1.1";
var VERSION = "2.0";
var MML = MathJax.ElementJax.mml,
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
@ -61,20 +61,21 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
this.Append(err); err.toHTML(span); this.data.pop();
span.bbox = err.HTMLspanElement().bbox;
} else {
img = HTMLCSS.addElement(span,"img",{src:values.src, alt:values.alt, title:values.alt});
var mu = this.HTMLgetMu(span);
img = HTMLCSS.addElement(span,"img",{isMathJax:true, src:values.src, alt:values.alt, title:values.alt});
if (values.width) {
if (String(values.width).match(/^\s*-?\d+\s*$/)) {values.width += "px"}
img.style.width = HTMLCSS.Em(HTMLCSS.length2em(values.width,this.img.img.width/HTMLCSS.em));
img.style.width = HTMLCSS.Em(HTMLCSS.length2em(values.width,mu,this.img.img.width/HTMLCSS.em));
}
if (values.height) {
if (String(values.height).match(/^\s*-?\d+\s*$/)) {values.height += "px"}
img.style.height = HTMLCSS.Em(HTMLCSS.length2em(values.height,this.img.img.height/HTMLCSS.em));
img.style.height = HTMLCSS.Em(HTMLCSS.length2em(values.height,mu,this.img.img.height/HTMLCSS.em));
}
span.bbox.w = span.bbox.rw = img.offsetWidth/HTMLCSS.em;
span.bbox.h = img.offsetHeight/HTMLCSS.em;
if (values.valign) {
if (String(values.valign).match(/^\s*-?\d+\s*$/)) {values.valign += "px"}
span.bbox.d = -HTMLCSS.length2em(values.valign,this.img.img.height/HTMLCSS.em);
span.bbox.d = -HTMLCSS.length2em(values.valign,mu,this.img.img.height/HTMLCSS.em);
img.style.verticalAlign = HTMLCSS.Em(-span.bbox.d);
span.bbox.h -= span.bbox.d;
}

View File

@ -6,7 +6,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var VERSION = "1.1";
var VERSION = "2.0";
var MML = MathJax.ElementJax.mml,
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
@ -31,11 +31,12 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
span = this.HTMLcreateSpan(span); var scale = this.HTMLgetScale();
var stack = HTMLCSS.createStack(span), values;
var base = HTMLCSS.createBox(stack);
this.HTMLmeasureChild(this.base,base);
if (this.data[this.base]) {
if (D != null) {HTMLCSS.Remeasured(this.data[this.base].HTMLstretchV(base,HW,D),base)}
else if (HW != null) {HTMLCSS.Remeasured(this.data[this.base].HTMLstretchH(base,HW),base)}
}
var child = this.data[this.base].toHTML(base);
if (D != null) {this.data[this.base].HTMLstretchV(base,HW,D)}
else if (HW != null) {this.data[this.base].HTMLstretchH(base,HW)}
HTMLCSS.Measured(child,base);
} else {base.bbox = this.HTMLzeroBBox()}
var x_height = HTMLCSS.TeX.x_height * scale,
s = HTMLCSS.TeX.scriptspace * scale * .75; // FIXME: .75 can be removed when IC is right?
@ -51,9 +52,9 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
if (this.data[this.base].data.join("").length === 1 && base.bbox.scale === 1 &&
!this.data[this.base].Get("largeop")) {u = v = 0}
}
var min = this.getValues("subscriptshift","superscriptshift");
min.subscriptshift = (min.subscriptshift === "" ? 0 : HTMLCSS.length2em(min.subscriptshift));
min.superscriptshift = (min.superscriptshift === "" ? 0 : HTMLCSS.length2em(min.superscriptshift));
var min = this.getValues("subscriptshift","superscriptshift"), mu = this.HTMLgetMu(span);
min.subscriptshift = (min.subscriptshift === "" ? 0 : HTMLCSS.length2em(min.subscriptshift,mu));
min.superscriptshift = (min.superscriptshift === "" ? 0 : HTMLCSS.length2em(min.superscriptshift,mu));
var dx = 0;
if (presub) {dx = presub.bbox.w+delta} else if (presup) {dx = presup.bbox.w-delta}

View File

@ -6,7 +6,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var VERSION = "1.1";
var VERSION = "2.0";
var MML = MathJax.ElementJax.mml,
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
@ -44,7 +44,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
return string.replace(/([.*+?|{}()\[\]\\])/g,"\\$1");
}
});
MML.ms.prototype.defaults.fontfamily = 'monospace';
MML.ms.prototype.defaults.mathvariant = 'monospace';
MathJax.Hub.Startup.signal.Post("HTML-CSS ms Ready");
MathJax.Ajax.loadComplete(HTMLCSS.autoloadDir+"/ms.js");

View File

@ -6,7 +6,7 @@
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2011 Design Science, Inc.
* Copyright (c) 2010-2012 Design Science, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var VERSION = "1.1";
var VERSION = "2.0";
var MML = MathJax.ElementJax.mml,
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
@ -36,9 +36,9 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
"align","useHeight","width","side","minlabelspacing");
var hasRelativeWidth = values.width.match(/%$/);
var stack = HTMLCSS.createStack(span);
var scale = this.HTMLgetScale(); var LABEL = -1;
var scale = this.HTMLgetScale(), mu = this.HTMLgetMu(span), LABEL = -1;
var H = [], D = [], W = [], A = [], C = [], i, j, J = -1, m, M, s, row;
var H = [], D = [], W = [], A = [], C = [], i, j, J = -1, m, M, s, row, entries = [];
var LHD = HTMLCSS.FONTDATA.baselineskip * scale * values.useHeight,
LH = HTMLCSS.FONTDATA.lineH * scale, LD = HTMLCSS.FONTDATA.lineD * scale;
@ -55,7 +55,13 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
W[j] = -HTMLCSS.BIGDIMEN;
}
A[i][j] = HTMLCSS.createBox(C[j]);
HTMLCSS.Measured(row.data[j-s].toHTML(A[i][j]),A[i][j]);
entries.push(row.data[j-s].toHTML(A[i][j]));
}
}
HTMLCSS.MeasureSpans(entries);
for (i = 0, m = this.data.length; i < m; i++) {
row = this.data[i]; s = (row.type === "mlabeledtr" ? LABEL : 0);
for (j = s, M = row.data.length + s; j < M; j++) {
if (row.data[j-s].isMultiline) {A[i][j].style.width = "100%"}
if (A[i][j].bbox.h > H[i]) {H[i] = A[i][j].bbox.h}
if (A[i][j].bbox.d > D[i]) {D[i] = A[i][j].bbox.d}
@ -76,8 +82,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
RLINES = values.rowlines.split(/ /),
CWIDTH = values.columnwidth.split(/ /),
RCALIGN = [];
for (i = 0, m = CSPACE.length; i < m; i++) {CSPACE[i] = HTMLCSS.length2em(CSPACE[i])}
for (i = 0, m = RSPACE.length; i < m; i++) {RSPACE[i] = HTMLCSS.length2em(RSPACE[i])}
for (i = 0, m = CSPACE.length; i < m; i++) {CSPACE[i] = HTMLCSS.length2em(CSPACE[i],mu)}
for (i = 0, m = RSPACE.length; i < m; i++) {RSPACE[i] = HTMLCSS.length2em(RSPACE[i],mu)}
while (CSPACE.length < J) {CSPACE.push(CSPACE[CSPACE.length-1])}
while (CALIGN.length <= J) {CALIGN.push(CALIGN[CALIGN.length-1])}
while (CLINES.length < J) {CLINES.push(CLINES[CLINES.length-1])}
@ -101,6 +107,16 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
}
}
//
// Handle equal heights
//
if (values.equalrows) {
// FIXME: should really be based on row align (below is for baseline)
var Hm = Math.max.apply(Math,H), Dm = Math.max.apply(Math,D);
for (i = 0, m = A.length; i < m; i++)
{s = ((Hm + Dm) - (H[i] + D[i])) / 2; H[i] += s; D[i] += s}
}
// FIXME: do background colors for entire cell (include half the intercolumn space?)
//
@ -114,18 +130,30 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var fx = 0, fy = 0, fW, fH = HD;
if (values.frame !== "none" ||
(values.columnlines+values.rowlines).match(/solid|dashed/)) {
fx = HTMLCSS.length2em(values.framespacing.split(/[, ]+/)[0]);
fy = HTMLCSS.length2em(values.framespacing.split(/[, ]+/)[1]);
fx = HTMLCSS.length2em(values.framespacing.split(/[, ]+/)[0],mu);
fy = HTMLCSS.length2em(values.framespacing.split(/[, ]+/)[1],mu);
fH = HD + 2*fy; // fW waits until stack.bbox.w is determined
}
//
// Compute alignment
//
var Y, fY;
if (String(values.align).match(/^\d+$/)) {
// FIXME: do row-based alignment
Y = HD/2 + HTMLCSS.TeX.axis_height*scale - H[0];
fY = -(HD/2 + fy);
var Y, fY, n = "";
if (typeof(values.align) !== "string") {values.align = String(values.align)}
if (values.align.match(/(top|bottom|center|baseline|axis)( +(-?\d+))?/))
{n = RegExp.$3; values.align = RegExp.$1} else {values.align = this.defaults.align}
if (n !== "") {
//
// Find the height of the given row
//
n = parseInt(n);
if (n < 0) {n = A.length + 1 + n}
if (n < 1) {n = 1} else if (n > A.length) {n = A.length}
Y = 0; fY = -(HD + fy) + H[0];
for (i = 0, m = n-1; i < m; i++) {
// FIXME: Should handle values.align for final row
var dY = Math.max((H[i]+D[i] ? LHD : 0),D[i]+H[i+1]+RSPACE[i]);
Y += dY; fY += dY;
}
} else {
Y = ({
top: -(H[0] + fy),
@ -158,7 +186,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
for (i = 0, m = Math.min(J+1,CSPACE.length); i < m; i++) {WW += CSPACE[i]}
} else {
// Get total width minus column spacing
WW = HTMLCSS.length2em(values.width);
WW = HTMLCSS.length2em(values.width,mu);
for (i = 0, m = Math.min(J+1,CSPACE.length); i < m; i++) {WW -= CSPACE[i]}
// Determine individual column widths
WW /= J+1;
@ -174,8 +202,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
if (CWIDTH[i] === "auto") {Wt += W[i]}
else if (CWIDTH[i] === "fit") {F[f] = i; f++; Wt += W[i]}
else if (CWIDTH[i].match(/%$/))
{P[p] = i; p++; Wp += W[i]; WP += HTMLCSS.length2em(CWIDTH[i],1)}
else {W[i] = HTMLCSS.length2em(CWIDTH[i]); Wt += W[i]}
{P[p] = i; p++; Wp += W[i]; WP += HTMLCSS.length2em(CWIDTH[i],mu,1)}
else {W[i] = HTMLCSS.length2em(CWIDTH[i],mu); Wt += W[i]}
}
if (hasRelativeWidth) {
// Get separation width and check percentages
@ -186,12 +214,12 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
if (values.width === "auto") {
if (WP > .98) {Wf = Wp/(Wt+Wp); WW = Wt + Wp} else {WW = Wt / (1-WP)}
} else {
WW = HTMLCSS.length2em(values.width);
WW = HTMLCSS.length2em(values.width,mu);
for (i = 0, m = Math.min(J+1,CSPACE.length); i < m; i++) {WW -= CSPACE[i]}
}
// Determine the relative column widths
for (i = 0, m = P.length; i < m; i++) {
W[P[i]] = HTMLCSS.length2em(CWIDTH[P[i]],WW*Wf); Wt += W[P[i]];
W[P[i]] = HTMLCSS.length2em(CWIDTH[P[i]],mu,WW*Wf); Wt += W[P[i]];
}
// Stretch fit columns, if any, otherwise stretch (or shrink) everything
if (Math.abs(WW - Wt) > .01) {
@ -208,15 +236,6 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
}
}
}
//
// Handle equal heights
//
if (values.equalrows) {
// FIXME: should really be based on row align (below is for baseline)
var Hm = Math.max.apply(Math,H), Dm = Math.max.apply(Math,D);
for (i = 0, m = A.length; i < m; i++)
{s = ((Hm + Dm) - (H[i] + D[i])) / 2; H[i] += s; D[i] += s}
}
//
// Lay out array columns
@ -335,11 +354,13 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
}
}
}
stack.bbox.d = -fY; stack.bbox.h = fH+fY;
HTMLCSS.setStackWidth(stack,stack.bbox.w + fx);
//
// Add frame
//
fW = stack.bbox.w + fx; var frame;
fW = stack.bbox.w; var frame;
if (values.frame !== "none") {
frame = HTMLCSS.createFrame(stack,fH,0,fW,1.25/HTMLCSS.em,values.frame);
HTMLCSS.addBox(stack,frame); HTMLCSS.placeBox(frame,0,fY,true);
@ -379,15 +400,14 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var eqn = HTMLCSS.createStack(span,false,"100%");
HTMLCSS.addBox(eqn,stack); HTMLCSS.alignBox(stack,indent.indentalign,0);
if (indent.indentshift && indent.indentalign !== MML.INDENTALIGN.CENTER) {
stack.style[{left:"Left",right:"Right"}[indent.indentalign]] =
HTMLCSS.Em(HTMLCSS.length2em(indent.indentshift));
stack.style[indent.indentalign] = HTMLCSS.Em(HTMLCSS.length2em(indent.indentshift,mu));
}
C[LABEL].parentNode.parentNode.removeChild(C[LABEL].parentNode);
HTMLCSS.addBox(eqn,C[LABEL]); HTMLCSS.alignBox(C[LABEL],CALIGN[LABEL],0);
if (HTMLCSS.msieRelativeWidthBug) {stack.style.top = C[LABEL].style.top = ""}
if (hasRelativeWidth) {stack.style.width = values.width; span.bbox.width = "100%"}
C[LABEL].style.marginRight = C[LABEL].style.marginLeft =
HTMLCSS.Em(HTMLCSS.length2em(values.minlabelspacing));
HTMLCSS.Em(HTMLCSS.length2em(values.minlabelspacing,mu));
}
//
// Finish the table
@ -410,7 +430,9 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
return span;
},
HTMLhandleSpace: function (span) {
span.style.paddingLeft = span.style.paddingRight = ".1667em";
span.bbox.keepPadding = true; span.bbox.exact = true;
if (!this.hasFrame) {span.style.paddingLeft = span.style.paddingRight = ".1667em"}
this.SUPER(arguments).HTMLhandleSpace.call(this,span);
}
});
@ -418,9 +440,9 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
toHTML: function (span,HW,D) {
span = this.HTMLcreateSpan(span);
if (this.data[0]) {
var box = HTMLCSS.Measured(this.data[0].toHTML(span),span);
if (D != null) {HTMLCSS.Remeasured(this.data[0].HTMLstretchV(span,HW,D),span)}
else if (HW != null) {HTMLCSS.Remeasured(this.data[0].HTMLstretchH(span,HW),span)}
var box = this.data[0].toHTML(span);
if (D != null) {box = this.data[0].HTMLstretchV(span,HW,D)}
else if (HW != null) {box = this.data[0].HTMLstretchH(span,HW)}
span.bbox = box.bbox;
}
this.HTMLhandleSpace(span);

Some files were not shown because too many files have changed in this diff Show More