E-book viewer: Fix some non-ASCII characters not display in embedded MathML. Fixes #1532323 [Some non-ASCII characters in MathML elements don't render correctly](https://bugs.launchpad.net/calibre/+bug/1532323)

All that was needed was to update MathJax to the latest release 2.6.0
This commit is contained in:
Kovid Goyal 2016-01-09 09:21:20 +05:30
parent a82ff8b749
commit d9a5a328e2
201 changed files with 10194 additions and 2678 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,151 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*************************************************************
*
* MathJax/extensions/AssistiveMML.js
*
* Implements an extension that inserts hidden MathML into the
* page for screen readers or other asistive technology.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2015 The MathJax Consortium
*
* 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 (AJAX,CALLBACK,HUB,HTML) {
var SETTINGS = HUB.config.menuSettings;
var AssistiveMML = MathJax.Extension["AssistiveMML"] = {
version: "2.6.0",
config: {
disabled: false,
styles: {
".MJX_Assistive_MathML": {
position:"absolute!important",
top: 0, left: 0,
clip: (HUB.Browser.isMSIE && (document.documentMode||0) < 8 ?
"rect(1px 1px 1px 1px)" : "rect(1px, 1px, 1px, 1px)"),
padding: "1px 0 0 0!important",
border: "0!important",
height: "1px!important",
width: "1px!important",
overflow: "hidden!important",
display:"block!important"
},
".MJX_Assistive_MathML.MJX_Assistive_MathML_Block": {
width: "100%!important"
}
}
},
Config: function () {
if (!this.config.disabled && SETTINGS.assistiveMML == null)
HUB.Config({menuSettings:{assistiveMML:true}});
AJAX.Styles(this.config.styles);
HUB.Register.MessageHook("End Math",function (msg) {
if (SETTINGS.assistiveMML) return AssistiveMML.AddAssistiveMathML(msg[1])
});
},
//
// This sets up a state object that lists the jax and index into the jax,
// and a dummy callback that is used to synchronizing with MathJax.
// It will be called when the jax are all processed, and that will
// let the MathJax queue continue (it will block until then).
//
AddAssistiveMathML: function (node) {
var state = {
jax: HUB.getAllJax(node), i: 0,
callback: MathJax.Callback({})
};
this.HandleMML(state);
return state.callback;
},
//
// This removes the data-mathml attribute and the assistive MathML from
// all the jax.
//
RemoveAssistiveMathML: function (node) {
var jax = HUB.getAllJax(node), frame;
for (var i = 0, m = jax.length; i < m; i++) {
frame = document.getElementById(jax[i].inputID+"-Frame");
if (frame && frame.getAttribute("data-mathml")) {
frame.removeAttribute("data-mathml");
if (frame.lastChild && frame.lastChild.className.match(/MJX_Assistive_MathML/))
frame.removeChild(frame.lastChild);
}
}
},
//
// For each jax in the state, look up the frame.
// If the jax doesn't use NativeMML and hasn't already been handled:
// Get the MathML for the jax, taking resets into account.
// Add a data-mathml attribute to the frame, and
// Create a span that is not visible on screen and put the MathML in it,
// and add it to the frame.
// When all the jax are processed, call the callback.
//
HandleMML: function (state) {
var m = state.jax.length, jax, mml, frame, span;
while (state.i < m) {
jax = state.jax[state.i];
frame = document.getElementById(jax.inputID+"-Frame");
if (jax.outputJax !== "NativeMML" && frame && !frame.getAttribute("data-mathml")) {
try {
mml = jax.root.toMathML("").replace(/\n */g,"").replace(/<!--.*?-->/g,"");
} catch (err) {
if (!err.restart) throw err; // an actual error
return MathJax.Callback.After(["HandleMML",this,state],err.restart);
}
frame.setAttribute("data-mathml",mml);
span = HTML.addElement(frame,"span",{
isMathJax: true,
className: "MJX_Assistive_MathML"
+ (jax.root.Get("display") === "block" ? " MJX_Assistive_MathML_Block" : "")
});
span.innerHTML = mml;
frame.style.position = "relative";
frame.setAttribute("role","presentation");
frame.firstChild.setAttribute("aria-hidden","true");
span.setAttribute("role","presentation");
}
state.i++;
}
state.callback();
}
};
HUB.Startup.signal.Post("AssistiveMML Ready");
})(MathJax.Ajax,MathJax.Callback,MathJax.Hub,MathJax.HTML);
//
// Make sure the toMathML extension is loaded before we signal
// the load complete for this extension. Then wait for the end
// of the user configuration before configuring this extension.
//
MathJax.Callback.Queue(
["Require",MathJax.Ajax,"[MathJax]/extensions/toMathML.js"],
["loadComplete",MathJax.Ajax,"[MathJax]/extensions/AssistiveMML.js"],
function () {
MathJax.Hub.Register.StartupHook("End Config",["Config",MathJax.Extension.AssistiveMML]);
}
);

View File

@ -0,0 +1,30 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*************************************************************
*
* MathJax/extensions/CHTML-preview.js
*
* Backward compatibility with old CHTML-preview extension.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2014-2015 The MathJax Consortium
*
* 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.Callback.Queue(
["Require",MathJax.Ajax,"[MathJax]/extensions/fast-preview.js"],
["loadComplete",MathJax.Ajax,"[MathJax]/extensions/CHTML-preview.js"]
);

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/FontWarnings.js * MathJax/extensions/FontWarnings.js
@ -67,7 +70,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2010-2012 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -83,7 +86,10 @@
*/ */
(function (HUB,HTML) { (function (HUB,HTML) {
var VERSION = "2.0"; var VERSION = "2.6.0";
var STIXURL = "http://www.stixfonts.org/";
var MATHJAXURL = "https://github.com/mathjax/MathJax/tree/master/fonts/HTML-CSS/TeX/otf";
var CONFIG = HUB.CombineConfig("FontWarnings",{ var CONFIG = HUB.CombineConfig("FontWarnings",{
// //
@ -110,33 +116,37 @@
// The messages for the various situations // The messages for the various situations
// //
Message: { Message: {
webFont: [ webFont: [
["closeBox"], ["closeBox"],
"MathJax is using web-based fonts to display the mathematics ", ["webFont",
"on this page. These take time to download, so the page would ", "MathJax is using web-based fonts to display the mathematics "+
"render faster if you installed math fonts directly in your ", "on this page. These take time to download, so the page would "+
"system's font folder.", "render faster if you installed math fonts directly in your "+
"system's font folder."],
["fonts"] ["fonts"]
], ],
imageFonts: [ imageFonts: [
["closeBox"], ["closeBox"],
"MathJax is using its image fonts rather than local or web-based fonts. ", ["imageFonts",
"This will render slower than usual, and the mathematics may not print ", "MathJax is using its image fonts rather than local or web-based fonts. "+
"at the full resolution of your printer.", "This will render slower than usual, and the mathematics may not print "+
"at the full resolution of your printer."],
["fonts"], ["fonts"],
["webfonts"] ["webFonts"]
], ],
noFonts: [ noFonts: [
["closeBox"], ["closeBox"],
"MathJax is unable to locate a font to use to display ", ["noFonts",
"its mathematics, and image fonts are not available, so it ", "MathJax is unable to locate a font to use to display "+
"is falling back on generic unicode characters in hopes that ", "its mathematics, and image fonts are not available, so it "+
"your browser will be able to display them. Some characters ", "is falling back on generic unicode characters in hopes that "+
"may not show up properly, or possibly not at all.", "your browser will be able to display them. Some characters "+
"may not show up properly, or possibly not at all."],
["fonts"], ["fonts"],
["webfonts"] ["webFonts"]
] ]
}, },
@ -168,34 +178,40 @@
[["span",{style:{position:"relative", bottom:".2em"}},["x"]]] [["span",{style:{position:"relative", bottom:".2em"}},["x"]]]
]], ]],
webfonts: [ webFonts: [
["p"], ["p"],
"Most modern browsers allow for fonts to be downloaded over the web. ", ["webFonts",
"Updating to a more recent version of your browser (or changing browsers) ", "Most modern browsers allow for fonts to be downloaded over the web. "+
"could improve the quality of the mathematics on this page." "Updating to a more recent version of your browser (or changing "+
"browsers) could improve the quality of the mathematics on this page."
]
], ],
fonts: [ fonts: [
["p"], ["p"],
"MathJax can use either the ", ["fonts",
["a",{href:"http://www.stixfonts.org/",target:"_blank"},"STIX fonts"], "MathJax can use either the [STIX fonts](%1) or the [MathJax TeX fonts](%2). " +
" or the ", "Download and install one of those fonts to improve your MathJax experience.",
["a",{href:"http://www.mathjax.org/help-v2/fonts/",target:"_blank"},["MathJax TeX fonts"]], STIXURL,MATHJAXURL
". Download and install either one to improve your MathJax experience." ]
], ],
STIXfonts: [ STIXfonts: [
["p"], ["p"],
"This page is designed to use the ", ["STIXPage",
["a",{href:"http://www.stixfonts.org/",target:"_blank"},"STIX fonts"], "This page is designed to use the [STIX fonts](%1). " +
". Download and install those fonts to improve your MathJax experience." "Download and install those fonts to improve your MathJax experience.",
STIXURL
]
], ],
TeXfonts: [ TeXfonts: [
["p"], ["p"],
"This page is designed to use the ", ["TeXPage",
["a",{href:"http://www.mathjax.org/help-v2/fonts/",target:"_blank"},["MathJax TeX fonts"]], "This page is designed to use the [MathJax TeX fonts](%1). " +
". Download and install those fonts to improve your MathJax experience." "Download and install those fonts to improve your MathJax experience.",
MATHJAXURL
]
] ]
}, },
@ -225,16 +241,26 @@
if (HUB.Browser.isMSIE) { if (HUB.Browser.isMSIE) {
if (CONFIG.messageStyle.position === "fixed") { if (CONFIG.messageStyle.position === "fixed") {
MathJax.Message.Init(); // make sure MathJax_MSIE_frame exists MathJax.Message.Init(); // make sure MathJax_MSIE_frame exists
frame = document.getElementById("MathJax_MSIE_Frame"); frame = document.getElementById("MathJax_MSIE_Frame") || frame;
CONFIG.messageStyle.position = "absolute"; if (frame !== document.body) {CONFIG.messageStyle.position = "absolute"}
} }
} else {delete CONFIG.messageStyle.filter} } else {delete CONFIG.messageStyle.filter}
CONFIG.messageStyle.maxWidth = (document.body.clientWidth-75) + "px"; CONFIG.messageStyle.maxWidth = (document.body.clientWidth-75) + "px";
var i = 0; while (i < data.length) { var i = 0; while (i < data.length) {
if (data[i] instanceof Array && CONFIG.HTML[data[i][0]]) if (data[i] instanceof Array) {
{data.splice.apply(data,[i,1].concat(CONFIG.HTML[data[i][0]]))} else {i++} if (data[i].length === 1 && CONFIG.HTML[data[i][0]]) {
data.splice.apply(data,[i,1].concat(CONFIG.HTML[data[i][0]]));
} else if (typeof data[i][1] === "string") {
var message = MathJax.Localization.lookupPhrase(["FontWarnings",data[i][0]],data[i][1]);
message = MathJax.Localization.processMarkdown(message,data[i].slice(2),"FontWarnings");
data.splice.apply(data,[i,1].concat(message));
i += message.length;
} else {i++}
} else {i++}
} }
DATA.div = HTMLCSS.addElement(frame,"div",{id:"MathJax_FontWarning",style:CONFIG.messageStyle},data); DATA.div = HTMLCSS.addElement(frame,"div",
{id:"MathJax_FontWarning",style:CONFIG.messageStyle},data);
MathJax.Localization.setCSS(DATA.div);
if (CONFIG.removeAfter) { if (CONFIG.removeAfter) {
HUB.Register.StartupHook("End",function () HUB.Register.StartupHook("End",function ()
{DATA.timer = setTimeout(FADEOUT,CONFIG.removeAfter)}); {DATA.timer = setTimeout(FADEOUT,CONFIG.removeAfter)});
@ -276,7 +302,8 @@
if (message.match(/- Web-Font/)) {if (localFonts) {MSG = "webFont"}} if (message.match(/- Web-Font/)) {if (localFonts) {MSG = "webFont"}}
else if (message.match(/- using image fonts/)) {MSG = "imageFonts"} else if (message.match(/- using image fonts/)) {MSG = "imageFonts"}
else if (message.match(/- no valid font/)) {MSG = "noFonts"} else if (message.match(/- no valid font/)) {MSG = "noFonts"}
if (MSG && CONFIG.Message[MSG]) {CREATEMESSAGE(CONFIG.Message[MSG])} if (MSG && CONFIG.Message[MSG])
{MathJax.Localization.loadDomain("FontWarnings",[CREATEMESSAGE,CONFIG.Message[MSG]])}
} }
}); });
} }

View File

@ -0,0 +1,82 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*************************************************************
*
* 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-2015 The MathJax Consortium
*
* 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.6.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.apply(this,arguments);
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");

View File

@ -0,0 +1,203 @@
/*************************************************************
*
* MathJax/extensions/HelpDialog.js
*
* Implements the MathJax Help dialog box.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2013-2015 The MathJax Consortium
*
* 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,OUTPUT,LOCALE) {
var HELP = MathJax.Extension.Help = {
version: "2.6.0"
};
var STIXURL = "http://www.stixfonts.org/";
var MENU = MathJax.Menu;
var FALSE, KEY;
HUB.Register.StartupHook("MathEvents Ready",function () {
FALSE = MathJax.Extension.MathEvents.Event.False;
KEY = MathJax.Extension.MathEvents.Event.KEY;
});
var CONFIG = HUB.CombineConfig("HelpDialog",{
styles: {
"#MathJax_Help": {
position:"fixed", left:"50%", width:"auto", "max-width": "90%", "text-align":"center",
border:"3px outset", padding:"1em 2em", "background-color":"#DDDDDD", color:"black",
cursor: "default", "font-family":"message-box", "font-size":"120%",
"font-style":"normal", "text-indent":0, "text-transform":"none",
"line-height":"normal", "letter-spacing":"normal", "word-spacing":"normal",
"word-wrap":"normal", "white-space":"wrap", "float":"none", "z-index":201,
"border-radius": "15px", // Opera 10.5 and IE9
"-webkit-border-radius": "15px", // Safari and Chrome
"-moz-border-radius": "15px", // Firefox
"-khtml-border-radius": "15px", // Konqueror
"box-shadow":"0px 10px 20px #808080", // Opera 10.5 and IE9
"-webkit-box-shadow":"0px 10px 20px #808080", // Safari 3 and Chrome
"-moz-box-shadow":"0px 10px 20px #808080", // Forefox 3.5
"-khtml-box-shadow":"0px 10px 20px #808080", // Konqueror
filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')" // IE
},
"#MathJax_Help.MathJax_MousePost": {
outline:"none"
},
"#MathJax_HelpContent": {
overflow:"auto", "text-align":"left", "font-size":"80%",
padding:".4em .6em", border:"1px inset", margin:"1em 0px",
"max-height":"20em", "max-width":"30em", "background-color":"#EEEEEE"
},
"#MathJax_HelpClose": {
position:"absolute", top:".2em", right:".2em",
cursor:"pointer",
display:"inline-block",
border:"2px solid #AAA",
"border-radius":"18px",
"-webkit-border-radius": "18px", // Safari and Chrome
"-moz-border-radius": "18px", // Firefox
"-khtml-border-radius": "18px", // Konqueror
"font-family":"'Courier New',Courier",
"font-size":"24px",
color:"#F0F0F0"
},
"#MathJax_HelpClose span": {
display:"block", "background-color":"#AAA", border:"1.5px solid",
"border-radius":"18px",
"-webkit-border-radius": "18px", // Safari and Chrome
"-moz-border-radius": "18px", // Firefox
"-khtml-border-radius": "18px", // Konqueror
"line-height":0,
padding:"8px 0 6px" // may need to be browser-specific
},
"#MathJax_HelpClose:hover": {
color:"white!important",
border:"2px solid #CCC!important"
},
"#MathJax_HelpClose:hover span": {
"background-color":"#CCC!important"
},
"#MathJax_HelpClose:hover:focus": {
outline:"none"
}
}
});
/*
* Handle the Help Dialog box
*/
HELP.Dialog = function (event) {
LOCALE.loadDomain("HelpDialog",["Post",HELP,event]);
};
HELP.Post = function (event) {
this.div = MENU.Background(this);
var help = HTML.addElement(this.div,"div",{
id: "MathJax_Help", tabIndex: 0, onkeydown: HELP.Keydown
},LOCALE._("HelpDialog",[
["b",{style:{fontSize:"120%"}},[["Help","MathJax Help"]]],
["div",{id: "MathJax_HelpContent", tabIndex: 0},[
["p",{},[["MathJax",
"*MathJax* is a JavaScript library that allows page authors to include " +
"mathematics within their web pages. As a reader, you don't need to do " +
"anything to make that happen."]]
],
["p",{},[["Browsers",
"*Browsers*: MathJax works with all modern browsers including IE6+, Firefox 3+, " +
"Chrome 0.2+, Safari 2+, Opera 9.6+ and most mobile browsers."]]
],
["p",{},[["Menu",
"*Math Menu*: MathJax adds a contextual menu to equations. Right-click or " +
"CTRL-click on any mathematics to access the menu."]]
],
["div",{style:{"margin-left":"1em"}},[
["p",{},[["ShowMath",
"*Show Math As* allows you to view the formula's source markup " +
"for copy & paste (as MathML or in its original format)."]]
],
["p",{},[["Settings",
"*Settings* gives you control over features of MathJax, such as the " +
"size of the mathematics, and the mechanism used to display equations."]]
],
["p",{},[["Language",
"*Language* lets you select the language used by MathJax for its menus " +
"and warning messages."]]
],
]],
["p",{},[["Zoom",
"*Math Zoom*: If you are having difficulty reading an equation, MathJax can " +
"enlarge it to help you see it better."]]
],
["p",{},[["Accessibilty",
"*Accessibility*: MathJax will automatically work with screen readers to make " +
"mathematics accessible to the visually impaired."]]
],
["p",{},[["Fonts",
"*Fonts*: MathJax will use certain math fonts if they are installed on your " +
"computer; otherwise, it will use web-based fonts. Although not required, " +
"locally installed fonts will speed up typesetting. We suggest installing " +
"the [STIX fonts](%1).",STIXURL]]
]
]],
["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]],
["span",{id: "MathJax_HelpClose", onclick: HELP.Remove,
onkeydown: HELP.Keydown, tabIndex: 0, role: "button",
"aria-label": LOCALE._(["HelpDialog","CloseDialog"],"Close help dialog")},
[["span",{},["\u00D7"]]]
]
]));
if (event.type === "mouseup") help.className += " MathJax_MousePost";
help.focus();
LOCALE.setCSS(help);
var doc = (document.documentElement||{});
var H = window.innerHeight || doc.clientHeight || doc.scrollHeight || 0;
if (MENU.prototype.msieAboutBug) {
help.style.width = "20em"; help.style.position = "absolute";
help.style.left = Math.floor((document.documentElement.scrollWidth - help.offsetWidth)/2)+"px";
help.style.top = (Math.floor((H-help.offsetHeight)/3)+document.body.scrollTop)+"px";
} else {
help.style.marginLeft = Math.floor(-help.offsetWidth/2)+"px";
help.style.top = Math.floor((H-help.offsetHeight)/3)+"px";
}
};
HELP.Remove = function (event) {
if (HELP.div) {document.body.removeChild(HELP.div); delete HELP.div}
};
HELP.Keydown = function(event) {
if (event.keyCode === KEY.ESCAPE ||
(this.id === "MathJax_HelpClose" &&
(event.keyCode === KEY.SPACE || event.keyCode === KEY.RETURN))) {
HELP.Remove(event);
MENU.CurrentNode().focus();
FALSE(event);
}
},
MathJax.Callback.Queue(
HUB.Register.StartupHook("End Config",{}), // wait until config is complete
["Styles",AJAX,CONFIG.styles],
["Post",HUB.Startup.signal,"HelpDialig Ready"],
["loadComplete",AJAX,"[MathJax]/extensions/HelpDialog.js"]
);
})(MathJax.Hub,MathJax.HTML,MathJax.Ajax,MathJax.OutputJax,MathJax.Localization);

View File

@ -0,0 +1,309 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*************************************************************
*
* MathJax/extensions/MatchWebFonts.js
*
* Adds code to the output jax so that if web fonts are used on the page,
* MathJax will be able to detect their arrival and update the math to
* accommodate the change in font. For the NativeMML output, this works
* both for web fonts in main text, and for web fonts in the math as well.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2013-2015 The MathJax Consortium
*
* 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,AJAX) {
var VERSION = "2.6.0";
var CONFIG = MathJax.Hub.CombineConfig("MatchWebFonts",{
matchFor: {
"HTML-CSS": true,
NativeMML: true,
SVG: true
},
fontCheckDelay: 500, // initial delay for the first check for web fonts
fontCheckTimeout: 15 * 1000, // how long to keep looking for fonts (15 seconds)
});
MathJax.Extension.MatchWebFonts = {
version: VERSION,
config: CONFIG
};
HUB.Register.StartupHook("HTML-CSS Jax Ready",function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"];
var POSTTRANSLATE = HTMLCSS.postTranslate;
HTMLCSS.Augment({
postTranslate: function (state,partial) {
if (!partial && CONFIG.matchFor["HTML-CSS"] && this.config.matchFontHeight) {
//
// Check for changes in the web fonts that might affect the font
// size for math elements. This is a periodic check that goes on
// until a timeout is reached.
//
AJAX.timer.start(AJAX,["checkFonts",this,state.jax[this.id]],
CONFIG.fontCheckDelay,CONFIG.fontCheckTimeout);
}
return POSTTRANSLATE.apply(this,arguments); // do the original function
},
checkFonts: function (check,scripts) {
if (check.time(function () {})) return;
var size = [], i, m, retry = false;
//
// Add the elements used for testing ex and em sizes
//
for (i = 0, m = scripts.length; i < m; i++) {
script = scripts[i];
if (script.parentNode && script.MathJax.elementJax) {
script.parentNode.insertBefore(this.EmExSpan.cloneNode(true),script);
}
}
//
// Check to see if anything has changed
//
for (i = 0, m = scripts.length; i < m; i++) {
script = scripts[i]; if (!script.parentNode) continue; retry = true;
var jax = script.MathJax.elementJax; if (!jax) continue;
//
// Check if ex or mex has changed
//
var test = script.previousSibling;
var ex = test.firstChild.offsetHeight/60;
var em = test.lastChild.lastChild.offsetHeight/60;
if (ex === 0 || ex === "NaN") {ex = this.defaultEx; em = this.defaultEm}
if (ex !== jax.HTMLCSS.ex || em !== jax.HTMLCSS.em) {
var scale = ex/this.TeX.x_height/em;
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale)*this.config.scale);
if (scale/100 !== jax.scale) {size.push(script); scripts[i] = {}}
}
}
//
// Remove markers
//
scripts = scripts.concat(size); // some scripts have been moved to the size array
for (i = 0, m = scripts.length; i < m; i++) {
script = scripts[i];
if (script && script.parentNode && script.MathJax.elementJax) {
script.parentNode.removeChild(script.previousSibling);
}
}
//
// Rerender the changed items
//
if (size.length) {HUB.Queue(["Rerender",HUB,[size],{}])}
//
// Try again later
//
if (retry) {setTimeout(check,check.delay)}
}
});
});
HUB.Register.StartupHook("SVG Jax Ready",function () {
var SVG = MathJax.OutputJax.SVG;
var POSTTRANSLATE = SVG.postTranslate;
SVG.Augment({
postTranslate: function (state,partial) {
if (!partial && CONFIG.matchFor.SVG) {
//
// Check for changes in the web fonts that might affect the font
// size for math elements. This is a periodic check that goes on
// until a timeout is reached.
//
AJAX.timer.start(AJAX,["checkFonts",this,state.jax[this.id]],
CONFIG.fontCheckDelay,CONFIG.fontCheckTimeout);
}
return POSTTRANSLATE.apply(this,arguments); // do the original function
},
checkFonts: function (check,scripts) {
if (check.time(function () {})) return;
var size = [], i, m, retry = false;
//
// Add the elements used for testing ex and em sizes
//
for (i = 0, m = scripts.length; i < m; i++) {
script = scripts[i];
if (script.parentNode && script.MathJax.elementJax) {
script.parentNode.insertBefore(this.ExSpan.cloneNode(true),script);
}
}
//
// Check to see if anything has changed
//
for (i = 0, m = scripts.length; i < m; i++) {
script = scripts[i]; if (!script.parentNode) continue; retry = true;
var jax = script.MathJax.elementJax; if (!jax) continue;
//
// Check if ex or mex has changed
//
var test = script.previousSibling;
var ex = test.firstChild.offsetHeight/60;
if (ex === 0 || ex === "NaN") {ex = this.defaultEx}
if (ex !== jax.SVG.ex) {size.push(script); scripts[i] = {}}
}
//
// Remove markers
//
scripts = scripts.concat(size); // some scripts have been moved to the size array
for (i = 0, m = scripts.length; i < m; i++) {
script = scripts[i];
if (script.parentNode && script.MathJax.elementJax) {
script.parentNode.removeChild(script.previousSibling);
}
}
//
// Rerender the changed items
//
if (size.length) {HUB.Queue(["Rerender",HUB,[size],{}])}
//
// Try again later (if not all the scripts are null)
//
if (retry) setTimeout(check,check.delay);
}
});
});
HUB.Register.StartupHook("NativeMML Jax Ready",function () {
var nMML = MathJax.OutputJax.NativeMML;
var POSTTRANSLATE = nMML.postTranslate;
nMML.Augment({
postTranslate: function (state) {
if (!HUB.Browser.isMSIE && CONFIG.matchFor.NativeMML) {
//
// Check for changes in the web fonts that might affect the sizes
// of math elements. This is a periodic check that goes on until
// a timeout is reached.
//
AJAX.timer.start(AJAX,["checkFonts",this,state.jax[this.id]],
CONFIG.fontCheckDelay,CONFIG.fontCheckTimeout);
}
POSTTRANSLATE.apply(this,arguments); // do the original routine
},
//
// Check to see if web fonts have been loaded that change the ex size
// of the surrounding font, the ex size within the math, or the widths
// of math elements. We do this by rechecking the ex and mex sizes
// (to see if the font scaling needs adjusting) and by checking the
// size of the inner mrow of math elements and mtd elements. The
// sizes of these have been stored in the NativeMML object of the
// element jax so that we can check for them here.
//
checkFonts: function (check,scripts) {
if (check.time(function () {})) return;
var adjust = [], mtd = [], size = [], i, m, script;
//
// Add the elements used for testing ex and em sizes
//
for (i = 0, m = scripts.length; i < m; i++) {
script = scripts[i];
if (script.parentNode && script.MathJax.elementJax) {
script.parentNode.insertBefore(this.EmExSpan.cloneNode(true),script);
}
}
//
// Check to see if anything has changed
//
for (i = 0, m = scripts.length; i < m; i++) {
script = scripts[i]; if (!script.parentNode) continue;
var jax = script.MathJax.elementJax; if (!jax) continue;
var span = document.getElementById(jax.inputID+"-Frame");
var math = span.getElementsByTagName("math")[0]; if (!math) continue;
jax = jax.NativeMML;
//
// Check if ex or mex has changed
//
var test = script.previousSibling;
var ex = test.firstChild.offsetWidth/60;
var mex = test.lastChild.offsetWidth/60;
if (ex === 0 || ex === "NaN") {ex = this.defaultEx; mex = this.defaultMEx}
var newEx = (ex !== jax.ex);
if (newEx || mex != jax.mex) {
var scale = (this.config.matchFontHeight && mex > 1 ? ex/mex : 1);
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale) * this.config.scale);
if (scale/100 !== jax.scale) {size.push([span.style,scale])}
jax.scale = scale/100; jax.fontScale = scale+"%"; jax.ex = ex; jax.mex = mex;
}
//
// Check width of math elements
//
if ("scrollWidth" in jax && (newEx || jax.scrollWidth !== math.firstChild.scrollWidth)) {
jax.scrollWidth = math.firstChild.scrollWidth;
adjust.push([math.parentNode.style,jax.scrollWidth/jax.ex/jax.scale]);
}
//
// Check widths of mtd elements
//
if (math.MathJaxMtds) {
for (var j = 0, n = math.MathJaxMtds.length; j < n; j++) {
if (!math.MathJaxMtds[j].parentNode) continue;
if (newEx || math.MathJaxMtds[j].firstChild.scrollWidth !== jax.mtds[j]) {
jax.mtds[j] = math.MathJaxMtds[j].firstChild.scrollWidth;
mtd.push([math.MathJaxMtds[j],jax.mtds[j]/jax.ex]);
}
}
}
}
//
// Remove markers
//
for (i = 0, m = scripts.length; i < m; i++) {
script = scripts[i];
if (script.parentNode && script.MathJax.elementJax) {
script.parentNode.removeChild(script.previousSibling);
}
}
//
// Adjust scaling factor
//
for (i = 0, m = size.length; i < m; i++) {
size[i][0].fontSize = size[i][1] + "%";
}
//
// Adjust width of spans containing math elements that have changed
//
for (i = 0, m = adjust.length; i < m; i++) {
adjust[i][0].width = adjust[i][1].toFixed(3)+"ex";
}
//
// Adjust widths of mtd elements that have changed
//
for (i = 0, m = mtd.length; i < m; i++) {
var style = mtd[i][0].getAttribute("style");
style = style.replace(/(($|;)\s*min-width:).*?ex/,"$1 "+mtd[i][1].toFixed(3)+"ex");
mtd[i][0].setAttribute("style",style);
}
//
// Try again later
//
setTimeout(check,check.delay);
}
});
});
HUB.Startup.signal.Post("MatchWebFonts Extension Ready");
AJAX.loadComplete("[MathJax]/extensions/MatchWebFonts.js");
})(MathJax.Hub,MathJax.Ajax);

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/MathEvents.js * MathJax/extensions/MathEvents.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,8 +25,8 @@
* limitations under the License. * limitations under the License.
*/ */
(function (HUB,HTML,AJAX,CALLBACK,OUTPUT,INPUT) { (function (HUB,HTML,AJAX,CALLBACK,LOCALE,OUTPUT,INPUT) {
var VERSION = "2.0"; var VERSION = "2.6.0";
var EXTENSION = MathJax.Extension; var EXTENSION = MathJax.Extension;
var ME = EXTENSION.MathEvents = {version: VERSION}; var ME = EXTENSION.MathEvents = {version: VERSION};
@ -40,9 +43,8 @@
hcolor: "#83A" // haze color hcolor: "#83A" // haze color
}, },
button: { button: {
x: -4, y: -3, // menu button offsets x: -6, y: -3, // menu button offsets
wx: -2, // button offset for full-width equations wx: -2 // button offset for full-width equations
src: AJAX.fileURL(OUTPUT.imageDir+"/MenuArrow-15.png") // button image
}, },
fadeinInc: .2, // increment for fade-in fadeinInc: .2, // increment for fade-in
fadeoutInc: .05, // increment for fade-out fadeoutInc: .05, // increment for fade-out
@ -66,10 +68,33 @@
display: "inline-block", position:"absolute" display: "inline-block", position:"absolute"
}, },
".MathJax_Hover_Arrow": { ".MathJax_Menu_Button .MathJax_Hover_Arrow": {
position:"absolute", position:"absolute",
width:"15px", height:"11px", cursor:"pointer",
cursor:"pointer" display:"inline-block",
border:"2px solid #AAA",
"border-radius":"4px",
"-webkit-border-radius": "4px", // Safari and Chrome
"-moz-border-radius": "4px", // Firefox
"-khtml-border-radius": "4px", // Konqueror
"font-family":"'Courier New',Courier",
"font-size":"9px",
color:"#F0F0F0"
},
".MathJax_Menu_Button .MathJax_Hover_Arrow span": {
display:"block",
"background-color":"#AAA",
border:"1px solid",
"border-radius":"3px",
"line-height":0,
padding:"4px"
},
".MathJax_Hover_Arrow:hover": {
color:"white!important",
border:"2px solid #CCC!important"
},
".MathJax_Hover_Arrow:hover span": {
"background-color":"#CCC!important"
} }
} }
}; };
@ -84,6 +109,20 @@
RIGHTBUTTON: 2, // the event.button value for right button RIGHTBUTTON: 2, // the event.button value for right button
MENUKEY: "altKey", // the event value for alternate context menu MENUKEY: "altKey", // the event value for alternate context menu
/*************************************************************/
/*
* Enum element for key codes.
*/
KEY: {
RETURN: 13,
ESCAPE: 27,
SPACE: 32,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40
},
Mousedown: function (event) {return EVENT.Handler(event,"Mousedown",this)}, Mousedown: function (event) {return EVENT.Handler(event,"Mousedown",this)},
Mouseup: function (event) {return EVENT.Handler(event,"Mouseup",this)}, Mouseup: function (event) {return EVENT.Handler(event,"Mouseup",this)},
Mousemove: function (event) {return EVENT.Handler(event,"Mousemove",this)}, Mousemove: function (event) {return EVENT.Handler(event,"Mousemove",this)},
@ -111,14 +150,23 @@
False: function (event) { False: function (event) {
if (!event) {event = window.event} if (!event) {event = window.event}
if (event) { if (event) {
if (event.preventDefault) {event.preventDefault()} if (event.preventDefault) {event.preventDefault()} else {event.returnValue = false}
if (event.stopPropagation) {event.stopPropagation()} if (event.stopPropagation) {event.stopPropagation()}
event.cancelBubble = true; event.cancelBubble = true;
event.returnValue = false;
} }
return false; return false;
}, },
//
// Keydown event handler. Should only fire on Space key.
//
Keydown: function (event, math) {
if (!event) event = window.event;
if (event.keyCode === EVENT.KEY.SPACE) {
EVENT.ContextMenu(event, this);
};
},
// //
// Load the contextual menu code, if needed, and post the menu // Load the contextual menu code, if needed, and post the menu
// //
@ -141,33 +189,66 @@
} }
// //
// If the menu code is loaded, post the menu // If the menu code is loaded,
// Otherwse lad the menu code and try again // Check if localization needs loading;
// If not, post the menu, and return.
// Otherwise wait for the localization to load
// Otherwse load the menu code.
// Try again after the file is loaded.
// //
var MENU = MathJax.Menu; var MENU = MathJax.Menu; var load, fn;
if (MENU) { if (MENU) {
if (MENU.loadingDomain) {return EVENT.False(event)}
load = LOCALE.loadDomain("MathMenu");
if (!load) {
MENU.jax = jax; MENU.jax = jax;
var source = MENU.menu.Find("Show Math As").menu; var source = MENU.menu.Find("Show Math As").submenu;
source.items[1].name = (INPUT[jax.inputJax].sourceMenuTitle||"Original Form"); source.items[0].name = jax.sourceMenuTitle;
source.items[0].hidden = (jax.inputJax === "Error"); // hide MathML choice for error messages source.items[0].format = (jax.sourceMenuFormat||"MathML");
source.items[1].name = INPUT[jax.inputJax].sourceMenuTitle;
source.items[5].disabled = !INPUT[jax.inputJax].annotationEncoding;
//
// Try and find each known annotation format and enable the menu
// items accordingly.
//
var annotations = source.items[2]; annotations.disabled = true;
var annotationItems = annotations.submenu.items;
annotationList = MathJax.Hub.Config.semanticsAnnotations;
for (var i = 0, m = annotationItems.length; i < m; i++) {
var name = annotationItems[i].name[1]
if (jax.root && jax.root.getAnnotation(name) !== null) {
annotations.disabled = false;
annotationItems[i].hidden = false;
} else {
annotationItems[i].hidden = true;
}
}
var MathPlayer = MENU.menu.Find("Math Settings","MathPlayer"); var MathPlayer = MENU.menu.Find("Math Settings","MathPlayer");
MathPlayer.hidden = !(jax.outputJax === "NativeMML" && HUB.Browser.hasMathPlayer); MathPlayer.hidden = !(jax.outputJax === "NativeMML" && HUB.Browser.hasMathPlayer);
return MENU.menu.Post(event); return MENU.menu.Post(event);
}
MENU.loadingDomain = true;
fn = function () {delete MENU.loadingDomain};
} else { } else {
if (!AJAX.loadingMathMenu) { if (AJAX.loadingMathMenu) {return EVENT.False(event)}
AJAX.loadingMathMenu = true; AJAX.loadingMathMenu = true;
load = AJAX.Require("[MathJax]/extensions/MathMenu.js");
fn = function () {
delete AJAX.loadingMathMenu;
if (!MathJax.Menu) {MathJax.Menu = {}}
}
}
var ev = { var ev = {
pageX:event.pageX, pageY:event.pageY, pageX:event.pageX, pageY:event.pageY,
clientX:event.clientX, clientY:event.clientY clientX:event.clientX, clientY:event.clientY
}; };
CALLBACK.Queue( CALLBACK.Queue(
AJAX.Require("[MathJax]/extensions/MathMenu.js"), load, fn, // load the file and delete the marker when done
function () {delete AJAX.loadingMathMenu; if (!MathJax.Menu) {MathJax.Menu = {}}}, ["ContextMenu",EVENT,ev,math,force] // call this function again
["ContextMenu",this,ev,math,force] // call this function again
); );
}
return EVENT.False(event); return EVENT.False(event);
}
}, },
// //
@ -215,7 +296,7 @@
if (SETTINGS.discoverable || SETTINGS.zoom === "Hover") { if (SETTINGS.discoverable || SETTINGS.zoom === "Hover") {
var from = event.fromElement || event.relatedTarget, var from = event.fromElement || event.relatedTarget,
to = event.toElement || event.target; to = event.toElement || event.target;
if (from && to && (from.isMathJax != to.isMathJax || if (from && to && (HUB.isMathJaxNode(from) !== HUB.isMathJaxNode(to) ||
HUB.getJaxFor(from) !== HUB.getJaxFor(to))) { HUB.getJaxFor(from) !== HUB.getJaxFor(to))) {
var jax = this.getJaxFromMath(math); var jax = this.getJaxFromMath(math);
if (jax.hover) {HOVER.ReHover(jax)} else {HOVER.HoverTimer(jax,math)} if (jax.hover) {HOVER.ReHover(jax)} else {HOVER.HoverTimer(jax,math)}
@ -232,7 +313,7 @@
if (SETTINGS.discoverable || SETTINGS.zoom === "Hover") { if (SETTINGS.discoverable || SETTINGS.zoom === "Hover") {
var from = event.fromElement || event.relatedTarget, var from = event.fromElement || event.relatedTarget,
to = event.toElement || event.target; to = event.toElement || event.target;
if (from && to && (from.isMathJax != to.isMathJax || if (from && to && (HUB.isMathJaxNode(from) !== HUB.isMathJaxNode(to) ||
HUB.getJaxFor(from) !== HUB.getJaxFor(to))) { HUB.getJaxFor(from) !== HUB.getJaxFor(to))) {
var jax = this.getJaxFromMath(math); var jax = this.getJaxFromMath(math);
if (jax.hover) {HOVER.UnHover(jax)} else {HOVER.ClearHoverTimer()} if (jax.hover) {HOVER.UnHover(jax)} else {HOVER.ClearHoverTimer()}
@ -299,17 +380,17 @@
]] ]]
); );
var button = HTML.Element("span",{ var button = HTML.Element("span",{
isMathJax: true, id:jax.hover.id+"Menu", isMathJax: true, id:jax.hover.id+"Menu", className:"MathJax_Menu_Button",
style:{display:"inline-block", "z-index": 1, width:0, height:0, position:"relative"} style:{display:"inline-block", "z-index": 1, width:0, height:0, position:"relative"}
},[["img",{ },[["span",{
className: "MathJax_Hover_Arrow", isMathJax: true, math: math, className: "MathJax_Hover_Arrow", isMathJax: true, math: math,
src: CONFIG.button.src, onclick: this.HoverMenu, jax:JAX.id, onclick: this.HoverMenu, jax:JAX.id,
style: { style: {
left:this.Px(bbox.w+dx+dd+(bbox.x||0)+CONFIG.button.x), 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), top:this.Px(-bbox.h-dy-dd-(bbox.y||0)-CONFIG.button.y),
opacity:0, filter:"alpha(opacity=0)" opacity:0, filter:"alpha(opacity=0)"
} }
}]] },[["span",{isMathJax:true},"\u25BC"]]]]
); );
if (bbox.width) { if (bbox.width) {
frame.style.width = button.style.width = bbox.width; frame.style.width = button.style.width = bbox.width;
@ -405,9 +486,11 @@
// Preload images so they show up with the menu // Preload images so they show up with the menu
// //
getImages: function () { getImages: function () {
if (SETTINGS.discoverable) {
var menu = new Image(); var menu = new Image();
menu.src = CONFIG.button.src; menu.src = CONFIG.button.src;
} }
}
}; };
@ -428,8 +511,8 @@
// //
start: function (event) { start: function (event) {
var now = new Date().getTime(); var now = new Date().getTime();
var dblTap = (now - TOUCH.last < TOUCH.delay); var dblTap = (now - TOUCH.last < TOUCH.delay && TOUCH.up);
TOUCH.last = now; TOUCH.last = now; TOUCH.up = false;
if (dblTap) { if (dblTap) {
TOUCH.timeout = setTimeout(TOUCH.menu,TOUCH.delay,event,this); TOUCH.timeout = setTimeout(TOUCH.menu,TOUCH.delay,event,this);
event.preventDefault(); event.preventDefault();
@ -444,9 +527,11 @@
// Prevent the default action and issue a double click. // Prevent the default action and issue a double click.
// //
end: function (event) { end: function (event) {
var now = new Date().getTime();
TOUCH.up = (now - TOUCH.last < TOUCH.delay);
if (TOUCH.timeout) { if (TOUCH.timeout) {
clearTimeout(TOUCH.timeout); clearTimeout(TOUCH.timeout);
delete TOUCH.timeout; TOUCH.last = 0; delete TOUCH.timeout; TOUCH.last = 0; TOUCH.up = false;
event.preventDefault(); event.preventDefault();
return EVENT.Handler((event.touches[0]||event.touch),"DblClick",this); return EVENT.Handler((event.touches[0]||event.touch),"DblClick",this);
} }
@ -457,20 +542,22 @@
// the contextual menu event. // the contextual menu event.
// //
menu: function (event,math) { menu: function (event,math) {
delete TOUCH.timeout; TOUCH.last = 0; delete TOUCH.timeout; TOUCH.last = 0; TOUCH.up = false;
return EVENT.Handler((event.touches[0]||event.touch),"ContextMenu",math); return EVENT.Handler((event.touches[0]||event.touch),"ContextMenu",math);
} }
}; };
// /*
// Mobile screens are small, so use larger version of arrow * //
// * // Mobile screens are small, so use larger version of arrow
if (HUB.Browser.isMobile) { * //
var arrow = CONFIG.styles[".MathJax_Hover_Arrow"]; * if (HUB.Browser.isMobile) {
arrow.width = "25px"; arrow.height = "18px"; * var arrow = CONFIG.styles[".MathJax_Hover_Arrow"];
CONFIG.button.x = -6; * arrow.width = "25px"; arrow.height = "18px";
} * CONFIG.button.x = -6;
* }
*/
// //
// Set up browser-specific values // Set up browser-specific values
@ -528,4 +615,5 @@
["loadComplete",AJAX,"[MathJax]/extensions/MathEvents.js"] ["loadComplete",AJAX,"[MathJax]/extensions/MathEvents.js"]
); );
})(MathJax.Hub,MathJax.HTML,MathJax.Ajax,MathJax.Callback,MathJax.OutputJax,MathJax.InputJax); })(MathJax.Hub,MathJax.HTML,MathJax.Ajax,MathJax.Callback,
MathJax.Localization,MathJax.OutputJax,MathJax.InputJax);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,784 @@
/*************************************************************
*
* MathJax/extensions/MathML/mml3.js
*
* This file implements an XSLT transform to convert some MathML 3
* constructs to constructs MathJax can render. The transform is
* performed in a pre-filter for the MathML input jax, so that the
* Show Math As menu will still show the Original MathML correctly,
* but the transformed MathML can be obtained from the regular MathML menu.
*
* To load it, include
*
* MathML: {
* extensions: ["mml3.js"]
* }
*
* in your configuration.
*
* A portion of this file is taken from mml3mj.xsl which is
* Copyright (c) David Carlisle 2008-2015
* and is used by permission of David Carlisle, who has agreed to allow us
* to release it under the Apache2 license (see below). That portion is
* indicated via comments.
*
* The remainder falls under the copyright that follows.
* ---------------------------------------------------------------------
*
* Copyright (c) 2013-2015 The MathJax Consortium
*
* 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["MathML/mml3"] = {
version: "2.6.0"
};
MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () {
var MATHML = MathJax.InputJax.MathML,
PARSE = MATHML.Parse.prototype;
MATHML.prefilterHooks.Add(function (data) {
if (!MATHML.mml3XSLT) return;
// Parse the <math> but use MATHML.Parse's preProcessMath to apply the normal preprocessing.
if (!MATHML.ParseXML) {MATHML.ParseXML = MATHML.createParser()}
var doc = MATHML.ParseXML(PARSE.preProcessMath(data.math));
// Now transform the <math> using the mml3 stylesheet.
var newdoc = MATHML.mml3XSLT.transformToDocument(doc);
if ((typeof newdoc) === "string") {
// Internet Explorer returns a string, so just use it.
data.math = newdoc;
} else if (window.XMLSerializer) {
// Serialize the <math> again. We could directly provide the DOM content
// but other prefilterHooks may assume data.math is still a string.
var serializer = new XMLSerializer();
data.math = serializer.serializeToString(newdoc.documentElement, doc);
}
});
/*
* The following is derived from mml3mj.xsl
* (https://github.com/davidcarlisle/web-xslt/blob/master/ctop/mml3mj.xsl)
* which is Copyright (c) David Carlisle 2008-2015.
* It is used by permission of David Carlisle, who has agreed to allow it to
* be released under the Apache License, Version 2.0.
*/
var BROWSER = MathJax.Hub.Browser;
var exslt = '';
if (BROWSER.isEdge || BROWSER.isMSIE) {
exslt = 'urn:schemas-microsoft-com:xslt'
} else {
exslt = 'http://exslt.org/common';
}
var mml3Stylesheet =
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' +
' xmlns:m="http://www.w3.org/1998/Math/MathML"' +
' xmlns:c="' + exslt + '"' +
' exclude-result-prefixes="m c">' +
'<xsl:output indent="yes" omit-xml-declaration="yes"/>' +
'<xsl:output indent="yes" omit-xml-declaration="yes"/><xsl:template match="*">' +
' <xsl:copy>' +
' <xsl:copy-of select="@*"/>' +
' <xsl:apply-templates/>' +
' </xsl:copy>' +
'</xsl:template><xsl:template match="m:*[@dir=\'rtl\']" priority="10">' +
' <xsl:apply-templates mode="rtl" select="."/>' +
'</xsl:template><xsl:template match="@*" mode="rtl">' +
' <xsl:copy-of select="."/>' +
' <xsl:attribute name="dir">ltr</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="*" mode="rtl">' +
' <xsl:copy>' +
' <xsl:apply-templates select="@*" mode="rtl"/>' +
' <xsl:for-each select="node()">' +
' <xsl:sort data-type="number" order="descending" select="position()"/>' +
' <xsl:text> </xsl:text>' +
' <xsl:apply-templates mode="rtl" select="."/>' +
' </xsl:for-each>' +
' </xsl:copy>' +
'</xsl:template><xsl:template match="@open" mode="rtl">' +
' <xsl:attribute name="close"><xsl:value-of select="."/></xsl:attribute>' +
'</xsl:template><xsl:template match="@open[.=\'(\']" mode="rtl">' +
' <xsl:attribute name="close">)</xsl:attribute>' +
'</xsl:template><xsl:template match="@open[.=\')\']" mode="rtl">' +
' <xsl:attribute name="close">(</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="@open[.=\'[\']" mode="rtl">' +
' <xsl:attribute name="close">]</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="@open[.=\']\']" mode="rtl">' +
' <xsl:attribute name="close">[</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="@open[.=\'{\']" mode="rtl">' +
' <xsl:attribute name="close">}</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="@open[.=\'}\']" mode="rtl">' +
' <xsl:attribute name="close">{</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="@close" mode="rtl">' +
' <xsl:attribute name="open"><xsl:value-of select="."/></xsl:attribute>' +
'</xsl:template><xsl:template match="@close[.=\'(\']" mode="rtl">' +
' <xsl:attribute name="open">)</xsl:attribute>' +
'</xsl:template><xsl:template match="@close[.=\')\']" mode="rtl">' +
' <xsl:attribute name="open">(</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="@close[.=\'[\']" mode="rtl">' +
' <xsl:attribute name="open">]</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="@close[.=\']\']" mode="rtl">' +
' <xsl:attribute name="open">[</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="@close[.=\'{\']" mode="rtl">' +
' <xsl:attribute name="open">}</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="@close[.=\'}\']" mode="rtl">' +
' <xsl:attribute name="open">{</xsl:attribute>' +
'</xsl:template><xsl:template match="m:mfrac[@bevelled=\'true\']" mode="rtl">' +
' <m:mrow>' +
' <m:msub><m:mi></m:mi><xsl:apply-templates select="*[2]" mode="rtl"/></m:msub>' +
' <m:mo>&#x5c;</m:mo>' +
' <m:msup><m:mi></m:mi><xsl:apply-templates select="*[1]" mode="rtl"/></m:msup>' +
' </m:mrow>' +
'</xsl:template><xsl:template match="m:mfrac" mode="rtl">' +
' <xsl:copy>' +
' <xsl:apply-templates mode="rtl" select="@*|*"/>' +
' </xsl:copy>' +
'</xsl:template><xsl:template match="m:mroot" mode="rtl">' +
' <m:msup>' +
' <m:menclose notation="top right">' +
' <xsl:apply-templates mode="rtl" select="@*|*[1]"/>' +
' </m:menclose>' +
' <xsl:apply-templates mode="rtl" select="*[2]"/>' +
' </m:msup>' +
'</xsl:template>' +
'<xsl:template match="m:msqrt" mode="rtl">' +
' <m:menclose notation="top right">' +
' <xsl:apply-templates mode="rtl" select="@*|*[1]"/>' +
' </m:menclose>' +
'</xsl:template><xsl:template match="m:mtable|m:munder|m:mover|m:munderover" mode="rtl" priority="2">' +
' <xsl:copy>' +
' <xsl:apply-templates select="@*" mode="rtl"/>' +
' <xsl:apply-templates mode="rtl">' +
' </xsl:apply-templates>' +
' </xsl:copy>' +
'</xsl:template>' +
'<xsl:template match="m:msup" mode="rtl" priority="2">' +
' <m:mmultiscripts>' +
' <xsl:apply-templates select="*[1]" mode="rtl"/>' +
' <m:mprescripts/>' +
' <m:none/>' +
' <xsl:apply-templates select="*[2]" mode="rtl"/>' +
' </m:mmultiscripts>' +
'</xsl:template>' +
'<xsl:template match="m:msub" mode="rtl" priority="2">' +
' <m:mmultiscripts>' +
' <xsl:apply-templates select="*[1]" mode="rtl"/>' +
' <m:mprescripts/>' +
' <xsl:apply-templates select="*[2]" mode="rtl"/>' +
' <m:none/>' +
' </m:mmultiscripts>' +
'</xsl:template>' +
'<xsl:template match="m:msubsup" mode="rtl" priority="2">' +
' <m:mmultiscripts>' +
' <xsl:apply-templates select="*[1]" mode="rtl"/>' +
' <m:mprescripts/>' +
' <xsl:apply-templates select="*[2]" mode="rtl"/>' +
' <xsl:apply-templates select="*[3]" mode="rtl"/>' +
' </m:mmultiscripts>' +
'</xsl:template>' +
'<xsl:template match="m:mmultiscripts" mode="rtl" priority="2">' +
' <m:mmultiscripts>' +
' <xsl:apply-templates select="*[1]" mode="rtl"/>' +
' <xsl:for-each select="m:mprescripts/following-sibling::*[position() mod 2 = 1]">' +
' <xsl:sort data-type="number" order="descending" select="position()"/>' +
' <xsl:apply-templates select="." mode="rtl"/>' +
' <xsl:apply-templates select="following-sibling::*[1]" mode="rtl"/>' +
' </xsl:for-each>' +
' <m:mprescripts/>' +
' <xsl:for-each select="m:mprescripts/preceding-sibling::*[position()!=last()][position() mod 2 = 0]">' +
' <xsl:sort data-type="number" order="descending" select="position()"/>' +
' <xsl:apply-templates select="." mode="rtl"/>' +
' <xsl:apply-templates select="following-sibling::*[1]" mode="rtl"/>' +
' </xsl:for-each>' +
' </m:mmultiscripts>' +
'</xsl:template>' +
'<xsl:template match="m:mmultiscripts[not(m:mprescripts)]" mode="rtl" priority="3">' +
' <m:mmultiscripts>' +
' <xsl:apply-templates select="*[1]" mode="rtl"/>' +
' <m:mprescripts/>' +
' <xsl:for-each select="*[position() mod 2 = 0]">' +
' <xsl:sort data-type="number" order="descending" select="position()"/>' +
' <xsl:apply-templates select="." mode="rtl"/>' +
' <xsl:apply-templates select="following-sibling::*[1]" mode="rtl"/>' +
' </xsl:for-each>' +
' </m:mmultiscripts>' +
'</xsl:template>' +
'<xsl:template match="text()[.=\'(\']" mode="rtl">)</xsl:template>' +
'<xsl:template match="text()[.=\')\']" mode="rtl">(</xsl:template>' +
'<xsl:template match="text()[.=\'{\']" mode="rtl">}</xsl:template>' +
'<xsl:template match="text()[.=\'}\']" mode="rtl">{</xsl:template>' +
'<xsl:template match="text()[.=\'&lt;\']" mode="rtl">&gt;</xsl:template>' +
'<xsl:template match="text()[.=\'&gt;\']" mode="rtl">&lt;</xsl:template>' +
'<xsl:template match="text()[.=\'&#x2208;\']" mode="rtl">&#x220b;</xsl:template>' +
'<xsl:template match="text()[.=\'&#x220b;\']" mode="rtl">&#x2208;</xsl:template>' +
'<xsl:template match="@notation[.=\'radical\']" mode="rtl">' +
' <xsl:attribute name="notation">top right</xsl:attribute>' +
'</xsl:template>' +
'<xsl:template match="m:mlongdiv|m:mstack" mode="rtl">' +
' <m:mrow dir="ltr">' +
' <xsl:apply-templates select="."/>' +
' </m:mrow>' +
'</xsl:template>' +
'<xsl:template match="m:mstack" priority="11">' +
' <xsl:variable name="m">' +
' <m:mtable columnspacing="0em">' +
' <xsl:copy-of select="@align"/>' +
' <xsl:variable name="t">' +
' <xsl:apply-templates select="*" mode="mstack1">' +
' <xsl:with-param name="p" select="0"/>' +
' </xsl:apply-templates>' +
' </xsl:variable>' +
' <xsl:variable name="maxl">' +
' <xsl:for-each select="c:node-set($t)/*/@l">' +
' <xsl:sort data-type="number" order="descending"/>' +
' <xsl:if test="position()=1">' +
' <xsl:value-of select="."/>' +
' </xsl:if>' +
' </xsl:for-each>' +
' </xsl:variable>' +
' <xsl:for-each select="c:node-set($t)/*[not(@class=\'mscarries\') or following-sibling::*[1]/@class=\'mscarries\']">' +
'<xsl:variable name="c" select="preceding-sibling::*[1][@class=\'mscarries\']"/>' +
' <xsl:text>&#10;</xsl:text>' +
' <m:mtr>' +
' <xsl:copy-of select="@class[.=\'msline\']"/>' +
' <xsl:variable name="offset" select="$maxl - @l"/>' +
' <xsl:choose>' +
' <xsl:when test="@class=\'msline\' and @l=\'*\'">' +
' <xsl:variable name="msl" select="*[1]"/>' +
' <xsl:for-each select="(//node())[position()&lt;=$maxl]">' +
' <xsl:copy-of select="$msl"/>' +
' </xsl:for-each>' +
' </xsl:when>' +
' <xsl:when test="$c">' +
' <xsl:variable name="ldiff" select="$c/@l - @l"/>' +
' <xsl:variable name="loffset" select="$maxl - $c/@l"/>' +
' <xsl:for-each select="(//*)[position()&lt;= $offset]">' +
' <xsl:variable name="pn" select="position()"/>' +
' <xsl:variable name="cy" select="$c/*[position()=$pn - $loffset]"/>' +
' <m:mtd>' +
' <xsl:if test="$cy/*">' +
' <m:mover><m:mphantom><m:mn>0</m:mn></m:mphantom><m:mpadded width="0em" lspace="-0.5width">' +
' <xsl:copy-of select="$cy/*"/></m:mpadded></m:mover>' +
' </xsl:if>' +
' </m:mtd>' +
' </xsl:for-each>' +
' <xsl:for-each select="*">' +
' <xsl:variable name="pn" select="position()"/>' +
' <xsl:variable name="cy" select="$c/*[position()=$pn + $ldiff]"/>' +
' <xsl:copy>' +
' <xsl:copy-of select="@*"/>' +
' <xsl:variable name="b">' +
' <xsl:choose>' +
' <xsl:when test="not(string($cy/@crossout) or $cy/@crossout=\'none\')"><xsl:copy-of select="*"/></xsl:when>' +
' <xsl:otherwise>' +
' <m:menclose notation="{$cy/@crossout}"><xsl:copy-of select="*"/></m:menclose>' +
' </xsl:otherwise>' +
' </xsl:choose>' +
' </xsl:variable>' +
' <xsl:choose>' +
' <xsl:when test="$cy/m:none or not($cy/*)"><xsl:copy-of select="$b"/></xsl:when>' +
' <xsl:when test="not(string($cy/@location)) or $cy/@location=\'n\'">' +
' <m:mover>' +
' <xsl:copy-of select="$b"/><m:mpadded width="0em" lspace="-0.5width">' +
' <xsl:copy-of select="$cy/*"/>' +
' </m:mpadded>' +
' </m:mover>' +
' </xsl:when>' +
' <xsl:when test="$cy/@location=\'nw\'">' +
' <m:mmultiscripts><xsl:copy-of select="$b"/><m:mprescripts/><m:none/><m:mpadded lspace="-1width" width="0em"><xsl:copy-of select="$cy/*"/></m:mpadded></m:mmultiscripts>' +
' </xsl:when>' +
' <xsl:when test="$cy/@location=\'s\'">' +
' <m:munder><xsl:copy-of select="$b"/><m:mpadded width="0em" lspace="-0.5width"><xsl:copy-of select="$cy/*"/></m:mpadded></m:munder>' +
' </xsl:when>' +
' <xsl:when test="$cy/@location=\'sw\'">' +
' <m:mmultiscripts><xsl:copy-of select="$b"/><m:mprescripts/><m:mpadded lspace="-1width" width="0em"><xsl:copy-of select="$cy/*"/></m:mpadded><m:none/></m:mmultiscripts>' +
' </xsl:when>' +
' <xsl:when test="$cy/@location=\'ne\'">' +
' <m:msup><xsl:copy-of select="$b"/><m:mpadded width="0em"><xsl:copy-of select="$cy/*"/></m:mpadded></m:msup>' +
' </xsl:when>' +
' <xsl:when test="$cy/@location=\'se\'">' +
' <m:msub><xsl:copy-of select="$b"/><m:mpadded width="0em"><xsl:copy-of select="$cy/*"/></m:mpadded></m:msub>' +
' </xsl:when>' +
' <xsl:when test="$cy/@location=\'w\'">' +
' <m:msup><m:mrow/><m:mpadded lspace="-1width" width="0em"><xsl:copy-of select="$cy/*"/></m:mpadded></m:msup>' +
' <xsl:copy-of select="$b"/>' +
' </xsl:when>' +
' <xsl:when test="$cy/@location=\'e\'">' +
' <xsl:copy-of select="$b"/>' +
' <m:msup><m:mrow/><m:mpadded width="0em"><xsl:copy-of select="$cy/*"/></m:mpadded></m:msup>' +
' </xsl:when>' +
' <xsl:otherwise>' +
' <xsl:copy-of select="$b"/>' +
' </xsl:otherwise>' +
' </xsl:choose>' +
' </xsl:copy>' +
' </xsl:for-each>' +
' </xsl:when>' +
' <xsl:otherwise>' +
' <xsl:for-each select="(//*)[position()&lt;= $offset]"><m:mtd/></xsl:for-each>' +
' <xsl:copy-of select="*"/>' +
' </xsl:otherwise>' +
' </xsl:choose>' +
' </m:mtr>' +
' </xsl:for-each>' +
' </m:mtable>' +
'</xsl:variable>' +
'<xsl:apply-templates mode="ml" select="c:node-set($m)"/>' +
'</xsl:template>' +
'<xsl:template match="*" mode="ml">' +
' <xsl:copy>' +
' <xsl:copy-of select="@*"/>' +
' <xsl:apply-templates mode="ml"/>' +
' </xsl:copy>' +
'</xsl:template>' +
'<xsl:template mode="ml" match="m:mtr[following-sibling::*[1][@class=\'msline\']]">' +
' <m:mtr>' +
' <xsl:copy-of select="@*"/>' +
' <xsl:variable name="m" select="following-sibling::*[1]/m:mtd"/>' +
' <xsl:for-each select="m:mtd">' +
' <xsl:variable name="p" select="position()"/>' +
' <m:mtd>' +
' <xsl:copy-of select="@*"/>' +
' <xsl:choose>' +
' <xsl:when test="$m[$p]/m:mpadded">' +
' <m:menclose notation="bottom">' +
' <m:mpadded depth=".1em" height="1em" width=".4em">' +
' <xsl:copy-of select="*"/>' +
' </m:mpadded>' +
' </m:menclose>' +
' </xsl:when>' +
' <xsl:otherwise>' +
' <xsl:copy-of select="*"/>' +
' </xsl:otherwise>' +
' </xsl:choose>' +
' </m:mtd>' +
' </xsl:for-each>' +
' </m:mtr>' +
'</xsl:template><xsl:template mode="ml" match="m:mtr[not(preceding-sibling::*)][@class=\'msline\']" priority="3">' +
' <m:mtr>' +
' <xsl:copy-of select="@*"/>' +
' <xsl:for-each select="m:mtd">' +
' <m:mtd>' +
' <xsl:copy-of select="@*"/>' +
' <xsl:if test="m:mpadded">' +
' <m:menclose notation="bottom">' +
' <m:mpadded depth=".1em" height="1em" width=".4em">' +
' <m:mspace width=".2em"/>' +
' </m:mpadded>' +
' </m:menclose>' +
' </xsl:if>' +
' </m:mtd>' +
' </xsl:for-each>' +
' </m:mtr>' +
'</xsl:template><xsl:template mode="ml" match="m:mtr[@class=\'msline\']" priority="2"/>' +
'<xsl:template mode="mstack1" match="*">' +
' <xsl:param name="p"/>' +
' <xsl:param name="maxl" select="0"/>' +
' <m:mtr l="{1 + $p}">' +
' <xsl:if test="ancestor::mstack[1]/@stackalign=\'left\'">' +
' <xsl:attribute name="l"><xsl:value-of select="$p"/></xsl:attribute>' +
' </xsl:if>' +
' <m:mtd><xsl:apply-templates select="."/></m:mtd>' +
' </m:mtr>' +
'</xsl:template>' +
'<xsl:template mode="mstack1" match="m:msrow">' +
' <xsl:param name="p"/>' +
' <xsl:param name="maxl" select="0"/>' +
' <xsl:variable name="align1" select="ancestor::m:mstack[1]/@stackalign"/>' +
' <xsl:variable name="align">' +
' <xsl:choose>' +
' <xsl:when test="string($align1)=\'\'">decimalpoint</xsl:when>' +
' <xsl:otherwise><xsl:value-of select="$align1"/></xsl:otherwise>' +
' </xsl:choose>' +
' </xsl:variable>' +
' <xsl:variable name="row">' +
' <xsl:apply-templates mode="mstack1" select="*">' +
' <xsl:with-param name="p" select="0"/>' +
' </xsl:apply-templates>' +
' </xsl:variable>' +
' <xsl:text>&#10;</xsl:text>' +
' <xsl:variable name="l1">' +
' <xsl:choose>' +
' <xsl:when test="$align=\'decimalpoint\' and m:mn">' +
' <xsl:for-each select="c:node-set($row)/m:mtr[m:mtd/m:mn][1]">' +
' <xsl:value-of select="number(sum(@l))+count(preceding-sibling::*/@l)"/>' +
' </xsl:for-each>' +
' </xsl:when>' +
' <xsl:when test="$align=\'right\' or $align=\'decimalpoint\'">' +
' <xsl:value-of select="count(c:node-set($row)/m:mtr/m:mtd)"/>' +
' </xsl:when>' +
' <xsl:otherwise>' +
' <xsl:value-of select="0"/>' +
' </xsl:otherwise>' +
' </xsl:choose>' +
' </xsl:variable>' +
' <m:mtr class="msrow" l="{number($l1) + number(sum(@position)) +$p}">' +
' <xsl:copy-of select="c:node-set($row)/m:mtr/*"/>' +
' </m:mtr>' +
'</xsl:template><xsl:template mode="mstack1" match="m:mn">' +
' <xsl:param name="p"/>' +
' <xsl:variable name="align1" select="ancestor::m:mstack[1]/@stackalign"/>' +
' <xsl:variable name="dp1" select="ancestor::*[@decimalpoint][1]/@decimalpoint"/>' +
' <xsl:variable name="align">' +
' <xsl:choose>' +
' <xsl:when test="string($align1)=\'\'">decimalpoint</xsl:when>' +
' <xsl:otherwise><xsl:value-of select="$align1"/></xsl:otherwise>' +
' </xsl:choose>' +
' </xsl:variable>' +
' <xsl:variable name="dp">' +
' <xsl:choose>' +
' <xsl:when test="string($dp1)=\'\'">.</xsl:when>' +
' <xsl:otherwise><xsl:value-of select="$dp1"/></xsl:otherwise>' +
' </xsl:choose>' +
' </xsl:variable>' +
' <m:mtr l="$p">' +
' <xsl:variable name="mn" select="normalize-space(.)"/>' +
' <xsl:variable name="len" select="string-length($mn)"/>' +
' <xsl:choose>' +
' <xsl:when test="$align=\'right\' or ($align=\'decimalpoint\' and not(contains($mn,$dp)))">' +
' <xsl:attribute name="l"><xsl:value-of select="$p + $len"/></xsl:attribute>' +
' </xsl:when>' +
' <xsl:when test="$align=\'center\'">' +
' <xsl:attribute name="l"><xsl:value-of select="round(($p + $len) div 2)"/></xsl:attribute>' +
' </xsl:when>' +
' <xsl:when test="$align=\'decimalpoint\'">' +
' <xsl:attribute name="l"><xsl:value-of select="$p + string-length(substring-before($mn,$dp))"/></xsl:attribute>' +
' </xsl:when>' +
' </xsl:choose> <xsl:for-each select="(//node())[position() &lt;=$len]">' +
' <xsl:variable name="pos" select="position()"/>' +
' <m:mtd><m:mn><xsl:value-of select="substring($mn,$pos,1)"/></m:mn></m:mtd>' +
' </xsl:for-each>' +
' </m:mtr>' +
'</xsl:template>' +
'<xsl:template match="m:msgroup" mode="mstack1">' +
' <xsl:param name="p"/>' +
' <xsl:variable name="s" select="number(sum(@shift))"/>' +
' <xsl:variable name="thisp" select="number(sum(@position))"/>' +
' <xsl:for-each select="*">' +
' <xsl:apply-templates mode="mstack1" select=".">' +
' <xsl:with-param name="p" select="number($p)+$thisp+(position()-1)*$s"/>' +
' </xsl:apply-templates>' +
' </xsl:for-each>' +
'</xsl:template>' +
'<xsl:template match="m:msline" mode="mstack1">' +
' <xsl:param name="p"/>' +
' <xsl:variable name="align1" select="ancestor::m:mstack[1]/@stackalign"/>' +
' <xsl:variable name="align">' +
' <xsl:choose>' +
' <xsl:when test="string($align1)=\'\'">decimalpoint</xsl:when>' +
' <xsl:otherwise><xsl:value-of select="$align1"/></xsl:otherwise>' +
' </xsl:choose>' +
' </xsl:variable>' +
' <m:mtr class="msline">' +
' <xsl:attribute name="l">' +
' <xsl:choose>' +
' <xsl:when test="not(string(@length)) or @length=0">*</xsl:when>' +
' <xsl:when test="string($align)=\'right\' or string($align)=\'decimalpoint\' "><xsl:value-of select="$p+ @length"/></xsl:when>' +
' <xsl:otherwise><xsl:value-of select="$p"/></xsl:otherwise>' +
' </xsl:choose>' +
' </xsl:attribute>' +
' <xsl:variable name="w">' +
' <xsl:choose>' +
' <xsl:when test="@mslinethickness=\'thin\'">0.1em</xsl:when>' +
' <xsl:when test="@mslinethickness=\'medium\'">0.15em</xsl:when>' +
' <xsl:when test="@mslinethickness=\'thick\'">0.2em</xsl:when>' +
' <xsl:when test="@mslinethickness"><xsl:value-of select="@mslinethickness"/></xsl:when>' +
' <xsl:otherwise>0.15em</xsl:otherwise>' +
' </xsl:choose>' +
' </xsl:variable>' +
' <xsl:choose>' +
' <xsl:when test="not(string(@length)) or @length=0">' +
' <m:mtd class="mslinemax">' +
' <m:mpadded lspace="-0.2em" width="0em" height="0em">' +
' <m:mfrac linethickness="{$w}">' +
' <m:mspace width=".4em"/>' +
' <m:mrow/>' +
' </m:mfrac>' +
' </m:mpadded>' +
' </m:mtd>' +
' </xsl:when>' +
' <xsl:otherwise>' +
' <xsl:variable name="l" select="@length"/>' +
' <xsl:for-each select="(//node())[position()&lt;=$l]">' +
' <m:mtd class="msline">' +
' <m:mpadded lspace="-0.2em" width="0em" height="0em">' +
' <m:mfrac linethickness="{$w}">' +
' <m:mspace width=".4em"/>' +
' <m:mrow/>' +
' </m:mfrac>' +
' </m:mpadded>' +
' </m:mtd>' +
' </xsl:for-each>' +
' </xsl:otherwise>' +
' </xsl:choose>' +
' </m:mtr>' +
'</xsl:template>' +
'<xsl:template match="m:mscarries" mode="mstack1">' +
' <xsl:param name="p"/>' +
' <xsl:variable name="align1" select="ancestor::m:mstack[1]/@stackalign"/>' +
' <xsl:variable name="l1">' +
' <xsl:choose>' +
' <xsl:when test="string($align1)=\'left\'">0</xsl:when>' +
' <xsl:otherwise><xsl:value-of select="count(*)"/></xsl:otherwise>' +
' </xsl:choose>' +
' </xsl:variable>' +
' <m:mtr class="mscarries" l="{$p + $l1 + sum(@position)}">' +
' <xsl:apply-templates select="*" mode="msc"/>' +
' </m:mtr>' +
'</xsl:template><xsl:template match="*" mode="msc">' +
' <m:mtd>' +
' <xsl:copy-of select="../@location|../@crossout"/>' +
' <xsl:choose>' +
' <xsl:when test="../@scriptsizemultiplier">' +
' <m:mstyle mathsize="{round(../@scriptsizemultiplier div .007)}%">' +
' <xsl:apply-templates select="."/>' +
' </m:mstyle>' +
' </xsl:when>' +
' <xsl:otherwise>' +
' <xsl:apply-templates select="."/>' +
' </xsl:otherwise>' +
' </xsl:choose>' +
' </m:mtd>' +
'</xsl:template><xsl:template match="m:mscarry" mode="msc">' +
' <m:mtd>' +
' <xsl:copy-of select="@location|@crossout"/>' +
' <xsl:choose>' +
' <xsl:when test="../@scriptsizemultiplier">' +
' <m:mstyle mathsize="{round(../@scriptsizemultiplier div .007)}%">' +
' <xsl:apply-templates/>' +
' </m:mstyle>' +
' </xsl:when>' +
' <xsl:otherwise>' +
' <xsl:apply-templates/>' +
' </xsl:otherwise>' +
' </xsl:choose>' +
' </m:mtd>' +
'</xsl:template>' +
'<xsl:template match="m:mlongdiv" priority="11">' +
' <xsl:variable name="ms">' +
' <m:mstack>' +
' <xsl:copy-of select="(ancestor-or-self::*/@decimalpoint)[last()]"/>' +
' <xsl:choose>' +
' <xsl:when test="@longdivstyle=\'left)(right\'">' +
' <m:msrow>' +
' <m:mrow><xsl:copy-of select="*[1]"/></m:mrow>' +
' <m:mo>)</m:mo>' +
' <xsl:copy-of select="*[3]"/>' +
' <m:mo>(</m:mo>' +
' <xsl:copy-of select="*[2]"/>' +
' </m:msrow>' +
' </xsl:when>' +
' <xsl:when test="@longdivstyle=\'left/\right\'">' +
' <m:msrow>' +
' <m:mrow><xsl:copy-of select="*[1]"/></m:mrow>' +
' <m:mo>/</m:mo>' +
' <xsl:copy-of select="*[3]"/>' +
' <m:mo>\</m:mo>' +
' <xsl:copy-of select="*[2]"/>' +
' </m:msrow>' +
' </xsl:when>' +
' <xsl:when test="@longdivstyle=\':right=right\'">' +
' <m:msrow>' +
' <xsl:copy-of select="*[3]"/>' +
' <m:mo>:</m:mo>' +
' <xsl:copy-of select="*[1]"/>' +
' <m:mo>=</m:mo>' +
' <xsl:copy-of select="*[2]"/>' +
' </m:msrow>' +
' </xsl:when>' +
' <xsl:when test="@longdivstyle=\'stackedrightright\'' +
' or @longdivstyle=\'mediumstackedrightright\'' +
' or @longdivstyle=\'shortstackedrightright\'' +
' or @longdivstyle=\'stackedleftleft\'' +
' ">' +
' <xsl:attribute name="align">top</xsl:attribute>' +
' <xsl:copy-of select="*[3]"/>' +
' </xsl:when>' +
' <xsl:when test="@longdivstyle=\'stackedleftlinetop\'">' +
' <xsl:copy-of select="*[2]"/>' +
' <m:msline length="{string-length(*[3])-1}"/>' +
' <m:msrow>' +
' <m:mrow>' +
' <m:menclose notation="bottom right">' +
' <xsl:copy-of select="*[1]"/>' +
' </m:menclose>' +
' </m:mrow>' +
' <xsl:copy-of select="*[3]"/>' +
' </m:msrow>' +
' </xsl:when>' +
' <xsl:when test="@longdivstyle=\'righttop\'">' +
' <xsl:copy-of select="*[2]"/>' +
' <m:msline length="{string-length(*[3])}"/>' +
' <m:msrow>' +
' <xsl:copy-of select="*[3]"/>' +
' <m:menclose notation="top left bottom">' +
' <xsl:copy-of select="*[1]"/></m:menclose>' +
' </m:msrow>' +
' </xsl:when>' +
' <xsl:otherwise>' +
' <xsl:copy-of select="*[2]"/>' +
' <m:msline length="{string-length(*[3])}"/>' +
' <m:msrow>' +
' <m:mrow><xsl:copy-of select="*[1]"/></m:mrow>' +
' <m:mo>)</m:mo>' +
' <xsl:copy-of select="*[3]"/>' +
' </m:msrow>' +
' </xsl:otherwise>' +
' </xsl:choose>' +
' <xsl:copy-of select="*[position()&gt;3]"/>' +
' </m:mstack>' +
' </xsl:variable>' +
' <xsl:choose>' +
' <xsl:when test="@longdivstyle=\'stackedrightright\'">' +
' <m:menclose notation="right">' +
' <xsl:apply-templates select="c:node-set($ms)"/>' +
' </m:menclose>' +
' <m:mtable align="top">' +
' <m:mtr>' +
' <m:menclose notation="bottom">' +
' <xsl:copy-of select="*[1]"/>' +
' </m:menclose>' +
' </m:mtr>' +
' <m:mtr>' +
' <mtd><xsl:copy-of select="*[2]"/></mtd>' +
' </m:mtr>' +
' </m:mtable>' +
' </xsl:when>' +
' <xsl:when test="@longdivstyle=\'mediumstackedrightright\'">' +
' <xsl:apply-templates select="c:node-set($ms)"/>' +
' <m:menclose notation="left">' +
' <m:mtable align="top">' +
' <m:mtr>' +
' <m:menclose notation="bottom">' +
' <xsl:copy-of select="*[1]"/>' +
' </m:menclose>' +
' </m:mtr>' +
' <m:mtr>' +
' <mtd><xsl:copy-of select="*[2]"/></mtd>' +
' </m:mtr>' +
' </m:mtable>' +
' </m:menclose>' +
' </xsl:when>' +
' <xsl:when test="@longdivstyle=\'shortstackedrightright\'">' +
' <xsl:apply-templates select="c:node-set($ms)"/>' +
' <m:mtable align="top">' +
' <m:mtr>' +
' <m:menclose notation="left bottom">' +
' <xsl:copy-of select="*[1]"/>' +
' </m:menclose>' +
' </m:mtr>' +
' <m:mtr>' +
' <mtd><xsl:copy-of select="*[2]"/></mtd>' +
' </m:mtr>' +
' </m:mtable>' +
' </xsl:when>' +
' <xsl:when test="@longdivstyle=\'stackedleftleft\'">' +
' <m:mtable align="top">' +
' <m:mtr>' +
' <m:menclose notation="bottom">' +
' <xsl:copy-of select="*[1]"/>' +
' </m:menclose>' +
' </m:mtr>' +
' <m:mtr>' +
' <mtd><xsl:copy-of select="*[2]"/></mtd>' +
' </m:mtr>' +
' </m:mtable>' +
' <m:menclose notation="left">' +
' <xsl:apply-templates select="c:node-set($ms)"/>' +
' </m:menclose>' +
' </xsl:when>' +
' <xsl:otherwise>' +
' <xsl:apply-templates select="c:node-set($ms)"/>' +
' </xsl:otherwise>' +
' </xsl:choose>' +
'</xsl:template>' +
'<xsl:template match="m:menclose[@notation=\'madruwb\']" mode="rtl">' +
' <m:menclose notation="bottom right">' +
' <xsl:apply-templates mode="rtl"/>' +
' </m:menclose>' +
'</xsl:template></xsl:stylesheet>';
/*
* End of mml3mj.xsl material.
*/
var mml3;
if (window.XSLTProcessor) {
// standard method: just use an XSLTProcessor and parse the stylesheet
if (!MATHML.ParseXML) {MATHML.ParseXML = MATHML.createParser()}
MATHML.mml3XSLT = new XSLTProcessor();
MATHML.mml3XSLT.importStylesheet(MATHML.ParseXML(mml3Stylesheet));
} else if (MathJax.Hub.Browser.isMSIE) {
// nonstandard methods for Internet Explorer
if (MathJax.Hub.Browser.versionAtLeast("9.0") || (document.documentMode||0) >= 9) {
// For Internet Explorer >= 9, use createProcessor
mml3 = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
mml3.loadXML(mml3Stylesheet);
var xslt = new ActiveXObject("Msxml2.XSLTemplate");
xslt.stylesheet = mml3;
MATHML.mml3XSLT = {
mml3: xslt.createProcessor(),
transformToDocument: function(doc) {
this.mml3.input = doc;
this.mml3.transform();
return this.mml3.output;
}
}
} else {
// For Internet Explorer <= 8, use transformNode
mml3 = MATHML.createMSParser();
mml3.async = false;
mml3.loadXML(mml3Stylesheet);
MATHML.mml3XSLT = {
mml3: mml3,
transformToDocument: function(doc) {
return doc.documentElement.transformNode(this.mml3);
}
}
}
} else {
// No XSLT support. Do not change the <math> content.
MATHML.mml3XSLT = null;
}
// Tweak CSS to avoid some browsers rearranging HTML output
MathJax.Ajax.Styles({
".MathJax .mi, .MathJax .mo, .MathJax .mn, .MathJax .mtext": {
direction: "ltr",
display: "inline-block"
},
".MathJax .ms, .MathJax .mspace, .MathJax .mglyph": {
direction: "ltr",
display: "inline-block"
}
});
MathJax.Hub.Startup.signal.Post("MathML mml3.js Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/MathML/mml3.js");

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/MathZoom.js * MathJax/extensions/MathZoom.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2010-2012 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +26,7 @@
*/ */
(function (HUB,HTML,AJAX,HTMLCSS,nMML) { (function (HUB,HTML,AJAX,HTMLCSS,nMML) {
var VERSION = "2.0"; var VERSION = "2.6.0";
var CONFIG = HUB.CombineConfig("MathZoom",{ var CONFIG = HUB.CombineConfig("MathZoom",{
styles: { styles: {
@ -37,6 +40,9 @@
"text-align":"left", "text-indent":0, "text-transform":"none", "text-align":"left", "text-indent":0, "text-transform":"none",
"line-height":"normal", "letter-spacing":"normal", "word-spacing":"normal", "line-height":"normal", "letter-spacing":"normal", "word-spacing":"normal",
"word-wrap":"normal", "white-space":"nowrap", "float":"none", "word-wrap":"normal", "white-space":"nowrap", "float":"none",
"-webkit-box-sizing":"content-box", // Android ≤ 2.3, iOS ≤ 4
"-moz-box-sizing":"content-box", // Firefox ≤ 28
"box-sizing":"content-box", // Chrome, Firefox 29+, IE 8+, Opera, Safari 5.1
"box-shadow":"5px 5px 15px #AAAAAA", // Opera 10.5 and IE9 "box-shadow":"5px 5px 15px #AAAAAA", // Opera 10.5 and IE9
"-webkit-box-shadow":"5px 5px 15px #AAAAAA", // Safari 3 and Chrome "-webkit-box-shadow":"5px 5px 15px #AAAAAA", // Safari 3 and Chrome
"-moz-box-shadow":"5px 5px 15px #AAAAAA", // Forefox 3.5 "-moz-box-shadow":"5px 5px 15px #AAAAAA", // Forefox 3.5
@ -53,6 +59,11 @@
"background-color":"white", opacity:0, filter:"alpha(opacity=0)" "background-color":"white", opacity:0, filter:"alpha(opacity=0)"
}, },
"#MathJax_ZoomFrame": {
position:"relative", display:"inline-block",
height:0, width:0
},
"#MathJax_ZoomEventTrap": { "#MathJax_ZoomEventTrap": {
position:"absolute", left:0, top:0, "z-index":302, position:"absolute", left:0, top:0, "z-index":302,
display:"inline-block", border:0, padding:0, margin:0, display:"inline-block", border:0, padding:0, margin:0,
@ -98,7 +109,7 @@
// Zoom on double click // Zoom on double click
// //
DblClick: function (event,math) { DblClick: function (event,math) {
if (this.settings.zoom === "Double-Click") {return this.Zoom(event,math)} if (this.settings.zoom === "Double-Click" || this.settings.zoom === "DoubleClick") {return this.Zoom(event,math)}
}, },
// //
@ -129,26 +140,25 @@
// //
// Create the DOM elements for the zoom box // Create the DOM elements for the zoom box
// //
var Mw = Math.floor(.85*document.body.clientWidth), var container = this.findContainer(math);
Mh = Math.floor(.85*Math.max(document.body.clientHeight,document.documentElement.clientHeight)); var Mw = Math.floor(.85*container.clientWidth),
Mh = Math.max(document.body.clientHeight,document.documentElement.clientHeight);
if (this.getOverflow(container) !== "visible") {Mh = Math.min(container.clientHeight,Mh)}
Mh = Math.floor(.85*Mh);
var div = HTML.Element( var div = HTML.Element(
"span",{ "span",{id:"MathJax_ZoomFrame"},[
style: {position:"relative", display:"inline-block", height:0, width:0},
id:"MathJax_ZoomFrame"
},[
["span",{id:"MathJax_ZoomOverlay", onmousedown:this.Remove}], ["span",{id:"MathJax_ZoomOverlay", onmousedown:this.Remove}],
["span",{ ["span",{
id:"MathJax_Zoom", onclick:this.Remove, id:"MathJax_Zoom", onclick:this.Remove,
style:{ style:{visibility:"hidden", fontSize:this.settings.zscale}
visibility:"hidden", fontSize:this.settings.zscale,
"max-width":Mw+"px", "max-height":Mh+"px"
}
},[["span",{style:{display:"inline-block", "white-space":"nowrap"}}]] },[["span",{style:{display:"inline-block", "white-space":"nowrap"}}]]
]] ]]
); );
var zoom = div.lastChild, span = zoom.firstChild, overlay = div.firstChild; var zoom = div.lastChild, span = zoom.firstChild, overlay = div.firstChild;
math.parentNode.insertBefore(div,math); math.parentNode.insertBefore(div,math); math.parentNode.insertBefore(math,div); // put div after math
if (span.addEventListener) {span.addEventListener("mousedown",this.Remove,true)} if (span.addEventListener) {span.addEventListener("mousedown",this.Remove,true)}
var eW = zoom.offsetWidth || zoom.clientWidth; Mw -= eW; Mh -= eW;
zoom.style.maxWidth = Mw+"px"; zoom.style.maxHeight = Mh+"px";
if (this.msieTrapEventBug) { if (this.msieTrapEventBug) {
var trap = HTML.Element("span",{id:"MathJax_ZoomEventTrap", onmousedown:this.Remove}); var trap = HTML.Element("span",{id:"MathJax_ZoomEventTrap", onmousedown:this.Remove});
@ -182,7 +192,8 @@
if (zoom.offsetWidth > Mw) {zoom.style.width = Mw+"px"; zoom.style.height = (bbox.zH+this.scrollSize)+"px"} 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 (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"} if (zoom.offsetWidth > eW && zoom.offsetWidth-eW < Mw && zoom.offsetHeight-eW < Mh)
{zoom.style.overflow = "visible"} // don't show scroll bars if we don't need to
this.Position(zoom,bbox); this.Position(zoom,bbox);
if (this.msieTrapEventBug) { if (this.msieTrapEventBug) {
trap.style.height = zoom.clientHeight+"px"; trap.style.width = zoom.clientWidth+"px"; trap.style.height = zoom.clientHeight+"px"; trap.style.width = zoom.clientWidth+"px";
@ -214,8 +225,10 @@
// Set the position of the zoom box and overlay // Set the position of the zoom box and overlay
// //
Position: function (zoom,bbox) { Position: function (zoom,bbox) {
zoom.style.display = "none"; // avoids getting excessive width in Resize()
var XY = this.Resize(), x = XY.x, y = XY.y, W = bbox.mW; 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.display = "";
var dx = -W-Math.floor((zoom.offsetWidth-W)/2), dy = bbox.Y;
zoom.style.left = Math.max(dx,10-x)+"px"; zoom.style.top = Math.max(dy,10-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 if (!ZOOM.msiePositionBug) {ZOOM.SetWH()} // refigure overlay width/height
}, },
@ -225,24 +238,61 @@
// //
Resize: function (event) { Resize: function (event) {
if (ZOOM.onresize) {ZOOM.onresize(event)} if (ZOOM.onresize) {ZOOM.onresize(event)}
var x = 0, y = 0, obj, var div = document.getElementById("MathJax_ZoomFrame"),
div = document.getElementById("MathJax_ZoomFrame"),
overlay = document.getElementById("MathJax_ZoomOverlay"); overlay = document.getElementById("MathJax_ZoomOverlay");
var xy = ZOOM.getXY(div), obj = ZOOM.findContainer(div);
if (ZOOM.getOverflow(obj) !== "visible") {
overlay.scroll_parent = obj; // Save this for future reference.
var XY = ZOOM.getXY(obj); // Remove container position
xy.x -= XY.x; xy.y -= XY.y;
XY = ZOOM.getBorder(obj); // Remove container border
xy.x -= XY.x; xy.y -= XY.y;
}
overlay.style.left = (-xy.x)+"px"; overlay.style.top = (-xy.y)+"px";
if (ZOOM.msiePositionBug) {setTimeout(ZOOM.SetWH,0)} else {ZOOM.SetWH()}
return xy;
},
SetWH: function () {
var overlay = document.getElementById("MathJax_ZoomOverlay");
if (!overlay) return;
overlay.style.display = "none"; // so scrollWidth/Height will be right below
var doc = overlay.scroll_parent || document.documentElement || document.body;
overlay.style.width = doc.scrollWidth + "px";
overlay.style.height = Math.max(doc.clientHeight,doc.scrollHeight) + "px";
overlay.style.display = "";
},
findContainer: function (obj) {
obj = obj.parentNode;
while (obj.parentNode && obj !== document.body && ZOOM.getOverflow(obj) === "visible")
{obj = obj.parentNode}
return obj;
},
//
// Look up CSS properties (use getComputeStyle if available, or currentStyle if not)
//
getOverflow: (window.getComputedStyle ?
function (obj) {return getComputedStyle(obj).overflow} :
function (obj) {return (obj.currentStyle||{overflow:"visible"}).overflow}),
getBorder: function (obj) {
var size = {thin: 1, medium: 2, thick: 3};
var style = (window.getComputedStyle ? getComputedStyle(obj) :
(obj.currentStyle || {borderLeftWidth:0,borderTopWidth:0}));
var x = style.borderLeftWidth, y = style.borderTopWidth;
if (size[x]) {x = size[x]} else {x = parseInt(x)}
if (size[y]) {y = size[y]} else {y = parseInt(y)}
return {x:x, y:y};
},
//
// Get the position of an element on the page
//
getXY: function (div) {
var x = 0, y = 0, obj;
obj = div; while (obj.offsetParent) {x += obj.offsetLeft; obj = obj.offsetParent} 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 (ZOOM.operaPositionBug) {div.style.border = "1px solid"} // to get vertical position right
obj = div; while (obj.offsetParent) {y += obj.offsetTop; obj = obj.offsetParent} obj = div; while (obj.offsetParent) {y += obj.offsetTop; obj = obj.offsetParent}
if (ZOOM.operaPositionBug) {div.style.border = ""} if (ZOOM.operaPositionBug) {div.style.border = ""}
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}; return {x:x, y:y};
}, },
SetWH: function () {
var overlay = document.getElementById("MathJax_ZoomOverlay");
overlay.style.width = overlay.style.height = "1px"; // so scrollWidth/Height will be right below
var doc = document.documentElement || document.body;
overlay.style.width = doc.scrollWidth + "px";
overlay.style.height = Math.max(doc.clientHeight,doc.scrollHeight) + "px";
},
// //
// Remove zoom display and event handlers // Remove zoom display and event handlers
@ -250,8 +300,8 @@
Remove: function (event) { Remove: function (event) {
var div = document.getElementById("MathJax_ZoomFrame"); var div = document.getElementById("MathJax_ZoomFrame");
if (div) { if (div) {
var JAX = MathJax.OutputJax[div.nextSibling.jaxID]; var JAX = MathJax.OutputJax[div.previousSibling.jaxID];
var jax = JAX.getJaxFromMath(div.nextSibling); var jax = JAX.getJaxFromMath(div.previousSibling);
HUB.signal.Post(["math unzoomed",jax]); HUB.signal.Post(["math unzoomed",jax]);
div.parentNode.removeChild(div); div.parentNode.removeChild(div);
div = document.getElementById("MathJax_ZoomTracker"); div = document.getElementById("MathJax_ZoomTracker");

View File

@ -0,0 +1,348 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*************************************************************
*
* MathJax/extensions/Safe.js
*
* Implements a "Safe" mode that disables features that could be
* misused in a shared environment (such as href's to javascript URL's).
* See the CONFIG variable below for configuration options.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2013-2015 The MathJax Consortium
*
* 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,AJAX) {
var VERSION = "2.6.0";
var CONFIG = MathJax.Hub.CombineConfig("Safe",{
allow: {
//
// Values can be "all", "safe", or "none"
//
URLs: "safe", // safe are in safeProtocols below
classes: "safe", // safe start with MJX-
cssIDs: "safe", // safe start with MJX-
styles: "safe", // safe are in safeStyles below
fontsize: "all", // safe are between sizeMin and sizeMax em's
require: "safe" // safe are in safeRequire below
},
sizeMin: .7, // \scriptsize
sizeMax: 1.44, // \large
safeProtocols: {
http: true,
https: true,
file: true,
javascript: false
},
safeStyles: {
color: true,
backgroundColor: true,
border: true,
cursor: true,
margin: true,
padding: true,
textShadow: true,
fontFamily: true,
fontSize: true,
fontStyle: true,
fontWeight: true,
opacity: true,
outline: true
},
safeRequire: {
action: true,
amscd: true,
amsmath: true,
amssymbols: true,
autobold: false,
"autoload-all": false,
bbox: true,
begingroup: true,
boldsymbol: true,
cancel: true,
color: true,
enclose: true,
extpfeil: true,
HTML: true,
mathchoice: true,
mhchem: true,
newcommand: true,
noErrors: false,
noUndefined: false,
unicode: true,
verb: true
}
});
var ALLOW = CONFIG.allow;
if (ALLOW.fontsize !== "all") {CONFIG.safeStyles.fontSize = false}
var SAFE = MathJax.Extension.Safe = {
version: VERSION,
config: CONFIG,
div1: document.createElement("div"), // for CSS processing
div2: document.createElement("div"),
//
// Methods called for MathML attribute processing
//
filter: {
href: "filterURL",
src: "filterURL",
altimg: "filterURL",
"class": "filterClass",
style: "filterStyles",
id: "filterID",
fontsize: "filterFontSize",
mathsize: "filterFontSize",
scriptminsize: "filterFontSize",
scriptsizemultiplier: "filterSizeMultiplier",
scriptlevel: "filterScriptLevel"
},
//
// Filter HREF URL's
//
filterURL: function (url) {
var protocol = (url.match(/^\s*([a-z]+):/i)||[null,""])[1].toLowerCase();
if (ALLOW.URLs === "none" ||
(ALLOW.URLs !== "all" && !CONFIG.safeProtocols[protocol])) {url = null}
return url;
},
//
// Filter class names and css ID's
//
filterClass: function (CLASS) {
if (ALLOW.classes === "none" ||
(ALLOW.classes !== "all" && !CLASS.match(/^MJX-[-a-zA-Z0-9_.]+$/))) {CLASS = null}
return CLASS;
},
filterID: function (id) {
if (ALLOW.cssIDs === "none" ||
(ALLOW.cssIDs !== "all" && !id.match(/^MJX-[-a-zA-Z0-9_.]+$/))) {id = null}
return id;
},
//
// Filter style strings
//
filterStyles: function (styles) {
if (ALLOW.styles === "all") {return styles}
if (ALLOW.styles === "none") {return null}
try {
//
// Set the div1 styles to the given styles, and clear div2
//
var STYLE1 = this.div1.style, STYLE2 = this.div2.style;
STYLE1.cssText = styles; STYLE2.cssText = "";
//
// Check each allowed style and transfer OK ones to div2
//
for (var name in CONFIG.safeStyles) {if (CONFIG.safeStyles.hasOwnProperty(name)) {
var value = this.filterStyle(name,STYLE1[name]);
if (value != null) {STYLE2[name] = value}
}}
//
// Return the div2 style string
//
styles = STYLE2.cssText;
} catch (e) {styles = null}
return styles;
},
//
// Filter an individual name:value style pair
//
filterStyle: function (name,value) {
if (typeof value !== "string") {return null}
if (value.match(/^\s*expression/)) {return null}
if (value.match(/javascript:/)) {return null}
return (CONFIG.safeStyles[name] ? value : null);
},
//
// Filter TeX font size values (in em's)
//
filterSize: function (size) {
if (ALLOW.fontsize === "none") {return null}
if (ALLOW.fontsize !== "all")
{size = Math.min(Math.max(size,CONFIG.sizeMin),CONFIG.sizeMax)}
return size;
},
filterFontSize: function (size) {
return (ALLOW.fontsize === "all" ? size: null);
},
//
// Filter scriptsizemultiplier
//
filterSizeMultiplier: function (size) {
if (ALLOW.fontsize === "none") {size = null}
else if (ALLOW.fontsize !== "all") {size = Math.min(1,Math.max(.6,size)).toString()}
return size;
},
//
// Filter scriptLevel
//
filterScriptLevel: function (level) {
if (ALLOW.fontsize === "none") {level = null}
else if (ALLOW.fontsize !== "all") {level = Math.max(0,level).toString()}
return level;
},
//
// Filter TeX extension names
//
filterRequire: function (name) {
if (ALLOW.require === "none" ||
(ALLOW.require !== "all" && !CONFIG.safeRequire[name.toLowerCase()]))
{name = null}
return name;
}
};
HUB.Register.StartupHook("TeX HTML Ready",function () {
var TEX = MathJax.InputJax.TeX;
TEX.Parse.Augment({
//
// Implements \href{url}{math} with URL filter
//
HREF_attribute: function (name) {
var url = SAFE.filterURL(this.GetArgument(name)),
arg = this.GetArgumentMML(name);
if (url) {arg.With({href:url})}
this.Push(arg);
},
//
// Implements \class{name}{math} with class-name filter
//
CLASS_attribute: function (name) {
var CLASS = SAFE.filterClass(this.GetArgument(name)),
arg = this.GetArgumentMML(name);
if (CLASS) {
if (arg["class"] != null) {CLASS = arg["class"] + " " + CLASS}
arg.With({"class":CLASS});
}
this.Push(arg);
},
//
// Implements \style{style-string}{math} with style filter
//
STYLE_attribute: function (name) {
var style = SAFE.filterStyles(this.GetArgument(name)),
arg = this.GetArgumentMML(name);
if (style) {
if (arg.style != null) {
if (style.charAt(style.length-1) !== ";") {style += ";"}
style = arg.style + " " + style;
}
arg.With({style: style});
}
this.Push(arg);
},
//
// Implements \cssId{id}{math} with ID filter
//
ID_attribute: function (name) {
var ID = SAFE.filterID(this.GetArgument(name)),
arg = this.GetArgumentMML(name);
if (ID) {arg.With({id:ID})}
this.Push(arg);
}
});
});
HUB.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
PARSE = TEX.Parse, METHOD = SAFE.filter;
PARSE.Augment({
//
// Implements \require{name} with filtering
//
Require: function (name) {
var file = this.GetArgument(name).replace(/.*\//,"").replace(/[^a-z0-9_.-]/ig,"");
file = SAFE.filterRequire(file);
if (file) {this.Extension(null,file)}
},
//
// Controls \mmlToken attributes
//
MmlFilterAttribute: function (name,value) {
if (METHOD[name]) {value = SAFE[METHOD[name]](value)}
return value;
},
//
// Handles font size macros with filtering
//
SetSize: function (name,size) {
size = SAFE.filterSize(size);
if (size) {
this.stack.env.size = size;
this.Push(TEX.Stack.Item.style().With({styles: {mathsize: size+"em"}}));
}
}
});
});
HUB.Register.StartupHook("TeX bbox Ready",function () {
var TEX = MathJax.InputJax.TeX;
//
// Filter the styles for \bbox
//
TEX.Parse.Augment({
BBoxStyle: function (styles) {return SAFE.filterStyles(styles)}
});
});
HUB.Register.StartupHook("MathML Jax Ready",function () {
var PARSE = MathJax.InputJax.MathML.Parse,
METHOD = SAFE.filter;
//
// Filter MathML attributes
//
PARSE.Augment({
filterAttribute: function (name,value) {
if (METHOD[name]) {value = SAFE[METHOD[name]](value)}
return value;
}
});
});
// MathML input (href, style, fontsize, class, id)
HUB.Startup.signal.Post("Safe Extension Ready");
AJAX.loadComplete("[MathJax]/extensions/Safe.js");
})(MathJax.Hub,MathJax.Ajax);

View File

@ -0,0 +1,158 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*************************************************************
*
* MathJax/extensions/TeX/AMScd.js
*
* Implements the CD environment for commutative diagrams.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2013-2015 The MathJax Consortium
*
* 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/AMScd"] = {
version: "2.6.0",
config: MathJax.Hub.CombineConfig("TeX.CD",{
colspace: "5pt",
rowspace: "5pt",
harrowsize: "2.75em",
varrowsize: "1.75em",
hideHorizontalLabels: false
})
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var MML = MathJax.ElementJax.mml,
TEX = MathJax.InputJax.TeX,
STACKITEM = TEX.Stack.Item,
TEXDEF = TEX.Definitions,
CONFIG = MathJax.Extension["TeX/AMScd"].config;
TEXDEF.environment.CD = "CD_env";
TEXDEF.special["@"] = "CD_arrow";
TEXDEF.macros.minCDarrowwidth = "CD_minwidth";
TEXDEF.macros.minCDarrowheight = "CD_minheight";
TEX.Parse.Augment({
//
// Implements \begin{CD}...\end{CD}
//
CD_env: function (begin) {
this.Push(begin);
return STACKITEM.array().With({
arraydef: {
columnalign: "center",
columnspacing: CONFIG.colspace,
rowspacing: CONFIG.rowspace,
displaystyle: true
},
minw: this.stack.env.CD_minw || CONFIG.harrowsize,
minh: this.stack.env.CD_minh || CONFIG.varrowsize
});
},
CD_arrow: function (name) {
var c = this.string.charAt(this.i);
if (!c.match(/[><VA.|=]/)) {return this.Other(name)} else {this.i++}
var top = this.stack.Top();
if (!top.isa(STACKITEM.array) || top.data.length) {
this.CD_cell(name);
top = this.stack.Top();
}
//
// Add enough cells to place the arrow correctly
//
var arrowRow = ((top.table.length % 2) === 1);
var n = (top.row.length + (arrowRow ? 0 : 1)) % 2;
while (n) {this.CD_cell(name); n--}
var mml;
var hdef = {minsize: top.minw, stretchy:true},
vdef = {minsize: top.minh, stretchy:true, symmetric:true, lspace:0, rspace:0};
if (c === ".") {}
else if (c === "|") {mml = this.mmlToken(MML.mo("\u2225").With(vdef))}
else if (c === "=") {mml = this.mmlToken(MML.mo("=").With(hdef))}
else {
//
// for @>>> @<<< @VVV and @AAA, get the arrow and labels
//
var arrow = {">":"\u2192", "<":"\u2190", V:"\u2193", A:"\u2191"}[c];
var a = this.GetUpTo(name+c,c),
b = this.GetUpTo(name+c,c);
if (c === ">" || c === "<") {
//
// Lay out horizontal arrows with munderover if it has labels
//
mml = MML.mo(arrow).With(hdef);
if (!a) {a = "\\kern "+top.minw} // minsize needs work
if (a || b) {
var pad = {width:"+11mu", lspace:"6mu"};
mml = MML.munderover(this.mmlToken(mml));
if (a) {
a = TEX.Parse(a,this.stack.env).mml();
mml.SetData(mml.over,MML.mpadded(a).With(pad).With({voffset:".1em"}));
}
if (b) {
b = TEX.Parse(b,this.stack.env).mml();
mml.SetData(mml.under,MML.mpadded(b).With(pad));
}
if (CONFIG.hideHorizontalLabels)
{mml = MML.mpadded(mml).With({depth:0, height:".67em"})}
}
} else {
//
// Lay out vertical arrows with mrow if there are labels
//
mml = arrow = this.mmlToken(MML.mo(arrow).With(vdef));
if (a || b) {
mml = MML.mrow();
if (a) {mml.Append(TEX.Parse("\\scriptstyle\\llap{"+a+"}",this.stack.env).mml())}
mml.Append(arrow.With({texClass: MML.TEXCLASS.ORD}));
if (b) {mml.Append(TEX.Parse("\\scriptstyle\\rlap{"+b+"}",this.stack.env).mml())}
}
}
}
if (mml) {this.Push(mml)};
this.CD_cell(name);
},
CD_cell: function (name) {
var top = this.stack.Top();
if ((top.table||[]).length % 2 === 0 && (top.row||[]).length === 0) {
//
// Add a strut to the first cell in even rows to get
// better spacing of arrow rows.
//
this.Push(MML.mpadded().With({height:"8.5pt",depth:"2pt"}));
}
this.Push(STACKITEM.cell().With({isEntry:true, name:name}));
},
CD_minwidth: function (name) {
this.stack.env.CD_minw = this.GetDimen(name);
},
CD_minheight: function (name) {
this.stack.env.CD_minh = this.GetDimen(name);
}
});
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/AMScd.js");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/AMSmath.js * MathJax/extensions/TeX/AMSmath.js
@ -6,7 +9,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,10 +25,12 @@
*/ */
MathJax.Extension["TeX/AMSmath"] = { MathJax.Extension["TeX/AMSmath"] = {
version: "2.0", version: "2.6.0",
number: 0, // current equation number number: 0, // current equation number
startNumber: 0, // current starting equation number (for when equation is restarted) startNumber: 0, // current starting equation number (for when equation is restarted)
IDs: {}, // IDs used in previous equations
eqIDs: {}, // IDs used in this equation
labels: {}, // the set of labels labels: {}, // the set of labels
eqlabels: {}, // labels in the current equation eqlabels: {}, // labels in the current equation
refs: [] // array of jax with unresolved references refs: [] // array of jax with unresolved references
@ -41,11 +46,20 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
STACKITEM = TEX.Stack.Item, STACKITEM = TEX.Stack.Item,
CONFIG = TEX.config.equationNumbers; CONFIG = TEX.config.equationNumbers;
var COLS = function (W) {return W.join("em ") + "em"}; var COLS = function (W) {
var WW = [];
for (var i = 0, m = W.length; i < m; i++)
{WW[i] = TEX.Parse.prototype.Em(W[i])}
return WW.join(" ");
};
/******************************************************************************/ /******************************************************************************/
TEXDEF.Add({ TEXDEF.Add({
mathchar0mo: {
iiiint: ['2A0C',{texClass: MML.TEXCLASS.OP}]
},
macros: { macros: {
mathring: ['Accent','2DA'], // or 0x30A mathring: ['Accent','2DA'], // or 0x30A
@ -53,14 +67,16 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
negmedspace: ['Spacer',MML.LENGTH.NEGATIVEMEDIUMMATHSPACE], negmedspace: ['Spacer',MML.LENGTH.NEGATIVEMEDIUMMATHSPACE],
negthickspace: ['Spacer',MML.LENGTH.NEGATIVETHICKMATHSPACE], negthickspace: ['Spacer',MML.LENGTH.NEGATIVETHICKMATHSPACE],
intI: ['Macro','\\mathchoice{\\!}{}{}{}\\!\\!\\int'], // intI: ['Macro','\\mathchoice{\\!}{}{}{}\\!\\!\\int'],
// iint: ['MultiIntegral','\\int\\intI'], // now in core TeX input jax // iint: ['MultiIntegral','\\int\\intI'], // now in core TeX input jax
// iiint: ['MultiIntegral','\\int\\intI\\intI'], // now in core TeX input jax // iiint: ['MultiIntegral','\\int\\intI\\intI'], // now in core TeX input jax
iiiint: ['MultiIntegral','\\int\\intI\\intI\\intI'], // iiiint: ['MultiIntegral','\\int\\intI\\intI\\intI'], // now in mathchar0mo above
idotsint: ['MultiIntegral','\\int\\cdots\\int'], idotsint: ['MultiIntegral','\\int\\cdots\\int'],
dddot: ['Macro','\\mathop{#1}\\limits^{\\textstyle \\mathord{.}\\mathord{.}\\mathord{.}}',1], // dddot: ['Macro','\\mathop{#1}\\limits^{\\textstyle \\mathord{.}\\mathord{.}\\mathord{.}}',1],
ddddot: ['Macro','\\mathop{#1}\\limits^{\\textstyle \\mathord{.}\\mathord{.}\\mathord{.}\\mathord{.}}',1], // ddddot: ['Macro','\\mathop{#1}\\limits^{\\textstyle \\mathord{.}\\mathord{.}\\mathord{.}\\mathord{.}}',1],
dddot: ['Accent','20DB'],
ddddot: ['Accent','20DC'],
sideset: ['Macro','\\mathop{\\mathop{\\rlap{\\phantom{#3}}}\\nolimits#1\\!\\mathop{#3}\\nolimits#2}',3], sideset: ['Macro','\\mathop{\\mathop{\\rlap{\\phantom{#3}}}\\nolimits#1\\!\\mathop{#3}\\nolimits#2}',3],
@ -74,23 +90,24 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
substack: ['Macro','\\begin{subarray}{c}#1\\end{subarray}',1], substack: ['Macro','\\begin{subarray}{c}#1\\end{subarray}',1],
injlim: ['Macro','\\mathop{\\rm inj\\,lim}'], injlim: ['NamedOp','inj&thinsp;lim'],
projlim: ['Macro','\\mathop{\\rm proj\\,lim}'], projlim: ['NamedOp','proj&thinsp;lim'],
varliminf: ['Macro','\\mathop{\\underline{\\rm lim}}'], varliminf: ['Macro','\\mathop{\\underline{\\mmlToken{mi}{lim}}}'],
varlimsup: ['Macro','\\mathop{\\overline{\\rm lim}}'], varlimsup: ['Macro','\\mathop{\\overline{\\mmlToken{mi}{lim}}}'],
varinjlim: ['Macro','\\mathop{\\underrightarrow{\\rm lim\\Rule{-1pt}{0pt}{1pt}}\\Rule{0pt}{0pt}{.45em}}'], varinjlim: ['Macro','\\mathop{\\underrightarrow{\\mmlToken{mi}{lim}\\Rule{-1pt}{0pt}{1pt}}\\Rule{0pt}{0pt}{.45em}}'],
varprojlim: ['Macro','\\mathop{\\underleftarrow{\\rm lim\\Rule{-1pt}{0pt}{1pt}}\\Rule{0pt}{0pt}{.45em}}'], varprojlim: ['Macro','\\mathop{\\underleftarrow{\\mmlToken{mi}{lim}\\Rule{-1pt}{0pt}{1pt}}\\Rule{0pt}{0pt}{.45em}}'],
DeclareMathOperator: 'HandleDeclareOp', DeclareMathOperator: 'HandleDeclareOp',
operatorname: 'HandleOperatorName', operatorname: 'HandleOperatorName',
SkipLimits: 'SkipLimits',
genfrac: 'Genfrac', genfrac: 'Genfrac',
frac: ['Genfrac',"","","",""], frac: ['Genfrac',"","","",""],
tfrac: ['Genfrac',"","","",1], tfrac: ['Genfrac',"","","",1],
dfrac: ['Genfrac',"","","",0], dfrac: ['Genfrac',"","","",0],
binom: ['Genfrac',"(",")","0em",""], binom: ['Genfrac',"(",")","0",""],
tbinom: ['Genfrac',"(",")","0em",1], tbinom: ['Genfrac',"(",")","0",1],
dbinom: ['Genfrac',"(",")","0em",0], dbinom: ['Genfrac',"(",")","0",0],
cfrac: 'CFrac', cfrac: 'CFrac',
@ -102,11 +119,11 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}, },
environment: { environment: {
align: ['AMSarray',null,true,true, 'rlrlrlrlrlrl',COLS([5/18,2,5/18,2,5/18,2,5/18,2,5/18,2,5/18])], align: ['AMSarray',null,true,true, 'rlrlrlrlrlrl',COLS([0,2,0,2,0,2,0,2,0,2,0])],
'align*': ['AMSarray',null,false,true, 'rlrlrlrlrlrl',COLS([5/18,2,5/18,2,5/18,2,5/18,2,5/18,2,5/18])], 'align*': ['AMSarray',null,false,true, 'rlrlrlrlrlrl',COLS([0,2,0,2,0,2,0,2,0,2,0])],
multline: ['Multline',null,true], multline: ['Multline',null,true],
'multline*': ['Multline',null,false], 'multline*': ['Multline',null,false],
split: ['AMSarray',null,false,false,'rl',COLS([5/18])], split: ['AMSarray',null,false,false,'rl',COLS([0])],
gather: ['AMSarray',null,true,true, 'c'], gather: ['AMSarray',null,true,true, 'c'],
'gather*': ['AMSarray',null,false,true, 'c'], 'gather*': ['AMSarray',null,false,true, 'c'],
@ -114,14 +131,17 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
'alignat*': ['AlignAt',null,false,true], 'alignat*': ['AlignAt',null,false,true],
alignedat: ['AlignAt',null,false,false], alignedat: ['AlignAt',null,false,false],
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'], aligned: ['AlignedAMSArray',null,null,null,'rlrlrlrlrlrl',COLS([0,2,0,2,0,2,0,2,0,2,0]),".5em",'D'],
gathered: ['AlignedArray',null,null,null,'c',null,".5em",'D'], gathered: ['AlignedAMSArray',null,null,null,'c',null,".5em",'D'],
subarray: ['Array',null,null,null,null,COLS([0,0,0,0]),"0.1em",'S',1], subarray: ['Array',null,null,null,null,COLS([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','Equation',true],
'equation*': ['EquationBegin','EquationStar',false] 'equation*': ['EquationBegin','EquationStar',false],
eqnarray: ['AMSarray',null,true,true, 'rcl',"0 "+MML.LENGTH.THICKMATHSPACE,".5em"],
'eqnarray*': ['AMSarray',null,false,true,'rcl',"0 "+MML.LENGTH.THICKMATHSPACE,".5em"]
}, },
delimiter: { delimiter: {
@ -145,8 +165,13 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var arg = this.trimSpaces(this.GetArgument(name)), tag = arg; var arg = this.trimSpaces(this.GetArgument(name)), tag = arg;
if (!star) {arg = CONFIG.formatTag(arg)} if (!star) {arg = CONFIG.formatTag(arg)}
var global = this.stack.global; global.tagID = tag; var global = this.stack.global; global.tagID = tag;
if (global.notags) {TEX.Error(name+" not allowed in "+global.notags+" environment")} if (global.notags) {
if (global.tag) {TEX.Error("Multiple "+name)} TEX.Error(["CommandNotAllowedInEnv",
"%1 not allowed in %2 environment",
name,global.notags]
);
}
if (global.tag) {TEX.Error(["MultipleCommand","Multiple %1",name])}
global.tag = MML.mtd.apply(MML,this.InternalMath(arg)).With({id:CONFIG.formatID(tag)}); global.tag = MML.mtd.apply(MML,this.InternalMath(arg)).With({id:CONFIG.formatID(tag)});
}, },
HandleNoTag: function (name) { HandleNoTag: function (name) {
@ -159,11 +184,13 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
*/ */
HandleLabel: function (name) { HandleLabel: function (name) {
var global = this.stack.global, label = this.GetArgument(name); var global = this.stack.global, label = this.GetArgument(name);
if (label === "") return;
if (!AMS.refUpdate) { if (!AMS.refUpdate) {
if (global.label) {TEX.Error("Multiple "+name+"'s")} if (global.label) {TEX.Error(["MultipleCommand","Multiple %1",name])}
global.label = label; global.label = label;
if (AMS.labels[label] || AMS.eqlabels[label]) {TEX.Error("Label '"+label+"' mutiply defined")} if (AMS.labels[label] || AMS.eqlabels[label])
AMS.eqlabels[label] = "???"; // will be replaced by tag value later {TEX.Error(["MultipleLabel","Label '%1' multiply defined",label])}
AMS.eqlabels[label] = {tag:"???", id:""}; // will be replaced by tag value later
} }
}, },
@ -173,11 +200,10 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
HandleRef: function (name,eqref) { HandleRef: function (name,eqref) {
var label = this.GetArgument(name); var label = this.GetArgument(name);
var ref = AMS.labels[label] || AMS.eqlabels[label]; var ref = AMS.labels[label] || AMS.eqlabels[label];
if (!ref) {ref = "??"; AMS.badref = !AMS.refUpdate} if (!ref) {ref = {tag:"???",id:""}; AMS.badref = !AMS.refUpdate}
var tag = ref; if (eqref) {tag = CONFIG.formatTag(tag)} var tag = ref.tag; if (eqref) {tag = CONFIG.formatTag(tag)}
if (CONFIG.useLabelIds) {ref = label}
this.Push(MML.mrow.apply(MML,this.InternalMath(tag)).With({ this.Push(MML.mrow.apply(MML,this.InternalMath(tag)).With({
href:CONFIG.formatURL(CONFIG.formatID(ref)), "class":"MathJax_ref" href:CONFIG.formatURL(ref.id), "class":"MathJax_ref"
})); }));
}, },
@ -185,7 +211,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
* Handle \DeclareMathOperator * Handle \DeclareMathOperator
*/ */
HandleDeclareOp: function (name) { HandleDeclareOp: function (name) {
var limits = (this.GetStar() ? "\\limits" : ""); var limits = (this.GetStar() ? "" : "\\nolimits\\SkipLimits");
var cs = this.trimSpaces(this.GetArgument(name)); var cs = this.trimSpaces(this.GetArgument(name));
if (cs.charAt(0) == "\\") {cs = cs.substr(1)} if (cs.charAt(0) == "\\") {cs = cs.substr(1)}
var op = this.GetArgument(name); var op = this.GetArgument(name);
@ -194,19 +220,27 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}, },
HandleOperatorName: function (name) { HandleOperatorName: function (name) {
var limits = (this.GetStar() ? "\\limits" : "\\nolimits"); var limits = (this.GetStar() ? "" : "\\nolimits\\SkipLimits");
var op = this.trimSpaces(this.GetArgument(name)); var op = this.trimSpaces(this.GetArgument(name));
op = op.replace(/\*/g,'\\text{*}').replace(/-/g,'\\text{-}'); op = op.replace(/\*/g,'\\text{*}').replace(/-/g,'\\text{-}');
this.string = '\\mathop{\\rm '+op+'}'+limits+" "+this.string.slice(this.i); this.string = '\\mathop{\\rm '+op+'}'+limits+" "+this.string.slice(this.i);
this.i = 0; this.i = 0;
}, },
SkipLimits: function (name) {
var c = this.GetNext(), i = this.i;
if (c === "\\" && ++this.i && this.GetCS() !== "limits") this.i = i;
},
/* /*
* Record presence of \shoveleft and \shoveright * Record presence of \shoveleft and \shoveright
*/ */
HandleShove: function (name,shove) { HandleShove: function (name,shove) {
var top = this.stack.Top(); var top = this.stack.Top();
if (top.type !== "multline" || top.data.length) {TEX.Error(name+" must come at the beginning of the line")} if (top.type !== "multline" || top.data.length) {
TEX.Error(["CommandAtTheBeginingOfLine",
"%1 must come at the beginning of the line",name]);
}
top.data.shove = shove; top.data.shove = shove;
}, },
@ -220,7 +254,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var frac = MML.mfrac(TEX.Parse('\\strut\\textstyle{'+num+'}',this.stack.env).mml(), var frac = MML.mfrac(TEX.Parse('\\strut\\textstyle{'+num+'}',this.stack.env).mml(),
TEX.Parse('\\strut\\textstyle{'+den+'}',this.stack.env).mml()); TEX.Parse('\\strut\\textstyle{'+den+'}',this.stack.env).mml());
lr = ({l:MML.ALIGN.LEFT, r:MML.ALIGN.RIGHT,"":""})[lr]; lr = ({l:MML.ALIGN.LEFT, r:MML.ALIGN.RIGHT,"":""})[lr];
if (lr == null) {TEX.Error("Illegal alignment specified in "+name)} if (lr == null)
{TEX.Error(["IllegalAlign","Illegal alignment specified in %1",name])}
if (lr) {frac.numalign = frac.denomalign = lr} if (lr) {frac.numalign = frac.denomalign = lr}
this.Push(frac); this.Push(frac);
}, },
@ -229,18 +264,19 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
* Implement AMS generalized fraction * Implement AMS generalized fraction
*/ */
Genfrac: function (name,left,right,thick,style) { Genfrac: function (name,left,right,thick,style) {
if (left == null) {left = this.GetDelimiterArg(name)} else {left = this.convertDelimiter(left)} if (left == null) {left = this.GetDelimiterArg(name)}
if (right == null) {right = this.GetDelimiterArg(name)} else {right = this.convertDelimiter(right)} if (right == null) {right = this.GetDelimiterArg(name)}
if (thick == null) {thick = this.GetArgument(name)} if (thick == null) {thick = this.GetArgument(name)}
if (style == null) {style = this.trimSpaces(this.GetArgument(name))} if (style == null) {style = this.trimSpaces(this.GetArgument(name))}
var num = this.ParseArg(name); var num = this.ParseArg(name);
var den = this.ParseArg(name); var den = this.ParseArg(name);
var frac = MML.mfrac(num,den); var frac = MML.mfrac(num,den);
if (thick !== "") {frac.linethickness = thick} if (thick !== "") {frac.linethickness = thick}
if (left || right) {frac = MML.mfenced(frac).With({open: left, close: right})} if (left || right) {frac = TEX.fixedFence(left,frac.With({texWithDelims:true}),right)}
if (style !== "") { if (style !== "") {
var STYLE = (["D","T","S","SS"])[style]; var STYLE = (["D","T","S","SS"])[style];
if (STYLE == null) {TEX.Error("Bad math style for "+name)} if (STYLE == null)
{TEX.Error(["BadMathStyleFor","Bad math style for %1",name])}
frac = MML.mstyle(frac); frac = MML.mstyle(frac);
if (STYLE === "D") {frac.displaystyle = true; frac.scriptlevel = 0} if (STYLE === "D") {frac.displaystyle = true; frac.scriptlevel = 0}
else {frac.displaystyle = false; frac.scriptlevel = style - 1} else {frac.displaystyle = false; frac.scriptlevel = style - 1}
@ -284,6 +320,11 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}); });
}, },
AlignedAMSArray: function (begin) {
var align = this.GetBrackets("\\begin{"+begin.name+"}");
return this.setArrayAlign(this.AMSarray.apply(this,arguments),align);
},
/* /*
* Handle alignat environments * Handle alignat environments
*/ */
@ -291,11 +332,14 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var n, valign, align = "", spacing = []; var n, valign, align = "", spacing = [];
if (!taggable) {valign = this.GetBrackets("\\begin{"+begin.name+"}")} if (!taggable) {valign = this.GetBrackets("\\begin{"+begin.name+"}")}
n = this.GetArgument("\\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")} if (n.match(/[^0-9]/)) {
TEX.Error(["PositiveIntegerArg","Argument to %1 must me a positive integer",
"\\begin{"+begin.name+"}"]);
}
while (n > 0) {align += "rl"; spacing.push("0em 0em"); n--} while (n > 0) {align += "rl"; spacing.push("0em 0em"); n--}
spacing = spacing.join(" "); spacing = spacing.join(" ");
if (taggable) {return this.AMSarray(begin,numbered,taggable,align,spacing)} if (taggable) {return this.AMSarray(begin,numbered,taggable,align,spacing)}
var array = this.Array.call(this,begin,null,null,align,spacing,".5em",'D'); var array = this.AMSarray(begin,numbered,taggable,align,spacing);
return this.setArrayAlign(array,valign); return this.setArrayAlign(array,valign);
}, },
@ -316,7 +360,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
* Check for bad nesting of equation environments * Check for bad nesting of equation environments
*/ */
checkEqnEnv: function () { checkEqnEnv: function () {
if (this.stack.global.eqnenv) {TEX.Error("Erroneous nesting of equation structures")} if (this.stack.global.eqnenv)
{TEX.Error(["ErroneousNestingEq","Erroneous nesting of equation structures"])}
this.stack.global.eqnenv = true; this.stack.global.eqnenv = true;
}, },
@ -352,7 +397,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
bot = TEX.Parse(bot,this.stack.env).mml() bot = TEX.Parse(bot,this.stack.env).mml()
mml.SetData(mml.under,MML.mpadded(bot).With(def).With({voffset:"-.24em"})); mml.SetData(mml.under,MML.mpadded(bot).With(def).With({voffset:"-.24em"}));
} }
this.Push(mml); this.Push(mml.With({subsupOK:true}));
}, },
/* /*
@ -360,9 +405,9 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
*/ */
GetDelimiterArg: function (name) { GetDelimiterArg: function (name) {
var c = this.trimSpaces(this.GetArgument(name)); var c = this.trimSpaces(this.GetArgument(name));
if (c == "") {return null} if (c == "") return null;
if (TEXDEF.delimiter[c] == null) {TEX.Error("Missing or unrecognized delimiter for "+name)} if (c in TEXDEF.delimiter) return c;
return this.convertDelimiter(c); TEX.Error(["MissingOrUnrecognizedDelim","Missing or unrecognized delimiter for %1",name]);
}, },
/* /*
@ -387,7 +432,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
if (!global.notag) { if (!global.notag) {
AMS.number++; global.tagID = CONFIG.formatNumber(AMS.number.toString()); AMS.number++; global.tagID = CONFIG.formatNumber(AMS.number.toString());
var mml = TEX.Parse("\\text{"+CONFIG.formatTag(global.tagID)+"}",{}).mml(); var mml = TEX.Parse("\\text{"+CONFIG.formatTag(global.tagID)+"}",{}).mml();
global.tag = MML.mtd(mml.With({id:CONFIG.formatID(global.tagID)})); global.tag = MML.mtd(mml).With({id:CONFIG.formatID(global.tagID)});
} }
}, },
@ -397,11 +442,42 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
getTag: function () { getTag: function () {
var global = this.global, tag = global.tag; global.tagged = true; var global = this.global, tag = global.tag; global.tagged = true;
if (global.label) { if (global.label) {
AMS.eqlabels[global.label] = global.tagID;
if (CONFIG.useLabelIds) {tag.id = CONFIG.formatID(global.label)} if (CONFIG.useLabelIds) {tag.id = CONFIG.formatID(global.label)}
AMS.eqlabels[global.label] = {tag:global.tagID, id:tag.id};
} }
delete global.tag; delete global.tagID; delete global.label; //
// Check for repeated ID's (either in the document or as
// a previous tag) and find a unique related one. (#240)
//
if (document.getElementById(tag.id) || AMS.IDs[tag.id] || AMS.eqIDs[tag.id]) {
var i = 0, ID;
do {i++; ID = tag.id+"_"+i}
while (document.getElementById(ID) || AMS.IDs[ID] || AMS.eqIDs[ID]);
tag.id = ID; if (global.label) {AMS.eqlabels[global.label].id = ID}
}
AMS.eqIDs[tag.id] = 1;
this.clearTag();
return tag; return tag;
},
clearTag: function () {
var global = this.global;
delete global.tag; delete global.tagID; delete global.label;
},
/*
* If the initial child, skipping any initial space or
* empty braces (TeXAtom with child being an empty inferred row),
* is an <mo>, preceed it by an empty <mi> to force the <mo> to
* be infix.
*/
fixInitialMO: function (data) {
for (var i = 0, m = data.length; i < m; i++) {
if (data[i] && (data[i].type !== "mspace" &&
(data[i].type !== "texatom" || (data[i].data[0] && data[i].data[0].data.length)))) {
if (data[i].isEmbellished()) data.unshift(MML.mi());
break;
}
}
} }
}); });
@ -417,13 +493,18 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
stack.global.tagged = !numbered && !stack.global.forcetag; // prevent automatic tagging in starred environments stack.global.tagged = !numbered && !stack.global.forcetag; // prevent automatic tagging in starred environments
}, },
EndEntry: function () { EndEntry: function () {
if (this.table.length) {this.fixInitialMO(this.data)}
var mtd = MML.mtd.apply(MML,this.data); var mtd = MML.mtd.apply(MML,this.data);
if (this.data.shove) {mtd.columnalign = this.data.shove} if (this.data.shove) {mtd.columnalign = this.data.shove}
this.row.push(mtd); this.row.push(mtd);
this.data = []; this.data = [];
}, },
EndRow: function () { EndRow: function () {
if (this.row.length != 1) {TEX.Error("multline rows must have exactly one column")} if (this.row.length != 1) {
TEX.Error(["MultlineRowsOneCol",
"The rows within the %1 environment must have exactly one column",
"multline"]);
}
this.table.push(this.row); this.row = []; this.table.push(this.row); this.row = [];
}, },
EndTable: function () { EndTable: function () {
@ -459,13 +540,18 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
stack.global.notags = (taggable ? null : name); stack.global.notags = (taggable ? null : name);
stack.global.tagged = !numbered && !stack.global.forcetag; // prevent automatic tagging in starred environments stack.global.tagged = !numbered && !stack.global.forcetag; // prevent automatic tagging in starred environments
}, },
EndEntry: function () {
if (this.row.length) {this.fixInitialMO(this.data)}
this.row.push(MML.mtd.apply(MML,this.data));
this.data = [];
},
EndRow: function () { EndRow: function () {
var mtr = MML.mtr; var mtr = MML.mtr;
if (!this.global.tag && this.numbered) {this.autoTag()} if (!this.global.tag && this.numbered) {this.autoTag()}
if (this.global.tag && !this.global.notags) { if (this.global.tag && !this.global.notags) {
this.row = [this.getTag()].concat(this.row); this.row = [this.getTag()].concat(this.row);
mtr = MML.mlabeledtr; mtr = MML.mlabeledtr;
} } else {this.clearTag()}
if (this.numbered) {delete this.global.notag} if (this.numbered) {delete this.global.notag}
this.table.push(mtr.apply(MML,this.row)); this.row = []; this.table.push(mtr.apply(MML,this.row)); this.row = [];
}, },
@ -491,21 +577,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var def = { var def = {
side: TEX.config.TagSide, side: TEX.config.TagSide,
minlabelspacing: TEX.config.TagIndent, minlabelspacing: TEX.config.TagIndent,
columnalign: mml.displayAlign displaystyle: "inherit" // replaced by TeX input jax Translate() function with actual value
}; };
if (mml.displayAlign === MML.INDENTALIGN.LEFT) {
def.width = "100%";
if (mml.displayIndent && !String(mml.displayIndent).match(/^0+(\.0*)?($|[a-z%])/)) {
def.columnwidth = mml.displayIndent + " fit"; def.columnspacing = "0"
row = [row[0],MML.mtd(),row[1]];
}
} else if (mml.displayAlign === MML.INDENTALIGN.RIGHT) {
def.width = "100%";
if (mml.displayIndent && !String(mml.displayIndent).match(/^0+(\.0*)?($|[a-z%])/)) {
def.columnwidth = "fit "+mml.displayIndent; def.columnspacing = "0"
row[2] = MML.mtd();
}
}
mml = MML.mtable(MML.mlabeledtr.apply(MML,row)).With(def); mml = MML.mtable(MML.mlabeledtr.apply(MML,row)).With(def);
} }
return STACKITEM.mml(mml); return STACKITEM.mml(mml);
@ -522,15 +595,16 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
TEX.prefilterHooks.Add(function (data) { TEX.prefilterHooks.Add(function (data) {
AMS.display = data.display; AMS.display = data.display;
AMS.number = AMS.startNumber; // reset equation numbers (in case the equation restarted) AMS.number = AMS.startNumber; // reset equation numbers (in case the equation restarted)
AMS.eqlabels = {}; AMS.badref = false; AMS.eqlabels = AMS.eqIDs = {}; AMS.badref = false;
if (AMS.refUpdate) {AMS.number = data.script.MathJax.startNumber} if (AMS.refUpdate) {AMS.number = data.script.MathJax.startNumber}
}); });
TEX.postfilterHooks.Add(function (data) { TEX.postfilterHooks.Add(function (data) {
data.script.MathJax.startNumber = AMS.startNumber; data.script.MathJax.startNumber = AMS.startNumber;
AMS.startNumber = AMS.number; // equation numbers for next equation AMS.startNumber = AMS.number; // equation numbers for next equation
MathJax.Hub.Insert(AMS.IDs,AMS.eqIDs); // save IDs from this equation
MathJax.Hub.Insert(AMS.labels,AMS.eqlabels); // save labels from this 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 if (AMS.badref && !data.math.texError) {AMS.refs.push(data.script)} // reprocess later
}); },100);
MathJax.Hub.Register.MessageHook("Begin Math Input",function () { MathJax.Hub.Register.MessageHook("Begin Math Input",function () {
AMS.refs = []; // array of jax with bad references AMS.refs = []; // array of jax with bad references
@ -555,7 +629,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
TEX.resetEquationNumbers = function (n,keepLabels) { TEX.resetEquationNumbers = function (n,keepLabels) {
AMS.startNumber = (n || 0); AMS.startNumber = (n || 0);
if (!keepLabels) {AMS.labels = {}} if (!keepLabels) {AMS.labels = AMS.IDs = {}}
} }
/******************************************************************************/ /******************************************************************************/

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/AMSsymbols.js * MathJax/extensions/TeX/AMSsymbols.js
@ -6,7 +9,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +25,7 @@
*/ */
MathJax.Extension["TeX/AMSsymbols"] = { MathJax.Extension["TeX/AMSsymbols"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
@ -55,22 +58,22 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
daleth: '2138', daleth: '2138',
// Miscellaneous symbols // Miscellaneous symbols
// hbar: '0127', // in MathJax_Main // hbar: '0127', // in TeX/jax.js
backprime: ['2035',{variantForm: true}], backprime: ['2035',{variantForm: true}],
hslash: ['210F',{variantForm: true}], hslash: '210F',
varnothing: ['2205',{variantForm: true}], varnothing: ['2205',{variantForm: true}],
blacktriangle: '25B2', blacktriangle: '25B4',
triangledown: '25BD', triangledown: ['25BD',{variantForm: true}],
blacktriangledown: '25BC', blacktriangledown: '25BE',
square: '25A1', square: '25FB',
Box: '25A1', Box: '25FB',
blacksquare: '25A0', blacksquare: '25FC',
lozenge: '25CA', lozenge: '25CA',
Diamond: '25CA', Diamond: '25CA',
blacklozenge: '29EB', blacklozenge: '29EB',
circledS: ['24C8',{mathvariant: MML.VARIANT.NORMAL}], circledS: ['24C8',{mathvariant: MML.VARIANT.NORMAL}],
bigstar: '2605', bigstar: '2605',
// angle: '2220', // in MathJax_Main // angle: '2220', // in TeX/jax.js
sphericalangle: '2222', sphericalangle: '2222',
measuredangle: '2221', measuredangle: '2221',
nexists: '2204', nexists: '2204',
@ -93,7 +96,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// Binary operators // Binary operators
dotplus: '2214', dotplus: '2214',
ltimes: '22C9', ltimes: '22C9',
smallsetminus: ['2216',{variantForm: true}], smallsetminus: '2216',
rtimes: '22CA', rtimes: '22CA',
Cap: '22D2', Cap: '22D2',
doublecap: '22D2', doublecap: '22D2',
@ -113,7 +116,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
boxdot: '22A1', boxdot: '22A1',
circledcirc: '229A', circledcirc: '229A',
boxplus: '229E', boxplus: '229E',
centerdot: '22C5', centerdot: ['22C5',{variantForm: true}],
divideontimes: '22C7', divideontimes: '22C7',
intercal: '22BA', intercal: '22BA',
@ -177,9 +180,9 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
vDash: '22A8', vDash: '22A8',
Vdash: '22A9', Vdash: '22A9',
Vvdash: '22AA', Vvdash: '22AA',
smallsmile: '2323', smallsmile: ['2323',{variantForm: true}],
shortmid: ['2223',{variantForm: true}], shortmid: ['2223',{variantForm: true}],
smallfrown: '2322', smallfrown: ['2322',{variantForm: true}],
shortparallel: ['2225',{variantForm: true}], shortparallel: ['2225',{variantForm: true}],
bumpeq: '224F', bumpeq: '224F',
between: '226C', between: '226C',
@ -187,8 +190,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
pitchfork: '22D4', pitchfork: '22D4',
varpropto: '221D', varpropto: '221D',
backepsilon: '220D', backepsilon: '220D',
blacktriangleleft: '25C0', blacktriangleleft: '25C2',
blacktriangleright: '25B6', blacktriangleright: '25B8',
therefore: '2234', therefore: '2234',
because: '2235', because: '2235',
eqsim: '2242', eqsim: '2242',
@ -343,59 +346,4 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}); });
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"];
var VARIANT = HTMLCSS.FONTDATA.VARIANT;
if (HTMLCSS.fontInUse === "TeX") {
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}
};
if (HTMLCSS.msieIE6) {
MathJax.Hub.Insert(VARIANT["-TeX-variant"].remap,{
0x2190:[0xE2C1,"-WinIE6"], 0x2192:[0xE2C0,"-WinIE6"],
0x2223:[0xE2C2,"-WinIE6"], 0x2225:[0xE2C3,"-WinIE6"],
0x223C:[0xE2C4,"-WinIE6"], 0x25B3:[0xE2D3,"-WinIE6"]
});
}
}
if (HTMLCSS.fontInUse === "STIX") {
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEXDEF = MathJax.InputJax.TeX.Definitions;
TEXDEF.mathchar0mi.varnothing = '2205';
TEXDEF.mathchar0mi.hslash = '210F';
TEXDEF.mathchar0mi.blacktriangle = '25B4';
TEXDEF.mathchar0mi.blacktriangledown = '25BE';
TEXDEF.mathchar0mi.square = '25FB';
TEXDEF.mathchar0mi.blacksquare = '25FC';
TEXDEF.mathchar0mi.vartriangle = ['25B3',{mathsize:"71%"}];
TEXDEF.mathchar0mi.triangledown = ['25BD',{mathsize:"71%"}];
TEXDEF.mathchar0mo.blacktriangleleft = '25C2';
TEXDEF.mathchar0mo.blacktriangleright = '25B8';
TEXDEF.mathchar0mo.smallsetminus = '2216';
MathJax.Hub.Insert(VARIANT["-STIX-variant"],{
remap: {0x2A87: 0xE010, 0x2A88: 0xE00F, 0x2270: 0xE011, 0x2271: 0xE00E,
0x22E0: 0xE04B, 0x22E1: 0xE04F, 0x2288: 0xE016, 0x2289: 0xE018}
});
});
}
});
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"); MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/AMSsymbols.js");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/HTML.js * MathJax/extensions/TeX/HTML.js
@ -6,7 +9,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2010-2012 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +25,7 @@
*/ */
MathJax.Extension["TeX/HTML"] = { MathJax.Extension["TeX/HTML"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
@ -37,7 +40,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
style: 'STYLE_attribute', style: 'STYLE_attribute',
cssId: 'ID_attribute' cssId: 'ID_attribute'
} }
}); },null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/action.js * MathJax/extensions/TeX/action.js
@ -16,7 +19,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,7 +35,7 @@
*/ */
MathJax.Extension["TeX/action"] = { MathJax.Extension["TeX/action"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
@ -42,9 +45,13 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
// Set up control sequenecs // Set up control sequenecs
// //
TEX.Definitions.macros.toggle = 'Toggle'; TEX.Definitions.Add({
TEX.Definitions.macros.mathtip = 'Mathtip'; macros: {
TEX.Definitions.macros.texttip = ['Macro','\\mathtip{#1}{\\text{#2}}',2]; toggle: 'Toggle',
mathtip: 'Mathtip',
texttip: ['Macro','\\mathtip{#1}{\\text{#2}}',2]
}
},null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/autobold.js * MathJax/extensions/TeX/autobold.js
@ -5,7 +8,9 @@
* Adds \boldsymbol around mathematics that appears in a section * Adds \boldsymbol around mathematics that appears in a section
* of an HTML page that is in bold. * of an HTML page that is in bold.
* *
* Copyright (c) 2009-2012 Design Science, Inc. * ---------------------------------------------------------------------
*
* Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,7 +26,7 @@
*/ */
MathJax.Extension["TeX/autobold"] = { MathJax.Extension["TeX/autobold"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/autoload-all.js * MathJax/extensions/TeX/autoload-all.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2012 Design Science, Inc. * Copyright (c) 2013-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,14 +26,10 @@
*/ */
MathJax.Extension["TeX/autoload-all"] = { MathJax.Extension["TeX/autoload-all"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX,
MACROS = TEX.Definitions.macros,
ENVS = TEX.Definitions.environment;
var EXTENSIONS = { var EXTENSIONS = {
action: ["mathtip","texttip","toggle"], action: ["mathtip","texttip","toggle"],
@ -42,24 +41,37 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
"shoveleft","shoveright","xrightarrow","xleftarrow"], "shoveleft","shoveright","xrightarrow","xleftarrow"],
begingroup: ["begingroup","endgroup","gdef","global"], begingroup: ["begingroup","endgroup","gdef","global"],
cancel: ["cancel","bcancel","xcancel","cancelto"], cancel: ["cancel","bcancel","xcancel","cancelto"],
color: ["color","colorbox","fcolorbox","DefineColor"], color: ["color","textcolor","colorbox","fcolorbox","definecolor"],
enclose: ["enclose"], enclose: ["enclose"],
extpfeil: ["Newextarrow","xlongequal","xmapsto","xtofrom", extpfeil: ["Newextarrow","xlongequal","xmapsto","xtofrom",
"xtwoheadleftarrow","xtwoheadrightarrow"], "xtwoheadleftarrow","xtwoheadrightarrow"],
mhchem: ["ce","cee","cf"] mhchem: ["ce","cee","cf"]
}; };
for (var name in EXTENSIONS) {if (EXTENSIONS.hasOwnProperty(name)) { var ENVIRONMENTS = {
AMSmath: ["subarray","smallmatrix","equation","equation*"],
AMScd: ["CD"]
};
var name, i, m, defs = {macros:{}, environment:{}};
for (name in EXTENSIONS) {if (EXTENSIONS.hasOwnProperty(name)) {
if (!MathJax.Extension["TeX/"+name]) {
var macros = EXTENSIONS[name]; var macros = EXTENSIONS[name];
for (var i = 0, m = macros.length; i < m; i++) { for (i = 0, m = macros.length; i < m; i++)
MACROS[macros[i]] = ["Extension",name]; {defs.macros[macros[i]] = ["Extension",name]}
} }
}} }}
ENVS["subarray"] = ['ExtensionEnv',null,'AMSmath']; for (name in ENVIRONMENTS) {if (ENVIRONMENTS.hasOwnProperty(name)) {
ENVS["smallmatrix"] = ['ExtensionEnv',null,'AMSmath']; if (!MathJax.Extension["TeX/"+name]) {
ENVS["equation"] = ['ExtensionEnv',null,'AMSmath']; var envs = ENVIRONMENTS[name];
ENVS["equation*"] = ['ExtensionEnv',null,'AMSmath']; for (i = 0, m = envs.length; i < m; i++)
{defs.environment[envs[i]] = ["ExtensionEnv",null,name]}
}
}}
MathJax.InputJax.TeX.Definitions.Add(defs);
MathJax.Hub.Startup.signal.Post("TeX autoload-all Ready"); MathJax.Hub.Startup.signal.Post("TeX autoload-all Ready");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/bbox.js * MathJax/extensions/TeX/bbox.js
@ -27,7 +30,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -43,7 +46,7 @@
*/ */
MathJax.Extension["TeX/bbox"] = { MathJax.Extension["TeX/bbox"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
@ -51,28 +54,35 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX, var TEX = MathJax.InputJax.TeX,
MML = MathJax.ElementJax.mml; MML = MathJax.ElementJax.mml;
TEX.Definitions.macros.bbox = "BBox"; TEX.Definitions.Add({macros: {bbox: "BBox"}},null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({
BBox: function (name) { BBox: function (name) {
var bbox = this.GetBrackets(name,""), var bbox = this.GetBrackets(name,""),
math = this.ParseArg(name); math = this.ParseArg(name);
var parts = bbox.split(/,/), def, background, style; var parts = bbox.split(/,/), def, background, style;
for (var i in parts) { for (var i = 0, m = parts.length; i < m; i++) {
var part = parts[i].replace(/^\s+/,'').replace(/\s+$/,''); var part = parts[i].replace(/^\s+/,'').replace(/\s+$/,'');
var match = part.match(/^(\.\d+|\d+(\.\d*)?)(pt|em|ex|mu|px|in|cm|mm)$/); var match = part.match(/^(\.\d+|\d+(\.\d*)?)(pt|em|ex|mu|px|in|cm|mm)$/);
if (match) { if (match) {
if (def)
{TEX.Error(["MultipleBBoxProperty","%1 specified twice in %2","Padding",name])}
var pad = match[1]+match[3]; 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]}; 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)) { } 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)} if (background)
{TEX.Error(["MultipleBBoxProperty","%1 specified twice in %2","Background",name])}
background = part; background = part;
} else if (part.match(/^[-a-z]+:/i)) { } else if (part.match(/^[-a-z]+:/i)) {
if (style) {TEX.Error("Style specified twice in "+name)} if (style)
style = part; {TEX.Error(["MultipleBBoxProperty","%1 specified twice in %2", "Style",name])}
style = this.BBoxStyle(part);
} else if (part !== "") { } else if (part !== "") {
TEX.Error("'"+part+"' doesn't look like a color, a padding dimension, or a style"); TEX.Error(
["InvalidBBoxProperty",
"'%1' doesn't look like a color, a padding dimension, or a style",
part]
);
} }
} }
if (def) {math = MML.mpadded(math).With(def)} if (def) {math = MML.mpadded(math).With(def)}
@ -80,7 +90,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
math = MML.mstyle(math).With({mathbackground:background, style:style}); math = MML.mstyle(math).With({mathbackground:background, style:style});
} }
this.Push(math); this.Push(math);
} },
BBoxStyle: function (styles) {return styles}
}); });
MathJax.Hub.Startup.signal.Post("TeX bbox Ready"); MathJax.Hub.Startup.signal.Post("TeX bbox Ready");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/begingroup.js * MathJax/extensions/TeX/begingroup.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +26,7 @@
*/ */
MathJax.Extension["TeX/begingroup"] = { MathJax.Extension["TeX/begingroup"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
@ -100,7 +103,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
Init: function (eqn) { Init: function (eqn) {
this.isEqn = eqn; this.stack = []; this.isEqn = eqn; this.stack = [];
if (!eqn) {this.Push(NSFRAME(TEXDEF.macros,TEXDEF.environments))} if (!eqn) {this.Push(NSFRAME(TEXDEF.macros,TEXDEF.environment))}
else {this.Push(NSFRAME())} else {this.Push(NSFRAME())}
}, },
// //
@ -186,10 +189,14 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
// Define the new macros // Define the new macros
// //
TEXDEF.macros.begingroup = "BeginGroup"; TEXDEF.Add({
TEXDEF.macros.endgroup = "EndGroup"; macros: {
TEXDEF.macros.global = ["Extension","newcommand"]; begingroup: "BeginGroup",
TEXDEF.macros.gdef = ["Extension","newcommand"]; endgroup: "EndGroup",
global: ["Extension","newcommand"],
gdef: ["Extension","newcommand"]
}
},null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({
// //
@ -209,7 +216,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
if (TEX.eqnStack.top > 1) { if (TEX.eqnStack.top > 1) {
TEX.eqnStack.Pop(); TEX.eqnStack.Pop();
} else if (TEX.rootStack.top === 1) { } else if (TEX.rootStack.top === 1) {
TEX.Error("Extra "+name+" or missing \\begingroup"); TEX.Error(["ExtraEndMissingBegin","Extra %1 or missing \\begingroup",name]);
} else { } else {
TEX.eqnStack.Clear(); TEX.eqnStack.Clear();
TEX.rootStack.Pop(); TEX.rootStack.Pop();
@ -257,8 +264,12 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
// Add the commands that depend on the newcommand code // Add the commands that depend on the newcommand code
// //
TEXDEF.macros.global = "Global"; TEXDEF.Add({
TEXDEF.macros.gdef = ["Macro","\\global\\def"]; macros: {
global: "Global",
gdef: ["Macro","\\global\\def"]
}
},null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({
// //
@ -280,8 +291,10 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
Global: function (name) { Global: function (name) {
var i = this.i; var cs = this.GetCSname(name); this.i = i; var i = this.i; var cs = this.GetCSname(name); this.i = i;
if (cs !== "let" && cs !== "def" && cs !== "newcommand") if (cs !== "let" && cs !== "def" && cs !== "newcommand") {
{TEX.Error(name+" not followed by \\let, \\def, or \\newcommand")} TEX.Error(["GlobalNotFollowedBy",
"%1 not followed by \\let, \\def, or \\newcommand",name]);
}
this.stack.env.isGlobal = true; this.stack.env.isGlobal = true;
} }

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/boldsymbol.js * MathJax/extensions/TeX/boldsymbol.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +26,7 @@
*/ */
MathJax.Extension["TeX/boldsymbol"] = { MathJax.Extension["TeX/boldsymbol"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
@ -41,7 +44,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
BOLDVARIANT["-tex-caligraphic"] = "-tex-caligraphic-bold"; BOLDVARIANT["-tex-caligraphic"] = "-tex-caligraphic-bold";
BOLDVARIANT["-tex-oldstyle"] = "-tex-oldstyle-bold"; BOLDVARIANT["-tex-oldstyle"] = "-tex-oldstyle-bold";
TEXDEF.macros.boldsymbol = 'Boldsymbol'; TEXDEF.Add({macros: {boldsymbol: 'Boldsymbol'}},null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({
mmlToken: function (token) { mmlToken: function (token) {
@ -69,58 +72,4 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}); });
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"];
var FONTS = HTMLCSS.FONTDATA.FONTS;
var VARIANT = HTMLCSS.FONTDATA.VARIANT;
if (HTMLCSS.fontInUse === "TeX") {
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"]};
if (HTMLCSS.msieCheckGreek && HTMLCSS.Font.testFont({
family:"MathJax_Greek", weight:"bold", style:"italic", testString: HTMLCSS.msieCheckGreek
})) {
VARIANT["bold-italic"].offsetG = 0x391; VARIANT["bold-italic"].variantG = "-Greek-Bold-Italic";
VARIANT["-Greek-Bold-Italic"] = {fonts:["MathJax_Greek-bold-italic"]};
FONTS["MathJax_Greek-bold-italic"] = "Greek/BoldItalic/Main.js";
}
if (MathJax.Hub.Browser.isChrome && !MathJax.Hub.Browser.versionAtLeast("5.0")) {
VARIANT["-tex-caligraphic-bold"].remap = {0x54: [0xE2F0,"-WinChrome"]};
}
} else if (HTMLCSS.fontInUse === "STIX") {
VARIANT["-tex-caligraphic-bold"] = {
fonts:["STIXGeneral-bold-italic","STIXNonUnicode-bold-italic","STIXNonUnicode","STIXGeneral","STIXSizeOneSym"],
offsetA: 0xE247, noLowerCase: 1
};
VARIANT["-tex-oldstyle-bold"] = {
fonts:["STIXGeneral-bold","STIXNonUnicode-bold","STIXGeneral","STIXSizeOneSym"], offsetN: 0xE263,
remap: {0xE264: 0xE267, 0xE265: 0xE26B, 0xE266: 0xE26F, 0xE267: 0xE273,
0xE268: 0xE277, 0xE269: 0xE27B, 0xE26A: 0xE27F, 0xE26B: 0xE283,
0xE26C: 0xE287}
};
}
});
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"); MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/boldsymbol.js");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/cancel.js * MathJax/extensions/TeX/cancel.js
@ -13,7 +16,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,13 +32,12 @@
*/ */
MathJax.Extension["TeX/cancel"] = { MathJax.Extension["TeX/cancel"] = {
version: "2.0", version: "2.6.0",
// //
// The attributes allowed in \enclose{notation}[attributes]{math} // The attributes allowed in \enclose{notation}[attributes]{math}
// //
ALLOWED: { ALLOWED: {
arrow: 1,
color: 1, mathcolor: 1, color: 1, mathcolor: 1,
background: 1, mathbackground: 1, background: 1, mathbackground: 1,
padding: 1, padding: 1,
@ -45,7 +47,6 @@ MathJax.Extension["TeX/cancel"] = {
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX, var TEX = MathJax.InputJax.TeX,
MACROS = TEX.Definitions.macros,
MML = MathJax.ElementJax.mml, MML = MathJax.ElementJax.mml,
CANCEL = MathJax.Extension["TeX/cancel"]; CANCEL = MathJax.Extension["TeX/cancel"];
@ -65,12 +66,16 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}; };
// //
// Set up macro // Set up macros
// //
MACROS.cancel = ['Cancel',MML.NOTATION.UPDIAGONALSTRIKE]; TEX.Definitions.Add({
MACROS.bcancel = ['Cancel',MML.NOTATION.DOWNDIAGONALSTRIKE]; macros: {
MACROS.xcancel = ['Cancel',MML.NOTATION.UPDIAGONALSTRIKE+" "+MML.NOTATION.DOWNDIAGONALSTRIKE]; cancel: ['Cancel',MML.NOTATION.UPDIAGONALSTRIKE],
MACROS.cancelto = 'CancelTo'; bcancel: ['Cancel',MML.NOTATION.DOWNDIAGONALSTRIKE],
xcancel: ['Cancel',MML.NOTATION.UPDIAGONALSTRIKE+" "+MML.NOTATION.DOWNDIAGONALSTRIKE],
cancelto: 'CancelTo'
}
},null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({
// //
@ -91,7 +96,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var value = this.ParseArg(name), var value = this.ParseArg(name),
attr = this.GetBrackets(name,""), attr = this.GetBrackets(name,""),
math = this.ParseArg(name); math = this.ParseArg(name);
var def = CANCEL.setAttributes({notation: MML.NOTATION.UPDIAGONALSTRIKE, arrow:true},attr); var def = CANCEL.setAttributes({notation: MML.NOTATION.UPDIAGONALSTRIKE+" "+MML.NOTATION.UPDIAGONALARROW},attr);
value = MML.mpadded(value).With({depth:"-.1em",height:"+.1em",voffset:".1em"}); value = MML.mpadded(value).With({depth:"-.1em",height:"+.1em",voffset:".1em"});
this.Push(MML.msup(MML.menclose(math).With(def),value)); this.Push(MML.msup(MML.menclose(math).With(def),value));
} }

View File

@ -1,14 +1,18 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/color.js * MathJax/extensions/TeX/color.js
* *
* Implements LaTeX-compatible \color macro rather than MathJax's * Implements LaTeX-compatible \color macro rather than MathJax's original
* original (non-standard) version. It includes the rgb, gray, and * (non-standard) version. It includes the rgb, RGB, gray, and named color
* named color models, and the \definecolor macro. * models, and the \textcolor, \definecolor, \colorbox, and \fcolorbox
* macros.
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +31,7 @@
// The configuration defaults, augmented by the user settings // The configuration defaults, augmented by the user settings
// //
MathJax.Extension["TeX/color"] = { MathJax.Extension["TeX/color"] = {
version: "2.0", version: "2.6.0",
config: MathJax.Hub.CombineConfig("TeX.color",{ config: MathJax.Hub.CombineConfig("TeX.color",{
padding: "5px", padding: "5px",
@ -111,21 +115,49 @@ MathJax.Extension["TeX/color"] = {
getColor: function (model,def) { getColor: function (model,def) {
if (!model) {model = "named"} if (!model) {model = "named"}
var fn = this["get_"+model]; var fn = this["get_"+model];
if (!fn) {this.TEX.Error("Color model '"+model+"' not defined")} if (!fn) {this.TEX.Error(["UndefinedColorModel","Color model '%1' not defined",model])}
return fn.call(this,def); return fn.call(this,def);
}, },
/*
* Get an rgb color
*/
get_rgb: function (rgb) {
rgb = rgb.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s*,\s*/); var RGB = "#";
if (rgb.length !== 3)
{this.TEX.Error(["ModelArg1","Color values for the %1 model require 3 numbers","rgb"])}
for (var i = 0; i < 3; i++) {
if (!rgb[i].match(/^(\d+(\.\d*)?|\.\d+)$/))
{this.TEX.Error(["InvalidDecimalNumber","Invalid decimal number"])}
var n = parseFloat(rgb[i]);
if (n < 0 || n > 1) {
this.TEX.Error(["ModelArg2",
"Color values for the %1 model must be between %2 and %3",
"rgb",0,1]);
}
n = Math.floor(n*255).toString(16); if (n.length < 2) {n = "0"+n}
RGB += n;
}
return RGB;
},
/* /*
* Get an RGB color * Get an RGB color
*/ */
get_rgb: function (rgb) { get_RGB: function (rgb) {
rgb = rgb.split(/,/); var RGB = "#"; rgb = rgb.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s*,\s*/); var RGB = "#";
if (rgb.length !== 3) {this.TEX.Error("RGB colors require 3 decimal numbers")} if (rgb.length !== 3)
{this.TEX.Error(["ModelArg1","Color values for the %1 model require 3 numbers","RGB"])}
for (var i = 0; i < 3; i++) { for (var i = 0; i < 3; i++) {
if (!rgb[i].match(/^(\d+(\.\d*)?|\.\d+)$/)) {this.TEX.Error("Invalid decimal number")} if (!rgb[i].match(/^\d+$/))
var n = parseFloat(rgb[i]); {this.TEX.Error(["InvalidNumber","Invalid number"])}
if (n < 0 || n > 1) {this.TEX.Error("RGB values must be between 0 and 1")} var n = parseInt(rgb[i]);
n = Math.floor(n*255).toString(16); if (n.length < 2) {n = "0"+n} if (n > 255) {
this.TEX.Error(["ModelArg2",
"Color values for the %1 model must be between %2 and %3",
"RGB",0,255]);
}
n = n.toString(16); if (n.length < 2) {n = "0"+n}
RGB += n; RGB += n;
} }
return RGB; return RGB;
@ -135,9 +167,14 @@ MathJax.Extension["TeX/color"] = {
* Get a gray-scale value * Get a gray-scale value
*/ */
get_gray: function (gray) { get_gray: function (gray) {
if (!gray.match(/^(\d+(\.\d*)?|\.\d+)$/)) {this.TEX.Error("Invalid decimal number")} if (!gray.match(/^\s*(\d+(\.\d*)?|\.\d+)\s*$/))
{this.TEX.Error(["InvalidDecimalNumber","Invalid decimal number"])}
var n = parseFloat(gray); var n = parseFloat(gray);
if (n < 0 || n > 1) {this.TEX.Error("Grey-scale values must be between 0 and 1")} if (n < 0 || n > 1) {
this.TEX.Error(["ModelArg2",
"Color values for the %1 model must be between %2 and %3",
"gray",0,1]);
}
n = Math.floor(n*255).toString(16); if (n.length < 2) {n = "0"+n} n = Math.floor(n*255).toString(16); if (n.length < 2) {n = "0"+n}
return "#"+n+n+n; return "#"+n+n+n;
}, },
@ -167,10 +204,15 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
COLOR.TEX = TEX; // for reference in getColor above COLOR.TEX = TEX; // for reference in getColor above
TEX.Definitions.macros.color = "Color"; TEX.Definitions.Add({
TEX.Definitions.macros.definecolor = "DefineColor"; macros: {
TEX.Definitions.macros.colorbox = "ColorBox"; color: "Color",
TEX.Definitions.macros.fcolorbox = "fColorBox"; textcolor: "TextColor",
definecolor: "DefineColor",
colorbox: "ColorBox",
fcolorbox: "fColorBox"
}
},null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({
@ -186,6 +228,16 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
this.Push(mml); this.Push(mml);
}, },
TextColor: function (name) {
var model = this.GetBrackets(name),
color = this.GetArgument(name);
color = COLOR.getColor(model,color);
var old = this.stack.env.color; this.stack.env.color = color;
var math = this.ParseArg(name);
if (old) {this.stack.env.color} else {delete this.stack.env.color}
this.Push(MML.mstyle(math).With({mathcolor: color}));
},
// //
// Define the \definecolor macro // Define the \definecolor macro
// //

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/enclose.js * MathJax/extensions/TeX/enclose.js
@ -13,7 +16,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,7 +32,7 @@
*/ */
MathJax.Extension["TeX/enclose"] = { MathJax.Extension["TeX/enclose"] = {
version: "2.0", version: "2.6.0",
// //
// The attributes allowed in \enclose{notation}[attributes]{math} // The attributes allowed in \enclose{notation}[attributes]{math}
@ -51,7 +54,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
// Set up macro // Set up macro
// //
TEX.Definitions.macros.enclose = 'Enclose'; TEX.Definitions.Add({macros: {enclose: 'Enclose'}},null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({
// //
@ -71,7 +74,9 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
keyvalue[1] = keyvalue[1].replace(/^"(.*)"$/,"$1"); keyvalue[1] = keyvalue[1].replace(/^"(.*)"$/,"$1");
if (keyvalue[1] === "true") {keyvalue[1] = true} if (keyvalue[1] === "true") {keyvalue[1] = true}
if (keyvalue[1] === "false") {keyvalue[1] = false} if (keyvalue[1] === "false") {keyvalue[1] = false}
def[keyvalue[0]] = keyvalue[1]; if (keyvalue[0] === "arrow" && keyvalue[1])
{def.notation = def.notation + " updiagonalarrow"} else
{def[keyvalue[0]] = keyvalue[1]}
} }
} }
} }

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/extpfeil.js * MathJax/extensions/TeX/extpfeil.js
@ -6,7 +9,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +25,7 @@
*/ */
MathJax.Extension["TeX/extpfeil"] = { MathJax.Extension["TeX/extpfeil"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
@ -34,7 +37,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// Define the arrows to load the AMSmath extension // Define the arrows to load the AMSmath extension
// (since they need its xArrow method) // (since they need its xArrow method)
// //
MathJax.Hub.Insert(TEXDEF,{ TEXDEF.Add({
macros: { macros: {
xtwoheadrightarrow: ['Extension','AMSmath'], xtwoheadrightarrow: ['Extension','AMSmath'],
xtwoheadleftarrow: ['Extension','AMSmath'], xtwoheadleftarrow: ['Extension','AMSmath'],
@ -43,7 +46,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
xtofrom: ['Extension','AMSmath'], xtofrom: ['Extension','AMSmath'],
Newextarrow: ['Extension','AMSmath'] Newextarrow: ['Extension','AMSmath']
} }
}); },null,true);
// //
// Redefine the macros when AMSmath is loaded // Redefine the macros when AMSmath is loaded
@ -70,12 +73,24 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var cs = this.GetArgument(name), var cs = this.GetArgument(name),
space = this.GetArgument(name), space = this.GetArgument(name),
chr = this.GetArgument(name); chr = this.GetArgument(name);
if (!cs.match(/^\\([a-z]+|.)$/i)) if (!cs.match(/^\\([a-z]+|.)$/i)) {
{TEX.Error("First argument to "+name+" must be a control sequence name")} TEX.Error(["NewextarrowArg1",
if (!space.match(/^(\d+),(\d+)$/)) "First argument to %1 must be a control sequence name",name]);
{TEX.Error("Second argument to "+name+" must be two integers separated by a comma")} }
if (!chr.match(/^(\d+|0x[0-9A-F]+)$/i)) if (!space.match(/^(\d+),(\d+)$/)) {
{TEX.Error("Third argument to "+name+" must be a unicode character number")} TEX.Error(
["NewextarrowArg2",
"Second argument to %1 must be two integers separated by a comma",
name]
);
}
if (!chr.match(/^(\d+|0x[0-9A-F]+)$/i)) {
TEX.Error(
["NewextarrowArg3",
"Third argument to %1 must be a unicode character number",
name]
);
}
cs = cs.substr(1); space = space.split(","); chr = parseInt(chr); cs = cs.substr(1); space = space.split(","); chr = parseInt(chr);
TEXDEF.macros[cs] = ['xArrow',chr,parseInt(space[0]),parseInt(space[1])]; TEXDEF.macros[cs] = ['xArrow',chr,parseInt(space[0]),parseInt(space[1])];
} }

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/mathchoice.js * MathJax/extensions/TeX/mathchoice.js
@ -6,7 +9,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,16 +25,15 @@
*/ */
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var VERSION = "2.0"; var VERSION = "2.6.0";
var MML = MathJax.ElementJax.mml; var MML = MathJax.ElementJax.mml;
var TEX = MathJax.InputJax.TeX; var TEX = MathJax.InputJax.TeX;
var TEXDEF = TEX.Definitions; var TEXDEF = TEX.Definitions;
TEXDEF.macros.mathchoice = 'MathChoice'; TEXDEF.Add({macros: {mathchoice: 'MathChoice'}},null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({
MathChoice: function (name) { MathChoice: function (name) {
var D = this.ParseArg(name), var D = this.ParseArg(name),
T = this.ParseArg(name), T = this.ParseArg(name),
@ -39,20 +41,29 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
SS = this.ParseArg(name); SS = this.ParseArg(name);
this.Push(MML.TeXmathchoice(D,T,S,SS)); this.Push(MML.TeXmathchoice(D,T,S,SS));
} }
}); });
MML.TeXmathchoice = MML.mbase.Subclass({ MML.TeXmathchoice = MML.mbase.Subclass({
type: "TeXmathchoice", type: "TeXmathchoice", notParent: true,
choice: function () { choice: function () {
var values = this.getValues("displaystyle","scriptlevel"); if (this.selection != null) return this.selection;
if (values.scriptlevel > 0) {return Math.min(3,values.scriptlevel + 1)} if (this.choosing) return 2; // prevent infinite loops: see issue #1151
return (values.displaystyle ? 0 : 1); this.choosing = true;
var selection = 0, values = this.getValues("displaystyle","scriptlevel");
if (values.scriptlevel > 0) {selection = Math.min(3,values.scriptlevel+1)}
else {selection = (values.displaystyle ? 0 : 1)}
// only cache the result if we are actually in place in a <math> tag.
var node = this.inherit; while (node && node.type !== "math") node = node.inherit;
if (node) this.selection = selection;
this.choosing = false;
return selection;
}, },
setTeXclass: function (prev) {return this.Core().setTeXclass(prev)}, selected: function () {return this.data[this.choice()]},
isSpacelike: function () {return this.Core().isSpacelike()}, setTeXclass: function (prev) {return this.selected().setTeXclass(prev)},
isEmbellished: function () {return this.Core().isEmbellished()}, isSpacelike: function () {return this.selected().isSpacelike()},
Core: function () {return this.data[this.choice()]}, isEmbellished: function () {return this.selected().isEmbellished()},
Core: function () {return this.selected()},
CoreMO: function () {return this.selected().CoreMO()},
toHTML: function (span) { toHTML: function (span) {
span = this.HTMLcreateSpan(span); span = this.HTMLcreateSpan(span);
span.bbox = this.Core().toHTML(span).bbox; span.bbox = this.Core().toHTML(span).bbox;
@ -68,7 +79,25 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
} }
return span; return span;
}, },
toSVG: function () {return this.Core().toSVG()} toSVG: function () {
var svg = this.Core().toSVG();
this.SVGsaveData(svg);
return svg;
},
toCommonHTML: function (node) {
node = this.CHTMLcreateNode(node);
this.CHTMLhandleStyle(node);
this.CHTMLhandleColor(node);
this.CHTMLaddChild(node,this.choice(),{});
return node;
},
toPreviewHTML: function(span) {
span = this.PHTMLcreateSpan(span);
this.PHTMLhandleStyle(span);
this.PHTMLhandleColor(span);
this.PHTMLaddChild(span,this.choice(),{});
return span;
}
}); });
MathJax.Hub.Startup.signal.Post("TeX mathchoice Ready"); MathJax.Hub.Startup.signal.Post("TeX mathchoice Ready");

View File

@ -0,0 +1,106 @@
MathJax.Extension["TeX/mediawiki-texvc"] = {
version: "2.6.0-beta.2"
};
MathJax.Hub.Register.StartupHook("TeX Jax Ready", function () {
MathJax.InputJax.TeX.Definitions.Add({
macros: {
AA: ["Macro", "\u00c5"],
alef: ["Macro", "\\aleph"],
alefsym: ["Macro", "\\aleph"],
Alpha: ["Macro", "\\mathrm{A}"],
and: ["Macro", "\\land"],
ang: ["Macro", "\\angle"],
Bbb: ["Macro", "\\mathbb"],
Beta: ["Macro", "\\mathrm{B}"],
bold: ["Macro", "\\mathbf"],
bull: ["Macro", "\\bullet"],
C: ["Macro", "\\mathbb{C}"],
Chi: ["Macro", "\\mathrm{X}"],
clubs: ["Macro", "\\clubsuit"],
cnums: ["Macro", "\\mathbb{C}"],
Complex: ["Macro", "\\mathbb{C}"],
coppa: ["Macro", "\u03D9"],
Coppa: ["Macro", "\u03D8"],
Dagger: ["Macro", "\\ddagger"],
Digamma: ["Macro", "\u03DC"],
darr: ["Macro", "\\downarrow"],
dArr: ["Macro", "\\Downarrow"],
Darr: ["Macro", "\\Downarrow"],
diamonds: ["Macro", "\\diamondsuit"],
empty: ["Macro", "\\emptyset"],
Epsilon: ["Macro", "\\mathrm{E}"],
Eta: ["Macro", "\\mathrm{H}"],
euro: ["Macro", "\u20AC"],
exist: ["Macro", "\\exists"],
geneuro: ["Macro", "\u20AC"],
geneuronarrow: ["Macro", "\u20AC"],
geneurowide: ["Macro", "\u20AC"],
H: ["Macro", "\\mathbb{H}"],
hAar: ["Macro", "\\Leftrightarrow"],
harr: ["Macro", "\\leftrightarrow"],
Harr: ["Macro", "\\Leftrightarrow"],
hearts: ["Macro", "\\heartsuit"],
image: ["Macro", "\\Im"],
infin: ["Macro", "\\infty"],
Iota: ["Macro", "\\mathrm{I}"],
isin: ["Macro", "\\in"],
Kappa: ["Macro", "\\mathrm{K}"],
koppa: ["Macro", "\u03DF"],
Koppa: ["Macro", "\u03DE"],
lang: ["Macro", "\\langle"],
larr: ["Macro", "\\leftarrow"],
Larr: ["Macro", "\\Leftarrow"],
lArr: ["Macro", "\\Leftarrow"],
lrarr: ["Macro", "\\leftrightarrow"],
Lrarr: ["Macro", "\\Leftrightarrow"],
lrArr: ["Macro", "\\Leftrightarrow"],
Mu: ["Macro", "\\mathrm{M}"],
N: ["Macro", "\\mathbb{N}"],
natnums: ["Macro", "\\mathbb{N}"],
Nu: ["Macro", "\\mathrm{N}"],
O: ["Macro", "\\emptyset"],
officialeuro: ["Macro", "\u20AC"],
Omicron: ["Macro", "\\mathrm{O}"],
or: ["Macro", "\\lor"],
P: ["Macro", "\u00B6"],
pagecolor: ['Macro','',1], // ignore \pagecolor{}
part: ["Macro", "\\partial"],
plusmn: ["Macro", "\\pm"],
Q: ["Macro", "\\mathbb{Q}"],
R: ["Macro", "\\mathbb{R}"],
rang: ["Macro", "\\rangle"],
rarr: ["Macro", "\\rightarrow"],
Rarr: ["Macro", "\\Rightarrow"],
rArr: ["Macro", "\\Rightarrow"],
real: ["Macro", "\\Re"],
reals: ["Macro", "\\mathbb{R}"],
Reals: ["Macro", "\\mathbb{R}"],
Rho: ["Macro", "\\mathrm{P}"],
sdot: ["Macro", "\\cdot"],
sampi: ["Macro", "\u03E1"],
Sampi: ["Macro", "\u03E0"],
sect: ["Macro", "\\S"],
spades: ["Macro", "\\spadesuit"],
stigma: ["Macro", "\u03DB"],
Stigma: ["Macro", "\u03DA"],
sub: ["Macro", "\\subset"],
sube: ["Macro", "\\subseteq"],
supe: ["Macro", "\\supseteq"],
Tau: ["Macro", "\\mathrm{T}"],
textvisiblespace: ["Macro", "\u2423"],
thetasym: ["Macro", "\\vartheta"],
uarr: ["Macro", "\\uparrow"],
uArr: ["Macro", "\\Uparrow"],
Uarr: ["Macro", "\\Uparrow"],
varcoppa: ["Macro", "\u03D9"],
varstigma: ["Macro", "\u03DB"],
vline: ['Macro','\\smash{\\large\\lvert}',0],
weierp: ["Macro", "\\wp"],
Z: ["Macro", "\\mathbb{Z}"],
Zeta: ["Macro", "\\mathrm{Z}"]
}
});
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/mediawiki-texvc.js");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/mhchem.js * MathJax/extensions/TeX/mhchem.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,13 +26,12 @@
*/ */
MathJax.Extension["TeX/mhchem"] = { MathJax.Extension["TeX/mhchem"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX, var TEX = MathJax.InputJax.TeX;
MACROS = TEX.Definitions.macros;
/* /*
* This is the main class for handing the \ce and related commands. * This is the main class for handing the \ce and related commands.
@ -40,10 +42,13 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var CE = MathJax.Object.Subclass({ var CE = MathJax.Object.Subclass({
string: "", // the \ce string being parsed string: "", // the \ce string being parsed
i: 0, // the current position in the string i: 0, // the current position in the string
tex: "", // the processed TeX result tex: "", // the partially processed TeX result
TEX: "", // the full TeX result
atom: false, // last processed token is an atom atom: false, // last processed token is an atom
sup: "", // pending superscript sup: "", // pending superscript
sub: "", // pending subscript sub: "", // pending subscript
presup: "", // pending pre-superscript
presub: "", // pending pre-subscript
// //
// Store the string when a CE object is created // Store the string when a CE object is created
@ -81,6 +86,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
'<->': "leftrightarrow", '<->': "leftrightarrow",
'<=>': "rightleftharpoons", '<=>': "rightleftharpoons",
'<=>>': "Rightleftharpoons", '<=>>': "Rightleftharpoons",
'<<=>': "Leftrightharpoons",
'^': "uparrow", '^': "uparrow",
'v': "downarrow" 'v': "downarrow"
}, },
@ -118,8 +124,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
else if (c.match(/[0-9]/)) {this.ParseNumber()} else if (c.match(/[0-9]/)) {this.ParseNumber()}
else {this["Parse"+(this.ParseTable[c]||"Other")](c)} else {this["Parse"+(this.ParseTable[c]||"Other")](c)}
} }
this.FinishAtom(); this.FinishAtom(true);
return this.tex; return this.TEX;
}, },
// //
@ -136,7 +142,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}, },
// //
// Make a number of fraction preceeding an atom, // Make a number or fraction preceeding an atom,
// or a subscript for an atom. // or a subscript for an atom.
// //
ParseNumber: function () { ParseNumber: function () {
@ -204,7 +210,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
ParseLess: function (c) { ParseLess: function (c) {
this.FinishAtom(); this.FinishAtom();
var arrow = this.Match(/^(<->?|<=>>?)/); var arrow = this.Match(/^(<->?|<=>>?|<<=>)/);
if (!arrow) {this.tex += c; this.i++} else {this.AddArrow(arrow)} if (!arrow) {this.tex += c; this.i++} else {this.AddArrow(arrow)}
}, },
@ -215,7 +221,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
c = this.string.charAt(++this.i); c = this.string.charAt(++this.i);
if (c === "{") { if (c === "{") {
this.i++; var m = this.Find("}"); this.i++; var m = this.Find("}");
if (m === "-.") {this.sup += "{-}{\\cdot}"} else if (m) {this.sup += CE(m).Parse()} if (m === "-.") {this.sup += "{-}{\\cdot}"}
else if (m) {this.sup += CE(m).Parse().replace(/^\{-\}/,"-")}
} else if (c === " " || c === "") { } else if (c === " " || c === "") {
this.tex += "{\\"+this.Arrows["^"]+"}"; this.i++; this.tex += "{\\"+this.Arrows["^"]+"}"; this.i++;
} else { } else {
@ -228,7 +235,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
ParseSubscript: function (c) { ParseSubscript: function (c) {
if (this.string.charAt(++this.i) == "{") { if (this.string.charAt(++this.i) == "{") {
this.i++; this.sub += CE(this.Find("}")).Parse(); this.i++; this.sub += CE(this.Find("}")).Parse().replace(/^\{-\}/,"-");
} else { } else {
var n = this.Match(/^\d+/); var n = this.Match(/^\d+/);
if (n) {this.sub += n} if (n) {this.sub += n}
@ -294,23 +301,34 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
// Handle the super and subscripts for an atom // Handle the super and subscripts for an atom
// //
FinishAtom: function () { FinishAtom: function (force) {
if (this.sup || this.sub) { if (this.sup || this.sub || this.presup || this.presub) {
if (this.sup && this.sub && !this.atom) { if (!force && !this.atom) {
// if (this.tex === "" && !this.sup && !this.sub) return;
// right-justify super- and subscripts when they are before the atom if (!this.presup && !this.presub &&
// (this.tex === "" || this.tex === "{" ||
var n = Math.abs(this.sup.length-this.sub.length); (this.tex === "}" && this.TEX.substr(-1) === "{"))) {
if (n) { this.presup = this.sup, this.presub = this.sub; // save for later
var zeros = "0000000000".substr(0,n); this.sub = this.sup = "";
var script = (this.sup.length > this.sub.length ? "sub" : "sup"); this.TEX += this.tex; this.tex = "";
this[script] = "\\phantom{"+zeros+"}" + this[script]; return;
} }
} }
if (!this.sup) {this.sup = "\\Space{0pt}{0pt}{.2em}"} // forces subscripts to align properly if (this.sub && !this.sup) {this.sup = "\\Space{0pt}{0pt}{.2em}"} // forces subscripts to align properly
this.tex += "^{"+this.sup+"}_{"+this.sub+"}"; if ((this.presup || this.presub) && this.tex !== "{") {
if (!this.presup && !this.sup) {this.presup = "\\Space{0pt}{0pt}{.2em}"}
this.tex = "\\CEprescripts{"+(this.presub||"\\CEnone")+"}{"+(this.presup||"\\CEnone")+"}"
+ "{"+(this.tex !== "}" ? this.tex : "")+"}"
+ "{"+(this.sub||"\\CEnone")+"}{"+(this.sup||"\\CEnone")+"}"
+ (this.tex === "}" ? "}" : "");
this.presub = this.presup = "";
} else {
if (this.sup) this.tex += "^{"+this.sup+"}";
if (this.sub) this.tex += "_{"+this.sub+"}";
}
this.sup = this.sub = ""; this.sup = this.sub = "";
} }
this.TEX += this.tex; this.tex = "";
this.atom = false; this.atom = false;
}, },
@ -349,46 +367,93 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
if (C === "{") {braces++} else if (C === "{") {braces++} else
if (C === "}") { if (C === "}") {
if (braces) {braces--} if (braces) {braces--}
else {TEX.Error("Extra close brace or missing open brace")} else {
TEX.Error(["ExtraCloseMissingOpen","Extra close brace or missing open brace"])
} }
} }
if (braces) {TEX.Error("Missing close brace")}; }
TEX.Error("Can't find closing "+c); if (braces) {TEX.Error(["MissingCloseBrace","Missing close brace"])}
TEX.Error(["NoClosingChar","Can't find closing %1",c]);
} }
}); });
MathJax.Extension["TeX/mhchem"].CE = CE;
/***************************************************************************/ /***************************************************************************/
TEX.Definitions.Add({
macros: {
// //
// Set up the macros for chemistry // Set up the macros for chemistry
// //
MACROS.ce = 'CE'; ce: 'CE',
MACROS.cf = 'CE'; cf: 'CE',
MACROS.cee = 'CE'; cee: 'CE',
// //
// Include some missing arrows (some are hacks) // Make these load AMSmath package (redefined below when loaded)
// //
MACROS.xleftrightarrow = ['xArrow',0x2194,6,6]; xleftrightarrow: ['Extension','AMSmath'],
MACROS.xrightleftharpoons = ['xArrow',0x21CC,5,7]; // FIXME: doesn't stretch in HTML-CSS output xrightleftharpoons: ['Extension','AMSmath'],
MACROS.xRightleftharpoons = ['xArrow',0x21CC,5,7]; // FIXME: how should this be handled? xRightleftharpoons: ['Extension','AMSmath'],
xLeftrightharpoons: ['Extension','AMSmath'],
// FIXME: These don't work well in FF NativeMML mode // FIXME: These don't work well in FF NativeMML mode
MACROS.longrightleftharpoons = ["Macro","\\stackrel{\\textstyle{{-}\\!\\!{\\rightharpoonup}}}{\\smash{{\\leftharpoondown}\\!\\!{-}}}"]; longrightleftharpoons: ["Macro","\\stackrel{\\textstyle{{-}\\!\\!{\\rightharpoonup}}}{\\smash{{\\leftharpoondown}\\!\\!{-}}}"],
MACROS.longRightleftharpoons = ["Macro","\\stackrel{\\textstyle{-}\\!\\!{\\rightharpoonup}}{\\small\\smash\\leftharpoondown}"]; longRightleftharpoons: ["Macro","\\stackrel{\\textstyle{-}\\!\\!{\\rightharpoonup}}{\\small\\smash\\leftharpoondown}"],
longLeftrightharpoons: ["Macro","\\stackrel{\\rightharpoonup}{{{\\leftharpoondown}\\!\\!\\textstyle{-}}}"],
//
// 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 // Add \hyphen used in some mhchem examples
// //
MACROS.hyphen = ["Macro","\\text{-}"]; hyphen: ["Macro","\\text{-}"],
//
// Handle prescripts and none
//
CEprescripts: "CEprescripts",
CEnone: "CEnone",
//
// Needed for \bond for the ~ forms
//
tripledash: ["Macro","\\raise3mu{\\tiny\\text{-}\\kern2mu\\text{-}\\kern2mu\\text{-}}"]
},
//
// Needed for \bond for the ~ forms
//
environment: {
CEstack: ['Array',null,null,null,'r',null,"0.001em",'T',1]
}
},null,true);
if (!MathJax.Extension["TeX/AMSmath"]) {
TEX.Definitions.Add({
macros: {
xrightarrow: ['Extension','AMSmath'],
xleftarrow: ['Extension','AMSmath']
}
},null,true);
}
//
// These arrows need to wait until AMSmath is loaded
//
MathJax.Hub.Register.StartupHook("TeX AMSmath Ready",function () {
TEX.Definitions.Add({
macros: {
//
// Some of these are hacks for now
//
xleftrightarrow: ['xArrow',0x2194,6,6],
xrightleftharpoons: ['xArrow',0x21CC,5,7], // FIXME: doesn't stretch in HTML-CSS output
xRightleftharpoons: ['xArrow',0x21CC,5,7], // FIXME: how should this be handled?
xLeftrightharpoons: ['xArrow',0x21CC,5,7]
}
},null,true);
});
TEX.Parse.Augment({ TEX.Parse.Augment({
@ -399,6 +464,22 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var arg = this.GetArgument(name); var arg = this.GetArgument(name);
var tex = CE(arg).Parse(); var tex = CE(arg).Parse();
this.string = tex + this.string.substr(this.i); this.i = 0; this.string = tex + this.string.substr(this.i); this.i = 0;
},
//
// Implements \CEprescripts{presub}{presup}{base}{sub}{sup}
//
CEprescripts: function (name) {
var presub = this.ParseArg(name),
presup = this.ParseArg(name),
base = this.ParseArg(name),
sub = this.ParseArg(name),
sup = this.ParseArg(name);
var MML = MathJax.ElementJax.mml;
this.Push(MML.mmultiscripts(base,sub,sup,MML.mprescripts(),presub,presup));
},
CEnone: function (name) {
this.Push(MathJax.ElementJax.mml.none());
} }
}); });

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/newcommand.js * MathJax/extensions/TeX/newcommand.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +26,7 @@
*/ */
MathJax.Extension["TeX/newcommand"] = { MathJax.Extension["TeX/newcommand"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
@ -45,7 +48,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
TEX.Parse.Augment({ TEX.Parse.Augment({
/* /*
* Implement \newcommand{\name}[n]{...} * Implement \newcommand{\name}[n][default]{...}
*/ */
NewCommand: function (name) { NewCommand: function (name) {
var cs = this.trimSpaces(this.GetArgument(name)), var cs = this.trimSpaces(this.GetArgument(name)),
@ -53,10 +56,16 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
opt = this.GetBrackets(name), opt = this.GetBrackets(name),
def = this.GetArgument(name); def = this.GetArgument(name);
if (cs.charAt(0) === "\\") {cs = cs.substr(1)} if (cs.charAt(0) === "\\") {cs = cs.substr(1)}
if (!cs.match(/^(.|[a-z]+)$/i)) {TEX.Error("Illegal control sequence name for "+name)} if (!cs.match(/^(.|[a-z]+)$/i)) {
TEX.Error(["IllegalControlSequenceName",
"Illegal control sequence name for %1",name]);
}
if (n) { if (n) {
n = this.trimSpaces(n); n = this.trimSpaces(n);
if (!n.match(/^[0-9]+$/)) {TEX.Error("Illegal number of parameters specified in "+name)} if (!n.match(/^[0-9]+$/)) {
TEX.Error(["IllegalParamNumber",
"Illegal number of parameters specified in %1",name]);
}
} }
this.setDef(cs,['Macro',def,n,opt]); this.setDef(cs,['Macro',def,n,opt]);
}, },
@ -67,13 +76,17 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
NewEnvironment: function (name) { NewEnvironment: function (name) {
var env = this.trimSpaces(this.GetArgument(name)), var env = this.trimSpaces(this.GetArgument(name)),
n = this.GetBrackets(name), n = this.GetBrackets(name),
opt = this.GetBrackets(name),
bdef = this.GetArgument(name), bdef = this.GetArgument(name),
edef = this.GetArgument(name); edef = this.GetArgument(name);
if (n) { if (n) {
n = this.trimSpaces(n); n = this.trimSpaces(n);
if (!n.match(/^[0-9]+$/)) {TEX.Error("Illegal number of parameters specified in "+name)} if (!n.match(/^[0-9]+$/)) {
TEX.Error(["IllegalParamNumber",
"Illegal number of parameters specified in %1",name]);
} }
this.setEnv(env,['BeginEnv','EndEnv',bdef,edef,n]); }
this.setEnv(env,['BeginEnv',[null,'EndEnv'],bdef,edef,n,opt]);
}, },
/* /*
@ -128,7 +141,10 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
*/ */
GetCSname: function (cmd) { GetCSname: function (cmd) {
var c = this.GetNext(); var c = this.GetNext();
if (c !== "\\") {TEX.Error("\\ must be followed by a control sequence")} if (c !== "\\") {
TEX.Error(["MissingCS",
"%1 must be followed by a control sequence", cmd])
}
var cs = this.trimSpaces(this.GetArgument(cmd)); var cs = this.trimSpaces(this.GetArgument(cmd));
return cs.substr(1); return cs.substr(1);
}, },
@ -144,8 +160,14 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
if (c === '#') { if (c === '#') {
if (i !== this.i) {params[n] = this.string.substr(i,this.i-i)} if (i !== this.i) {params[n] = this.string.substr(i,this.i-i)}
c = this.string.charAt(++this.i); c = this.string.charAt(++this.i);
if (!c.match(/^[1-9]$/)) {TEX.Error("Illegal use of # in template for "+cs)} if (!c.match(/^[1-9]$/)) {
if (parseInt(c) != ++n) {TEX.Error("Parameters for "+cs+" must be numbered sequentially")} TEX.Error(["CantUseHash2",
"Illegal use of # in template for %1",cs]);
}
if (parseInt(c) != ++n) {
TEX.Error(["SequentialParam",
"Parameters for %1 must be numbered sequentially",cs]);
}
i = this.i+1; i = this.i+1;
} else if (c === '{') { } else if (c === '{') {
if (i !== this.i) {params[n] = this.string.substr(i,this.i-i)} if (i !== this.i) {params[n] = this.string.substr(i,this.i-i)}
@ -153,7 +175,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
} }
this.i++; this.i++;
} }
TEX.Error("Missing replacement string for definition of "+cmd); TEX.Error(["MissingReplacementString",
"Missing replacement string for definition of %1",cmd]);
}, },
/* /*
@ -162,34 +185,43 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
MacroWithTemplate: function (name,text,n,params) { MacroWithTemplate: function (name,text,n,params) {
if (n) { if (n) {
var args = []; this.GetNext(); var args = []; this.GetNext();
if (params[0] && !this.MatchParam(params[0])) if (params[0] && !this.MatchParam(params[0])) {
{TEX.Error("Use of "+name+" doesn't match its definition")} TEX.Error(["MismatchUseDef",
"Use of %1 doesn't match its definition",name]);
}
for (var i = 0; i < n; i++) {args.push(this.GetParameter(name,params[i+1]))} for (var i = 0; i < n; i++) {args.push(this.GetParameter(name,params[i+1]))}
text = this.SubstituteArgs(args,text); text = this.SubstituteArgs(args,text);
} }
this.string = this.AddArgs(text,this.string.slice(this.i)); this.string = this.AddArgs(text,this.string.slice(this.i));
this.i = 0; this.i = 0;
if (++this.macroCount > TEX.config.MAXMACROS) if (++this.macroCount > TEX.config.MAXMACROS) {
{TEX.Error("MathJax maximum macro substitution count exceeded; is there a recursive macro call?")} TEX.Error(["MaxMacroSub1",
"MathJax maximum macro substitution count exceeded; " +
"is there a recursive macro call?"]);
}
}, },
/* /*
* Process a user-defined environment * Process a user-defined environment
*/ */
BeginEnv: function (begin,bdef,edef,n) { BeginEnv: function (begin,bdef,edef,n,def) {
if (n) { if (n) {
var args = []; var args = [];
for (var i = 0; i < n; i++) {args.push(this.GetArgument("\\begin{"+name+"}"))} if (def != null) {
bdef = this.SubstituteArgs(args,bdef); var optional = this.GetBrackets("\\begin{"+name+"}");
edef = this.SubstituteArgs(args,edef); args.push(optional == null ? def : optional);
}
for (var i = args.length; i < n; i++) {args.push(this.GetArgument("\\begin{"+name+"}"))}
bdef = this.SubstituteArgs(args,bdef);
edef = this.SubstituteArgs([],edef); // no args, but get errors for #n in edef
} }
begin.edef = edef;
this.string = this.AddArgs(bdef,this.string.slice(this.i)); this.i = 0; this.string = this.AddArgs(bdef,this.string.slice(this.i)); this.i = 0;
return begin; return begin;
}, },
EndEnv: function (begin,row) { EndEnv: function (begin,bdef,edef,n) {
this.string = this.AddArgs(begin.edef,this.string.slice(this.i)); this.i = 0 var end = "\\end{\\end\\"+begin.name+"}"; // special version of \end for after edef
return row; this.string = this.AddArgs(edef,end+this.string.slice(this.i)); this.i = 0;
return null;
}, },
/* /*
@ -209,7 +241,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
this.i++; j++; hasBraces = 0; this.i++; j++; hasBraces = 0;
} }
} }
TEX.Error("Runaway argument for "+name+"?"); TEX.Error(["RunawayArgument","Runaway argument for %1?",name]);
}, },
/* /*

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/noErrors.js * MathJax/extensions/TeX/noErrors.js
@ -52,7 +55,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -68,7 +71,7 @@
*/ */
(function (HUB,HTML) { (function (HUB,HTML) {
var VERSION = "2.0"; var VERSION = "2.6.0";
var CONFIG = HUB.CombineConfig("TeX.noErrors",{ var CONFIG = HUB.CombineConfig("TeX.noErrors",{
disabled: false, // set to true to return to original error messages disabled: false, // set to true to return to original error messages
@ -151,7 +154,7 @@
span = this.HTMLcreateSpan(span); span = this.HTMLcreateSpan(span);
span.bbox = data.data[0].toHTML(span).bbox; span.bbox = data.data[0].toHTML(span).bbox;
} else { } else {
span = MATH.call(this,span,node); span = MATH.apply(this,arguments);
} }
return span; return span;
} }
@ -163,7 +166,7 @@
// //
MML.merror.Augment({ MML.merror.Augment({
toHTML: function (span) { toHTML: function (span) {
if (!this.isError) {return MERROR.call(this,span)} if (!this.isError) {return MERROR.apply(this,arguments)}
span = this.HTMLcreateSpan(span); span.className = "noError" span = this.HTMLcreateSpan(span); span.className = "noError"
if (this.multiLine) {span.style.display = "inline-block"} if (this.multiLine) {span.style.display = "inline-block"}
var text = this.data[0].data[0].data.join("").split(/\n/); var text = this.data[0].data[0].data.join("").split(/\n/);
@ -215,7 +218,7 @@
toSVG: function (span,node) { toSVG: function (span,node) {
var data = this.data[0]; var data = this.data[0];
if (data && data.data[0] && data.data[0].isError) if (data && data.data[0] && data.data[0].isError)
{span = data.data[0].toSVG(span)} else {span = MATH.call(this,span,node)} {span = data.data[0].toSVG(span)} else {span = MATH.apply(this,arguments)}
return span; return span;
} }
}); });
@ -226,7 +229,7 @@
// //
MML.merror.Augment({ MML.merror.Augment({
toSVG: function (span) { toSVG: function (span) {
if (!this.isError || this.Parent().type !== "math") {return MERROR.call(this,span)} if (!this.isError || this.Parent().type !== "math") {return MERROR.apply(this,arguments)}
span = HTML.addElement(span,"span",{className: "noError", isMathJax:true}); span = HTML.addElement(span,"span",{className: "noError", isMathJax:true});
if (this.multiLine) {span.style.display = "inline-block"} if (this.multiLine) {span.style.display = "inline-block"}
var text = this.data[0].data[0].data.join("").split(/\n/); var text = this.data[0].data[0].data.join("").split(/\n/);
@ -264,7 +267,7 @@
toNativeMML: function (span) { toNativeMML: function (span) {
var data = this.data[0]; var data = this.data[0];
if (data && data.data[0] && data.data[0].isError) if (data && data.data[0] && data.data[0].isError)
{span = data.data[0].toNativeMML(span)} else {span = MATH.call(this,span)} {span = data.data[0].toNativeMML(span)} else {span = MATH.apply(this,arguments)}
return span; return span;
} }
}); });
@ -275,7 +278,7 @@
// //
MML.merror.Augment({ MML.merror.Augment({
toNativeMML: function (span) { toNativeMML: function (span) {
if (!this.isError) {return MERROR.call(this,span)} if (!this.isError) {return MERROR.apply(this,arguments)}
span = span.appendChild(document.createElement("span")); span = span.appendChild(document.createElement("span"));
var text = this.data[0].data[0].data.join("").split(/\n/); var text = this.data[0].data[0].data.join("").split(/\n/);
for (var i = 0, m = text.length; i < m; i++) { for (var i = 0, m = text.length; i < m; i++) {
@ -296,6 +299,102 @@
}); });
/*******************************************************************
*
* Fix PreviewHTML output
*/
HUB.Register.StartupHook("PreviewHTML Jax Config",function () {
HUB.Config({
PreviewHTML: {
styles: {
".MathJax_PHTML .noError": HUB.Insert({
"vertical-align": (HUB.Browser.isMSIE && CONFIG.multiLine ? "-2px" : "")
},CONFIG.style)
}
}
});
});
HUB.Register.StartupHook("PreviewHTML Jax Ready",function () {
var MML = MathJax.ElementJax.mml;
var HTML = MathJax.HTML;
var MERROR = MML.merror.prototype.toPreviewHTML;
//
// Override merror toPreviewHTML routine so that it puts out the
// TeX code in an inline-block with line breaks as in the original
//
MML.merror.Augment({
toPreviewHTML: function (span) {
if (!this.isError) return MERROR.apply(this,arguments);
span = this.PHTMLcreateSpan(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++) {
HTML.addText(span,text[i]);
if (i !== m-1) {HTML.addElement(span,"br",{isMathJax:true})}
}
return span;
}
});
});
/*******************************************************************
*
* Fix CommonHTML output
*/
HUB.Register.StartupHook("CommonHTML Jax Config",function () {
HUB.Config({
CommonHTML: {
styles: {
".mjx-chtml .mjx-noError": HUB.Insert({
"line-height": 1.2,
"vertical-align": (HUB.Browser.isMSIE && CONFIG.multiLine ? "-2px" : "")
},CONFIG.style)
}
}
});
});
HUB.Register.StartupHook("CommonHTML Jax Ready",function () {
var MML = MathJax.ElementJax.mml;
var CHTML = MathJax.OutputJax.CommonHTML;
var HTML = MathJax.HTML;
var MERROR = MML.merror.prototype.toCommonHTML;
//
// Override merror toCommonHTML routine so that it puts out the
// TeX code in an inline-block with line breaks as in the original
//
MML.merror.Augment({
toCommonHTML: function (node) {
if (!this.isError) return MERROR.apply(this,arguments);
node = CHTML.addElement(node,"mjx-noError");
var text = this.data[0].data[0].data.join("").split(/\n/);
for (var i = 0, m = text.length; i < m; i++) {
HTML.addText(node,text[i]);
if (i !== m-1) {CHTML.addElement(node,"br",{isMathJax:true})}
}
var bbox = this.CHTML = CHTML.BBOX.zero();
bbox.w = (node.offsetWidth)/CHTML.em;
if (m > 1) {
var H2 = 1.2*m/2;
bbox.h = H2+.25; bbox.d = H2-.25;
node.style.verticalAlign = CHTML.Em(.45-H2);
} else {
bbox.h = 1; bbox.d = .2 + 2/CHTML.em;
}
return node;
}
});
});
/*******************************************************************/ /*******************************************************************/
HUB.Startup.signal.Post("TeX noErrors Ready"); HUB.Startup.signal.Post("TeX noErrors Ready");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/noUndefined.js * MathJax/extensions/TeX/noUndefined.js
@ -22,7 +25,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2010-2012 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,7 +44,7 @@
// The configuration defaults, augmented by the user settings // The configuration defaults, augmented by the user settings
// //
MathJax.Extension["TeX/noUndefined"] = { MathJax.Extension["TeX/noUndefined"] = {
version: "2.0", version: "2.6.0",
config: MathJax.Hub.CombineConfig("TeX.noUndefined",{ config: MathJax.Hub.CombineConfig("TeX.noUndefined",{
disabled: false, // set to true to return to original error messages disabled: false, // set to true to return to original error messages
attributes: { attributes: {

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/unicode.js * MathJax/extensions/TeX/unicode.js
@ -40,7 +43,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -59,7 +62,7 @@
// The configuration defaults, augmented by the user settings // The configuration defaults, augmented by the user settings
// //
MathJax.Extension["TeX/unicode"] = { MathJax.Extension["TeX/unicode"] = {
version: "2.0", version: "2.6.0",
unicode: {}, unicode: {},
config: MathJax.Hub.CombineConfig("TeX.unicode",{ config: MathJax.Hub.CombineConfig("TeX.unicode",{
fonts: "STIXGeneral,'Arial Unicode MS'" fonts: "STIXGeneral,'Arial Unicode MS'"
@ -74,7 +77,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
// //
// Add \unicode macro // Add \unicode macro
// //
TEX.Definitions.macros.unicode = 'Unicode'; TEX.Definitions.Add({macros: {unicode: 'Unicode'}},null,true);
// //
// Implementation of \unicode in parser // Implementation of \unicode in parser
// //
@ -121,7 +124,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var GETVARIANT = MML.mbase.prototype.HTMLgetVariant; var GETVARIANT = MML.mbase.prototype.HTMLgetVariant;
MML.mbase.Augment({ MML.mbase.Augment({
HTMLgetVariant: function () { HTMLgetVariant: function () {
var variant = GETVARIANT.call(this); var variant = GETVARIANT.apply(this,arguments);
if (variant.unicode) {delete variant.unicode; delete variant.FONTS} // clear font cache in case of restart if (variant.unicode) {delete variant.unicode; delete variant.FONTS} // clear font cache in case of restart
if (!this.unicode) {return variant} if (!this.unicode) {return variant}
variant.unicode = true; variant.unicode = true;

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/TeX/verb.js * MathJax/extensions/TeX/verb.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +26,7 @@
*/ */
MathJax.Extension["TeX/verb"] = { MathJax.Extension["TeX/verb"] = {
version: "2.0" version: "2.6.0"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
@ -32,7 +35,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX; var TEX = MathJax.InputJax.TeX;
var TEXDEF = TEX.Definitions; var TEXDEF = TEX.Definitions;
TEXDEF.macros.verb = 'Verb'; TEXDEF.Add({macros: {verb: 'Verb'}},null,true);
TEX.Parse.Augment({ TEX.Parse.Augment({
@ -41,11 +44,11 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
*/ */
Verb: function (name) { Verb: function (name) {
var c = this.GetNext(); var start = ++this.i; var c = this.GetNext(); var start = ++this.i;
if (c == "" ) {TEX.Error(name+" requires an argument")} if (c == "" ) {TEX.Error(["MissingArgFor","Missing argument for %1",name])}
while (this.i < this.string.length && this.string.charAt(this.i) != c) {this.i++} while (this.i < this.string.length && this.string.charAt(this.i) != c) {this.i++}
if (this.i == this.string.length) if (this.i == this.string.length)
{TEX.Error("Can't find closing delimiter for "+name)} {TEX.Error(["NoClosingDelim","Can't find closing delimiter for %1", name])}
var text = this.string.slice(start,this.i); this.i++; var text = this.string.slice(start,this.i).replace(/ /g,"\u00A0"); this.i++;
this.Push(MML.mtext(text).With({mathvariant:MML.VARIANT.MONOSPACE})); this.Push(MML.mtext(text).With({mathvariant:MML.VARIANT.MONOSPACE}));
} }

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/asciimath2jax.js * MathJax/extensions/asciimath2jax.js
@ -11,7 +14,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2012 Design Science, Inc. * Copyright (c) 2012-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,11 +30,11 @@
*/ */
MathJax.Extension.asciimath2jax = { MathJax.Extension.asciimath2jax = {
version: "2.0", version: "2.6.0",
config: { config: {
delimiters: [['`','`']], // The star/stop delimiter pairs for asciimath code delimiters: [['`','`']], // The star/stop delimiter pairs for asciimath code
skipTags: ["script","noscript","style","textarea","pre","code"], skipTags: ["script","noscript","style","textarea","pre","code","annotation","annotation-xml"],
// The names of the tags whose contents will not be // The names of the tags whose contents will not be
// scanned for math delimiters // scanned for math delimiters
@ -75,7 +78,10 @@ MathJax.Extension.asciimath2jax = {
} }
this.start = new RegExp(starts.sort(this.sortLength).join("|"),"g"); this.start = new RegExp(starts.sort(this.sortLength).join("|"),"g");
this.skipTags = new RegExp("^("+config.skipTags.join("|")+")$","i"); this.skipTags = new RegExp("^("+config.skipTags.join("|")+")$","i");
this.ignoreClass = new RegExp("(^| )("+config.ignoreClass+")( |$)"); var ignore = [];
if (MathJax.Hub.config.preRemoveClass) {ignore.push(MathJax.Hub.config.preRemoveClass)}
if (config.ignoreClass) {ignore.push(config.ignoreClass)}
this.ignoreClass = (ignore.length ? new RegExp("(^| )("+ignore.join("|")+")( |$)") : /^$/);
this.processClass = new RegExp("(^| )("+config.processClass+")( |$)"); this.processClass = new RegExp("(^| )("+config.processClass+")( |$)");
return true; return true;
}, },
@ -201,9 +207,9 @@ MathJax.Extension.asciimath2jax = {
}, },
createPreview: function (mode,asciimath) { createPreview: function (mode,asciimath) {
var preview; var preview = this.config.preview;
if (this.config.preview === "AsciiMath") {preview = [this.filterPreview(asciimath)]} if (preview === "none") return;
else if (this.config.preview instanceof Array) {preview = this.config.preview} if (preview === "AsciiMath") {preview = [this.filterPreview(asciimath)]}
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
this.insertNode(preview); this.insertNode(preview);
@ -224,5 +230,10 @@ MathJax.Extension.asciimath2jax = {
}; };
// We register the preprocessors with the following priorities:
// - mml2jax.js: 5
// - jsMath2jax.js: 8
// - asciimath2jax.js, tex2jax.js: 10 (default)
// See issues 18 and 484 and the other *2jax.js files.
MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.asciimath2jax]); MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.asciimath2jax]);
MathJax.Ajax.loadComplete("[MathJax]/extensions/asciimath2jax.js"); MathJax.Ajax.loadComplete("[MathJax]/extensions/asciimath2jax.js");

View File

@ -0,0 +1,155 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*************************************************************
*
* MathJax/extensions/fast-preview.js
*
* Implements a fast preview using the PreviewHTML output jax
* and then a slower update to the more accurate HTML-CSS output
* (or whatever the user has selected).
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2014-2015 The MathJax Consortium
*
* 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,BROWSER) {
var SETTINGS = HUB.config.menuSettings;
var JAX = MathJax.OutputJax;
var msieColorBug = BROWSER.isMSIE && (document.documentMode||0) < 8;
var FastPreview = MathJax.Extension["fast-preview"] = {
version: "2.6.0",
enabled: true,
//
// Configuration for the chunking of the main output
// after the previews have been created, and other configuration.
//
config: HUB.CombineConfig("fast-preview",{
Chunks: {EqnChunk: 10000, EqnChunkFactor: 1, EqnChunkDelay: 0},
color: "inherit!important",
updateTime: 30, updateDelay: 6,
messageStyle: "none",
disabled: BROWSER.isMSIE && !BROWSER.versionAtLeast("8.0")
}),
//
// Ajust the chunking of the output jax
//
Config: function () {
if (HUB.config["CHTML-preview"])
MathJax.Hub.Config({"fast-preview": HUB.config["CHTML-preview"]});
var update, delay, style, done, saved;
var config = this.config;
if (!config.disabled && SETTINGS.FastPreview == null)
HUB.Config({menuSettings:{FastPreview:true}});
if (SETTINGS.FastPreview) {
MathJax.Ajax.Styles({".MathJax_Preview .MJXf-math":{color:config.color}});
HUB.Config({"HTML-CSS": config.Chunks, CommonHTML: config.Chunks, SVG: config.Chunks});
}
HUB.Register.MessageHook("Begin Math Output",function () {
if (!done && FastPreview.Active()) {
update = HUB.processUpdateTime; delay = HUB.processUpdateDelay;
style = HUB.config.messageStyle;
HUB.processUpdateTime = config.updateTime;
HUB.processUpdateDelay = config.updateDelay;
HUB.Config({messageStyle: config.messageStyle});
MathJax.Message.Clear(0,0);
saved = true;
}
});
HUB.Register.MessageHook("End Math Output",function () {
if (!done && saved) {
HUB.processUpdateTime = update;
HUB.processUpdateDelay = delay;
HUB.Config({messageStyle: style});
done = true;
}
});
},
//
// Allow page to override user settings (for things like editor previews)
//
Disable: function () {this.enabled = false},
Enable: function () {this.enabled = true},
Active: function () {
return SETTINGS.FastPreview && this.enabled &&
!(JAX[SETTINGS.renderer]||{}).noFastPreview;
},
//
// Insert a preview span, if there isn't one already,
// and call the PreviewHTML output jax to create the preview
//
Preview: function (data) {
if (!this.Active()) return;
var preview = data.script.MathJax.preview || data.script.previousSibling;
if (!preview || preview.className !== MathJax.Hub.config.preRemoveClass) {
preview = HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass});
data.script.parentNode.insertBefore(preview,data.script);
data.script.MathJax.preview = preview;
}
preview.innerHTML = "";
preview.style.color = (msieColorBug ? "black" : "inherit");
return this.postFilter(preview,data);
},
postFilter: function (preview,data) {
//
// Load the PreviewHTML jax if it is not already loaded
//
if (!data.math.root.toPreviewHTML) {
var queue = MathJax.Callback.Queue();
queue.Push(
["Require",MathJax.Ajax,"[MathJax]/jax/output/PreviewHTML/config.js"],
["Require",MathJax.Ajax,"[MathJax]/jax/output/PreviewHTML/jax.js"]
);
HUB.RestartAfter(queue.Push({}));
}
data.math.root.toPreviewHTML(preview);
},
//
// Hook into the input jax postFilter to create the previews as
// the input jax are processed.
//
Register: function (name) {
HUB.Register.StartupHook(name+" Jax Require",function () {
var jax = MathJax.InputJax[name];
jax.postfilterHooks.Add(["Preview",MathJax.Extension["fast-preview"]],50);
});
}
}
//
// Hook into each input jax
//
FastPreview.Register("TeX");
FastPreview.Register("MathML");
FastPreview.Register("AsciiMath");
HUB.Register.StartupHook("End Config",["Config",FastPreview]);
HUB.Startup.signal.Post("fast-preview Ready");
})(MathJax.Hub,MathJax.HTML,MathJax.Hub.Browser);
MathJax.Ajax.loadComplete("[MathJax]/extensions/fast-preview.js");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/jsMath2jax.js * MathJax/extensions/jsMath2jax.js
@ -15,7 +18,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2010-2012 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,7 +34,7 @@
*/ */
MathJax.Extension.jsMath2jax = { MathJax.Extension.jsMath2jax = {
version: "2.0", version: "2.6.0",
config: { config: {
preview: "TeX" // Set to "none" to prevent preview strings from being inserted preview: "TeX" // Set to "none" to prevent preview strings from being inserted
@ -70,9 +73,8 @@ MathJax.Extension.jsMath2jax = {
}, },
createPreview: function (node) { createPreview: function (node) {
var preview; var preview = this.config.preview;
if (this.config.preview === "TeX") {preview = [this.filterPreview(node.innerHTML)]} if (preview === "TeX") {preview = [this.filterPreview(node.innerHTML)]}
else if (this.config.preview instanceof Array) {preview = this.config.preview}
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className: MathJax.Hub.config.preRemoveClass},preview); preview = MathJax.HTML.Element("span",{className: MathJax.Hub.config.preRemoveClass},preview);
node.parentNode.insertBefore(preview,node); node.parentNode.insertBefore(preview,node);
@ -91,5 +93,10 @@ MathJax.Extension.jsMath2jax = {
}; };
MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.jsMath2jax]); // We register the preprocessors with the following priorities:
// - mml2jax.js: 5
// - jsMath2jax.js: 8
// - asciimath2jax.js, tex2jax.js: 10 (default)
// See issues 18 and 484 and the other *2jax.js files.
MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.jsMath2jax],8);
MathJax.Ajax.loadComplete("[MathJax]/extensions/jsMath2jax.js"); MathJax.Ajax.loadComplete("[MathJax]/extensions/jsMath2jax.js");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/mml2jax.js * MathJax/extensions/mml2jax.js
@ -8,7 +11,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2010-2012 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,10 +27,13 @@
*/ */
MathJax.Extension.mml2jax = { MathJax.Extension.mml2jax = {
version: "2.0", version: "2.6.0",
config: { config: {
preview: "alttext" // Use the <math> element's alttext as the preview: "mathml" // Use the <math> element as the
// preview. Set to "none" for no preview, // preview. Set to "none" for no preview,
// set to "alttext" to use the alttext attribute
// of the <math> element, set to "altimg" to use
// an image described by the altimg* attributes
// or set to an array specifying an HTML snippet // or set to an array specifying an HTML snippet
// to use a fixed preview for all math // to use a fixed preview for all math
@ -43,28 +49,30 @@ MathJax.Extension.mml2jax = {
} }
if (typeof(element) === "string") {element = document.getElementById(element)} if (typeof(element) === "string") {element = document.getElementById(element)}
if (!element) {element = document.body} if (!element) {element = document.body}
var mathArray = [];
// //
// Handle all math tags with no namespaces // Handle all math tags with no namespaces
// //
this.ProcessMathArray(element.getElementsByTagName("math")); this.PushMathElements(mathArray,element,"math");
// //
// Handle math with namespaces in XHTML // Handle math with namespaces in XHTML
// //
if (element.getElementsByTagNameNS) this.PushMathElements(mathArray,element,"math",this.MMLnamespace);
{this.ProcessMathArray(element.getElementsByTagNameNS(this.MMLnamespace,"math"))}
// //
// Handle math with namespaces in HTML // Handle math with namespaces in HTML
// //
var i, m; var i, m;
if (document.namespaces) { if (typeof(document.namespaces) !== "undefined") {
// //
// IE namespaces are listed in document.namespaces // IE namespaces are listed in document.namespaces
// //
try {
for (i = 0, m = document.namespaces.length; i < m; i++) { for (i = 0, m = document.namespaces.length; i < m; i++) {
var ns = document.namespaces[i]; var ns = document.namespaces[i];
if (ns.urn === this.MMLnamespace) if (ns.urn === this.MMLnamespace)
{this.ProcessMathArray(element.getElementsByTagName(ns.name+":math"))} {this.PushMathElements(mathArray,element,ns.name+":math")}
} }
} catch (err) {}
} else { } else {
// //
// Everybody else // Everybody else
@ -74,28 +82,45 @@ MathJax.Extension.mml2jax = {
for (i = 0, m = html.attributes.length; i < m; i++) { for (i = 0, m = html.attributes.length; i < m; i++) {
var attr = html.attributes[i]; var attr = html.attributes[i];
if (attr.nodeName.substr(0,6) === "xmlns:" && attr.nodeValue === this.MMLnamespace) if (attr.nodeName.substr(0,6) === "xmlns:" && attr.nodeValue === this.MMLnamespace)
{this.ProcessMathArray(element.getElementsByTagName(attr.nodeName.substr(6)+":math"))} {this.PushMathElements(mathArray,element,attr.nodeName.substr(6)+":math")}
} }
} }
} }
this.ProcessMathArray(mathArray);
},
PushMathElements: function (array,element,name,namespace) {
var math, preview = MathJax.Hub.config.preRemoveClass;
if (namespace) {
if (!element.getElementsByTagNameNS) return;
math = element.getElementsByTagNameNS(namespace,name);
} else {
math = element.getElementsByTagName(name);
}
for (var i = 0, m = math.length; i < m; i++) {
var parent = math[i].parentNode;
if (parent && parent.className !== preview &&
!parent.isMathJax && !math[i].prefix === !namespace) array.push(math[i]);
}
}, },
ProcessMathArray: function (math) { ProcessMathArray: function (math) {
var i; var i, m = math.length;
if (math.length) { if (m) {
if (this.MathTagBug) { if (this.MathTagBug) {
for (i = math.length-1; i >= 0; i--) { for (i = 0; i < m; i++) {
if (math[i].nodeName === "MATH") {this.ProcessMathFlattened(math[i])} if (math[i].nodeName === "MATH") {this.ProcessMathFlattened(math[i])}
else {this.ProcessMath(math[i])} else {this.ProcessMath(math[i])}
} }
} else { } else {
for (i = math.length-1; i >= 0; i--) {this.ProcessMath(math[i])} for (i = 0; i < m; i++) {this.ProcessMath(math[i])}
} }
} }
}, },
ProcessMath: function (math) { ProcessMath: function (math) {
var parent = math.parentNode; var parent = math.parentNode;
if (!parent || parent.className === MathJax.Hub.config.preRemoveClass) return;
var script = document.createElement("script"); var script = document.createElement("script");
script.type = "math/mml"; script.type = "math/mml";
parent.insertBefore(script,math); parent.insertBefore(script,math);
@ -115,6 +140,7 @@ MathJax.Extension.mml2jax = {
ProcessMathFlattened: function (math) { ProcessMathFlattened: function (math) {
var parent = math.parentNode; var parent = math.parentNode;
if (!parent || parent.className === MathJax.Hub.config.preRemoveClass) return;
var script = document.createElement("script"); var script = document.createElement("script");
script.type = "math/mml"; script.type = "math/mml";
parent.insertBefore(script,math); parent.insertBefore(script,math);
@ -141,7 +167,7 @@ MathJax.Extension.mml2jax = {
html = "<"+node.nodeName.toLowerCase(); html = "<"+node.nodeName.toLowerCase();
for (i = 0, m = node.attributes.length; i < m; i++) { for (i = 0, m = node.attributes.length; i < m; i++) {
var attribute = node.attributes[i]; var attribute = node.attributes[i];
if (attribute.specified) { if (attribute.specified && attribute.nodeName.substr(0,10) !== "_moz-math-") {
// Opera 11.5 beta turns xmlns into xmlns:xmlns, so put it back (*** check after 11.5 is out ***) // Opera 11.5 beta turns xmlns into xmlns:xmlns, so put it back (*** check after 11.5 is out ***)
html += " "+attribute.nodeName.toLowerCase().replace(/xmlns:xmlns/,"xmlns")+"="; html += " "+attribute.nodeName.toLowerCase().replace(/xmlns:xmlns/,"xmlns")+"=";
var value = attribute.nodeValue; // IE < 8 doesn't properly set style by setAttributes var value = attribute.nodeValue; // IE < 8 doesn't properly set style by setAttributes
@ -170,18 +196,41 @@ MathJax.Extension.mml2jax = {
}, },
quoteHTML: function (string) { quoteHTML: function (string) {
if (string == null) {string = ""} if (string == null) {string = ""}
return string.replace(/&/g,"&#x26;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"); return string.replace(/&/g,"&#x26;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;");
}, },
createPreview: function (math,script) { createPreview: function (math,script) {
var preview; var preview = this.config.preview;
if (this.config.preview === "alttext") { if (preview === "none") return;
var text = math.getAttribute("alttext"); var isNodePreview = false;
if (text != null) {preview = [this.filterPreview(text)]} if (preview === "mathml") {
} else if (this.config.preview instanceof Array) {preview = this.config.preview} isNodePreview = true;
// mathml preview does not work with IE < 9, so fallback to alttext.
if (this.MathTagBug) {preview = "alttext"} else {preview = math.cloneNode(true)}
}
if (preview === "alttext" || preview === "altimg") {
isNodePreview = true;
var alttext = this.filterPreview(math.getAttribute("alttext"));
if (preview === "alttext") {
if (alttext != null) {preview = MathJax.HTML.TextNode(alttext)} else {preview = null}
} else {
var src = math.getAttribute("altimg");
if (src != null) {
// FIXME: use altimg-valign when display="inline"?
var style = {width: math.getAttribute("altimg-width"), height: math.getAttribute("altimg-height")};
preview = MathJax.HTML.Element("img",{src:src,alt:alttext,style:style});
} else {preview = null}
}
}
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); var span;
script.parentNode.insertBefore(preview,script); if (isNodePreview) {
span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass});
span.appendChild(preview);
} else {
span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
}
script.parentNode.insertBefore(span,script);
} }
}, },
@ -201,5 +250,12 @@ MathJax.Extension.mml2jax = {
}; };
MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.mml2jax]); //
// We register the preprocessors with the following priorities:
// - mml2jax.js: 5
// - jsMath2jax.js: 8
// - asciimath2jax.js, tex2jax.js: 10 (default)
// See issues 18 and 484 and the other *2jax.js files.
//
MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.mml2jax],5);
MathJax.Ajax.loadComplete("[MathJax]/extensions/mml2jax.js"); MathJax.Ajax.loadComplete("[MathJax]/extensions/mml2jax.js");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/tex2jax.js * MathJax/extensions/tex2jax.js
@ -8,7 +11,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +27,7 @@
*/ */
MathJax.Extension.tex2jax = { MathJax.Extension.tex2jax = {
version: "2.0", version: "2.6.0",
config: { config: {
inlineMath: [ // The start/stop pairs for in-line math inlineMath: [ // The start/stop pairs for in-line math
// ['$','$'], // (comment out any you don't want, or add your own, but // ['$','$'], // (comment out any you don't want, or add your own, but
@ -40,7 +43,7 @@ MathJax.Extension.tex2jax = {
// balanced within math delimiters (allows for nested // balanced within math delimiters (allows for nested
// dollar signs). Set to false to get pre-v2.0 compatibility. // dollar signs). Set to false to get pre-v2.0 compatibility.
skipTags: ["script","noscript","style","textarea","pre","code"], skipTags: ["script","noscript","style","textarea","pre","code","annotation","annotation-xml"],
// The names of the tags whose contents will not be // The names of the tags whose contents will not be
// scanned for math delimiters // scanned for math delimiters
@ -107,7 +110,10 @@ MathJax.Extension.tex2jax = {
if (config.processRefs) {parts.push("\\\\(eq)?ref\\{[^}]*\\}")} if (config.processRefs) {parts.push("\\\\(eq)?ref\\{[^}]*\\}")}
this.start = new RegExp(parts.join("|"),"g"); this.start = new RegExp(parts.join("|"),"g");
this.skipTags = new RegExp("^("+config.skipTags.join("|")+")$","i"); this.skipTags = new RegExp("^("+config.skipTags.join("|")+")$","i");
this.ignoreClass = new RegExp("(^| )("+config.ignoreClass+")( |$)"); var ignore = [];
if (MathJax.Hub.config.preRemoveClass) {ignore.push(MathJax.Hub.config.preRemoveClass)};
if (config.ignoreClass) {ignore.push(config.ignoreClass)}
this.ignoreClass = (ignore.length ? new RegExp("(^| )("+ignore.join("|")+")( |$)") : /^$/);
this.processClass = new RegExp("(^| )("+config.processClass+")( |$)"); this.processClass = new RegExp("(^| )("+config.processClass+")( |$)");
return (parts.length > 0); return (parts.length > 0);
}, },
@ -271,9 +277,9 @@ MathJax.Extension.tex2jax = {
}, },
createPreview: function (mode,tex) { createPreview: function (mode,tex) {
var preview; var preview = this.config.preview;
if (this.config.preview === "TeX") {preview = [this.filterPreview(tex)]} if (preview === "none") return;
else if (this.config.preview instanceof Array) {preview = this.config.preview} if (preview === "TeX") {preview = [this.filterPreview(tex)]}
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
this.insertNode(preview); this.insertNode(preview);
@ -294,5 +300,10 @@ MathJax.Extension.tex2jax = {
}; };
// We register the preprocessors with the following priorities:
// - mml2jax.js: 5
// - jsMath2jax.js: 8
// - asciimath2jax.js, tex2jax.js: 10 (default)
// See issues 18 and 484 and the other *2jax.js files.
MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.tex2jax]); MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.tex2jax]);
MathJax.Ajax.loadComplete("[MathJax]/extensions/tex2jax.js"); MathJax.Ajax.loadComplete("[MathJax]/extensions/tex2jax.js");

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/extensions/toMathML.js * MathJax/extensions/toMathML.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2010-2012 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,9 +26,9 @@
*/ */
MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () { MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
var VERSION = "2.0"; var VERSION = "2.6.0";
var MML = MathJax.ElementJax.mml var MML = MathJax.ElementJax.mml,
SETTINGS = MathJax.Hub.config.menuSettings; SETTINGS = MathJax.Hub.config.menuSettings;
MML.mbase.Augment({ MML.mbase.Augment({
@ -35,12 +38,12 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
if (space == null) {space = ""} if (space == null) {space = ""}
var tag = this.type, attr = this.toMathMLattributes(); var tag = this.type, attr = this.toMathMLattributes();
if (tag === "mspace") {return space + "<"+tag+attr+" />"} if (tag === "mspace") {return space + "<"+tag+attr+" />"}
var data = []; var SPACE = (this.isToken ? "" : space+(inferred ? "" : " ")); var data = [], SPACE = (this.isToken ? "" : space+(inferred ? "" : " "));
for (var i = 0, m = this.data.length; i < m; i++) { for (var i = 0, m = this.data.length; i < m; i++) {
if (this.data[i]) {data.push(this.data[i].toMathML(SPACE))} if (this.data[i]) {data.push(this.data[i].toMathML(SPACE))}
else if (!this.isToken) {data.push(SPACE+"<mrow />")} else if (!this.isToken && !this.isChars) {data.push(SPACE+"<mrow />")}
} }
if (this.isToken) {return space + "<"+tag+attr+">"+data.join("")+"</"+tag+">"} if (this.isToken || this.isChars) {return space + "<"+tag+attr+">"+data.join("")+"</"+tag+">"}
if (inferred) {return data.join("\n")} if (inferred) {return data.join("\n")}
if (data.length === 0 || (data.length === 1 && data[0] === "")) if (data.length === 0 || (data.length === 1 && data[0] === ""))
{return space + "<"+tag+attr+" />"} {return space + "<"+tag+attr+" />"}
@ -48,26 +51,25 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
}, },
toMathMLattributes: function () { toMathMLattributes: function () {
var attr = [], defaults = this.defaults; var defaults = (this.type === "mstyle" ? MML.math.prototype.defaults : this.defaults);
var copy = (this.attrNames||MML.copyAttributeNames), skip = MML.skipAttributes; var names = (this.attrNames||MML.copyAttributeNames),
skip = MML.skipAttributes, copy = MML.copyAttributes;
var attr = [];
if (this.type === "math") {attr.push('xmlns="http://www.w3.org/1998/Math/MathML"')} if (this.type === "math" && (!this.attr || !this.attr.xmlns))
{attr.push('xmlns="http://www.w3.org/1998/Math/MathML"')}
if (!this.attrNames) { if (!this.attrNames) {
if (this.type === "mstyle") {defaults = MML.math.prototype.defaults} for (var id in defaults) {if (!skip[id] && !copy[id] && defaults.hasOwnProperty(id)) {
for (var id in defaults) {if (!skip[id] && defaults.hasOwnProperty(id)) { if (this[id] != null && this[id] !== defaults[id]) {
var force = (id === "open" || id === "close"); if (this.Get(id,null,1) !== this[id])
if (this[id] != null && (force || this[id] !== defaults[id])) { attr.push(id+'="'+this.toMathMLattribute(this[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++) { for (var i = 0, m = names.length; i < m; i++) {
if (copy[i] === "class") continue; // this is handled separately below if (copy[names[i]] === 1 && !defaults.hasOwnProperty(names[i])) continue;
value = (this.attr||{})[copy[i]]; if (value == null) {value = this[copy[i]]} value = (this.attr||{})[names[i]]; if (value == null) {value = this[names[i]]}
if (value != null) {attr.push(copy[i]+'="'+this.toMathMLquote(value)+'"')} if (value != null) {attr.push(names[i]+'="'+this.toMathMLquote(value)+'"')}
} }
this.toMathMLclass(attr); this.toMathMLclass(attr);
if (attr.length) {return " "+attr.join(" ")} else {return ""} if (attr.length) {return " "+attr.join(" ")} else {return ""}
@ -80,7 +82,6 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
} }
if (this.mathvariant && this.toMathMLvariants[this.mathvariant]) if (this.mathvariant && this.toMathMLvariants[this.mathvariant])
{CLASS.push("MJX"+this.mathvariant)} {CLASS.push("MJX"+this.mathvariant)}
if (this.arrow) {CLASS.push("MJX-arrow")}
if (this.variantForm) {CLASS.push("MJX-variant")} if (this.variantForm) {CLASS.push("MJX-variant")}
if (CLASS.length) {attr.unshift('class="'+CLASS.join(" ")+'"')} if (CLASS.length) {attr.unshift('class="'+CLASS.join(" ")+'"')}
}, },
@ -88,7 +89,7 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
if (typeof(value) === "string" && if (typeof(value) === "string" &&
value.replace(/ /g,"").match(/^(([-+])?(\d+(\.\d*)?|\.\d+))mu$/)) { value.replace(/ /g,"").match(/^(([-+])?(\d+(\.\d*)?|\.\d+))mu$/)) {
// FIXME: should take scriptlevel into account // FIXME: should take scriptlevel into account
return ((1/18)*RegExp.$1).toFixed(3).replace(/\.?0+$/,"")+"em"; return (RegExp.$2||"")+((1/18)*RegExp.$3).toFixed(3).replace(/\.?0+$/,"")+"em";
} }
else if (this.toMathMLvariants[value]) {return this.toMathMLvariants[value]} else if (this.toMathMLvariants[value]) {return this.toMathMLvariants[value]}
return this.toMathMLquote(value); return this.toMathMLquote(value);
@ -105,17 +106,69 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
string = String(string).split(""); string = String(string).split("");
for (var i = 0, m = string.length; i < m; i++) { for (var i = 0, m = string.length; i < m; i++) {
var n = string[i].charCodeAt(0); var n = string[i].charCodeAt(0);
if (n < 0x20 || n > 0x7E) { if (n <= 0xD7FF || 0xE000 <= n) {
// Code points U+0000 to U+D7FF and U+E000 to U+FFFF.
// They are directly represented by n.
if (n > 0x7E || (n < 0x20 && n !== 0x0A && n !== 0x0D && n !== 0x09)) {
string[i] = "&#x"+n.toString(16).toUpperCase()+";"; string[i] = "&#x"+n.toString(16).toUpperCase()+";";
} else { } else {
var c = {'&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;'}[string[i]]; var c =
{'&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;'}[string[i]];
if (c) {string[i] = c} if (c) {string[i] = c}
} }
} else if (i+1 < m) {
// Code points U+10000 to U+10FFFF.
// n is the lead surrogate, let's read the trail surrogate.
var trailSurrogate = string[i+1].charCodeAt(0);
var codePoint = (((n-0xD800)<<10)+(trailSurrogate-0xDC00)+0x10000);
string[i] = "&#x"+codePoint.toString(16).toUpperCase()+";";
string[i+1] = "";
i++;
} else {
// n is a lead surrogate without corresponding trail surrogate:
// remove that character.
string[i] = "";
}
} }
return string.join(""); return string.join("");
} }
}); });
//
// Override math.toMathML in order to add semantics tag
// for the input format, if the user requests that in the
// Show As menu.
//
MML.math.Augment({
toMathML: function (space,jax) {
var annotation;
if (space == null) {space = ""}
if (jax && jax.originalText && SETTINGS.semantics)
{annotation = MathJax.InputJax[jax.inputJax].annotationEncoding}
var nested = (this.data[0] && this.data[0].data.length > 1);
var tag = this.type, attr = this.toMathMLattributes();
var data = [], SPACE = space + (annotation ? " " + (nested ? " " : "") : "") + " ";
for (var i = 0, m = this.data.length; i < m; i++) {
if (this.data[i]) {data.push(this.data[i].toMathML(SPACE))}
else {data.push(SPACE+"<mrow />")}
}
if (data.length === 0 || (data.length === 1 && data[0] === "")) {
if (!annotation) {return "<"+tag+attr+" />"}
data.push(SPACE+"<mrow />");
}
if (annotation) {
if (nested) {data.unshift(space+" <mrow>"); data.push(space+" </mrow>")}
data.unshift(space+" <semantics>");
var xmlEscapedTex = jax.originalText.replace(/[&<>]/g, function(item) {
return { '>': '&gt;', '<': '&lt;','&': '&amp;' }[item]
});
data.push(space+' <annotation encoding="'+annotation+'">'+xmlEscapedTex+"</annotation>");
data.push(space+" </semantics>");
}
return space+"<"+tag+attr+">\n"+data.join("\n")+"\n"+space+"</"+tag+">";
}
});
MML.msubsup.Augment({ MML.msubsup.Augment({
toMathML: function (space) { toMathML: function (space) {
var tag = this.type; var tag = this.type;

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/jax/element/mml/jax.js * MathJax/jax/element/mml/jax.js
@ -8,7 +11,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +30,7 @@ MathJax.ElementJax.mml = MathJax.ElementJax({
mimeType: "jax/mml" mimeType: "jax/mml"
},{ },{
id: "mml", id: "mml",
version: "2.0", version: "2.6.0",
directory: MathJax.ElementJax.directory + "/mml", directory: MathJax.ElementJax.directory + "/mml",
extensionDir: MathJax.ElementJax.extensionDir + "/mml", extensionDir: MathJax.ElementJax.extensionDir + "/mml",
optableDir: MathJax.ElementJax.directory + "/mml/optable" optableDir: MathJax.ElementJax.directory + "/mml/optable"
@ -129,8 +132,10 @@ MathJax.ElementJax.mml.Augment({
BOTTOM: "bottom", BOTTOM: "bottom",
UPDIAGONALSTRIKE: "updiagonalstrike", UPDIAGONALSTRIKE: "updiagonalstrike",
DOWNDIAGONALSTRIKE: "downdiagonalstrike", DOWNDIAGONALSTRIKE: "downdiagonalstrike",
UPDIAGONALARROW: "updiagonalarrow",
VERTICALSTRIKE: "verticalstrike", VERTICALSTRIKE: "verticalstrike",
HORIZONTALSTRIKE: "horizontalstrike", HORIZONTALSTRIKE: "horizontalstrike",
PHASORANGLE: "phasorangle",
MADRUWB: "madruwb" MADRUWB: "madruwb"
}, },
ALIGN: { ALIGN: {
@ -209,17 +214,41 @@ MathJax.ElementJax.mml.Augment({
NONE: -1 NONE: -1
}, },
TEXCLASSNAMES: ["ORD", "OP", "BIN", "REL", "OPEN", "CLOSE", "PUNCT", "INNER", "VCENTER"], TEXCLASSNAMES: ["ORD", "OP", "BIN", "REL", "OPEN", "CLOSE", "PUNCT", "INNER", "VCENTER"],
skipAttributes: {
texClass:true, useHeight:true, texprimestyle:true
},
copyAttributes: { copyAttributes: {
displaystyle:1, scriptlevel:1, open:1, close:1, form:1,
actiontype: 1,
fontfamily:true, fontsize:true, fontweight:true, fontstyle:true, fontfamily:true, fontsize:true, fontweight:true, fontstyle:true,
color:true, background:true, color:true, background:true,
id:true, "class":true, href:true, style:true id:true, "class":1, href:true, style:true
}, },
skipAttributes: {texClass: true, useHeight: true, texprimestyle: true},
copyAttributeNames: [ copyAttributeNames: [
"displaystyle", "scriptlevel", "open", "close", "form", // force these to be copied
"actiontype",
"fontfamily", "fontsize", "fontweight", "fontstyle", "fontfamily", "fontsize", "fontweight", "fontstyle",
"color", "background", "color", "background",
"id", "class", "href", "style" "id", "class", "href", "style"
] ],
nocopyAttributes: {
fontfamily: true, fontsize: true, fontweight: true, fontstyle: true,
color: true, background: true,
id: true, 'class': true, href: true, style: true,
xmlns: true
},
Error: function (message,def) {
var mml = this.merror(message),
dir = MathJax.Localization.fontDirection(),
font = MathJax.Localization.fontFamily();
if (def) {mml = mml.With(def)}
if (dir || font) {
mml = this.mstyle(mml);
if (dir) {mml.dir = dir}
if (font) {mml.style.fontFamily = "font-family: "+font}
}
return mml;
}
}); });
(function (MML) { (function (MML) {
@ -228,18 +257,20 @@ MathJax.ElementJax.mml.Augment({
type: "base", isToken: false, type: "base", isToken: false,
defaults: { defaults: {
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT mathcolor: MML.INHERIT,
dir: MML.INHERIT
}, },
noInherit: {}, noInherit: {},
noInheritAttribute: { noInheritAttribute: {
texClass: true texClass: true
}, },
getRemoved: {},
linebreakContainer: false, linebreakContainer: false,
Init: function () { Init: function () {
this.data = []; this.data = [];
if (this.inferRow && !(arguments.length === 1 && arguments[0].inferred)) if (this.inferRow && !(arguments.length === 1 && arguments[0].inferred))
{this.Append(MML.mrow().With({inferred: true}))} {this.Append(MML.mrow().With({inferred: true, notParent: true}))}
this.Append.apply(this,arguments); this.Append.apply(this,arguments);
}, },
With: function (def) { With: function (def) {
@ -257,7 +288,7 @@ MathJax.ElementJax.mml.Augment({
SetData: function (i,item) { SetData: function (i,item) {
if (item != null) { if (item != null) {
if (!(item instanceof MML.mbase)) if (!(item instanceof MML.mbase))
{item = (this.isToken ? MML.chars(item) : MML.mtext(item))} {item = (this.isToken || this.isChars ? MML.chars(item) : MML.mtext(item))}
item.parent = this; item.parent = this;
item.setInherit(this.inheritFromMe ? this : this.inherit); item.setInherit(this.inheritFromMe ? this : this.inherit);
} }
@ -265,21 +296,25 @@ MathJax.ElementJax.mml.Augment({
}, },
Parent: function () { Parent: function () {
var parent = this.parent; var parent = this.parent;
while (parent && parent.inferred) {parent = parent.parent} while (parent && parent.notParent) {parent = parent.parent}
return parent; return parent;
}, },
Get: function (name,nodefault) { Get: function (name,nodefault,noself) {
if (!noself) {
if (this[name] != null) {return this[name]} if (this[name] != null) {return this[name]}
if (this.attr && this.attr[name] != null) {return this.attr[name]} if (this.attr && this.attr[name] != null) {return this.attr[name]}
}
// FIXME: should cache these values and get from cache // FIXME: should cache these values and get from cache
// (clear cache when appended to a new object?) // (clear cache when appended to a new object?)
var parent = this.Parent(); var parent = this.Parent();
if (parent && parent["adjustChild_"+name] != null) if (parent && parent["adjustChild_"+name] != null) {
{return (parent["adjustChild_"+name])(parent.childPosition(this))} return (parent["adjustChild_"+name])(this.childPosition(),nodefault);
}
var obj = this.inherit; var root = obj; var obj = this.inherit; var root = obj;
while (obj) { while (obj) {
var value = obj[name]; if (value == null && obj.attr) {value = obj.attr[name]} var value = obj[name]; if (value == null && obj.attr) {value = obj.attr[name]}
if (value != null && !obj.noInheritAttribute[name]) { if (obj.removedStyles && obj.getRemoved[name] && value == null) value = obj.removedStyles[obj.getRemoved[name]];
if (value != null && obj.noInheritAttribute && !obj.noInheritAttribute[name]) {
var noInherit = obj.noInherit[this.type]; var noInherit = obj.noInherit[this.type];
if (!(noInherit && noInherit[name])) {return value} if (!(noInherit && noInherit[name])) {return value}
} }
@ -300,12 +335,13 @@ MathJax.ElementJax.mml.Augment({
{values[arguments[i]] = this.Get(arguments[i])} {values[arguments[i]] = this.Get(arguments[i])}
return values; return values;
}, },
adjustChild_scriptlevel: function (i) {return this.Get("scriptlevel")}, // always inherit from parent adjustChild_scriptlevel: function (i,nodef) {return this.Get("scriptlevel",nodef)}, // always inherit from parent
adjustChild_displaystyle: function (i) {return this.Get("displaystyle")}, // always inherit from parent adjustChild_displaystyle: function (i,nodef) {return this.Get("displaystyle",nodef)}, // always inherit from parent
adjustChild_texprimestyle: function (i) {return this.Get("texprimestyle")}, // always inherit from parent adjustChild_texprimestyle: function (i,nodef) {return this.Get("texprimestyle",nodef)}, // always inherit from parent
childPosition: function (child) { childPosition: function () {
if (child.parent.inferred) {child = child.parent} var child = this, parent = child.parent;
for (var i = 0, m = this.data.length; i < m; i++) {if (this.data[i] === child) {return i}} while (parent.notParent) {child = parent; parent = child.parent}
for (var i = 0, m = parent.data.length; i < m; i++) {if (parent.data[i] === child) {return i}}
return null; return null;
}, },
setInherit: function (obj) { setInherit: function (obj) {
@ -365,6 +401,13 @@ MathJax.ElementJax.mml.Augment({
isEmbellished: function () {return false}, isEmbellished: function () {return false},
Core: function () {return this}, Core: function () {return this},
CoreMO: function () {return this}, CoreMO: function () {return this},
childIndex: function(child) {
if (child == null) return;
for (var i = 0, m = this.data.length; i < m; i++) if (child === this.data[i]) return i;
},
CoreIndex: function () {
return (this.inferRow ? this.data[0]||this : this).childIndex(this.Core());
},
hasNewline: function () { hasNewline: function () {
if (this.isEmbellished()) {return this.CoreMO().hasNewline()} if (this.isEmbellished()) {return this.CoreMO().hasNewline()}
if (this.isToken || this.linebreakContainer) {return false} if (this.isToken || this.linebreakContainer) {return false}
@ -374,7 +417,8 @@ MathJax.ElementJax.mml.Augment({
return false; return false;
}, },
array: function () {if (this.inferred) {return this.data} else {return [this]}}, array: function () {if (this.inferred) {return this.data} else {return [this]}},
toString: function () {return this.type+"("+this.data.join(",")+")"} toString: function () {return this.type+"("+this.data.join(",")+")"},
getAnnotation: function () {return null}
},{ },{
childrenSpacelike: function () { childrenSpacelike: function () {
for (var i = 0, m = this.data.length; i < m; i++) for (var i = 0, m = this.data.length; i < m; i++)
@ -384,7 +428,7 @@ MathJax.ElementJax.mml.Augment({
childEmbellished: function () { childEmbellished: function () {
return (this.data[0] && this.data[0].isEmbellished()); return (this.data[0] && this.data[0].isEmbellished());
}, },
childCore: function () {return this.data[0]}, childCore: function () {return (this.inferRow && this.data[0] ? this.data[0].Core() : this.data[0])},
childCoreMO: function () {return (this.data[0] ? this.data[0].CoreMO() : null)}, childCoreMO: function () {return (this.data[0] ? this.data[0].CoreMO() : null)},
setChildTeXclass: function (prev) { setChildTeXclass: function (prev) {
if (this.data[0]) { if (this.data[0]) {
@ -395,10 +439,12 @@ MathJax.ElementJax.mml.Augment({
}, },
setBaseTeXclasses: function (prev) { setBaseTeXclasses: function (prev) {
this.getPrevClass(prev); this.texClass = null; this.getPrevClass(prev); this.texClass = null;
if (this.isEmbellished()) { if (this.data[0]) {
if (this.isEmbellished() || this.data[0].isa(MML.mi)) {
prev = this.data[0].setTeXclass(prev); prev = this.data[0].setTeXclass(prev);
this.updateTeXclass(this.Core()); this.updateTeXclass(this.Core());
} else {if (this.data[0]) {this.data[0].setTeXclass()}; prev = this} } else {this.data[0].setTeXclass(); prev = this}
} else {prev = this}
for (var i = 1, m = this.data.length; i < m; i++) for (var i = 1, m = this.data.length; i < m; i++)
{if (this.data[i]) {this.data[i].setTeXclass()}} {if (this.data[i]) {this.data[i].setTeXclass()}}
return prev; return prev;
@ -419,7 +465,8 @@ MathJax.ElementJax.mml.Augment({
mathvariant: MML.AUTO, mathvariant: MML.AUTO,
mathsize: MML.INHERIT, mathsize: MML.INHERIT,
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT mathcolor: MML.INHERIT,
dir: MML.INHERIT
}, },
autoDefault: function (name) { autoDefault: function (name) {
if (name === "mathvariant") { if (name === "mathvariant") {
@ -429,6 +476,16 @@ MathJax.ElementJax.mml.Augment({
MML.VARIANT.ITALIC : MML.VARIANT.NORMAL); MML.VARIANT.ITALIC : MML.VARIANT.NORMAL);
} }
return ""; return "";
},
setTeXclass: function (prev) {
this.getPrevClass(prev);
var name = this.data.join("");
if (name.length > 1 && name.match(/^[a-z][a-z0-9]*$/i) &&
this.texClass === MML.TEXCLASS.ORD) {
this.texClass = MML.TEXCLASS.OP;
this.autoOP = true;
}
return this;
} }
}); });
@ -439,7 +496,8 @@ MathJax.ElementJax.mml.Augment({
mathvariant: MML.INHERIT, mathvariant: MML.INHERIT,
mathsize: MML.INHERIT, mathsize: MML.INHERIT,
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT mathcolor: MML.INHERIT,
dir: MML.INHERIT
} }
}); });
@ -450,6 +508,7 @@ MathJax.ElementJax.mml.Augment({
mathsize: MML.INHERIT, mathsize: MML.INHERIT,
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT, mathcolor: MML.INHERIT,
dir: MML.INHERIT,
form: MML.AUTO, form: MML.AUTO,
fence: MML.AUTO, fence: MML.AUTO,
separator: MML.AUTO, separator: MML.AUTO,
@ -482,7 +541,7 @@ MathJax.ElementJax.mml.Augment({
lspace: MML.LENGTH.THICKMATHSPACE, lspace: MML.LENGTH.THICKMATHSPACE,
rspace: MML.LENGTH.THICKMATHSPACE, rspace: MML.LENGTH.THICKMATHSPACE,
stretchy: false, stretchy: false,
symmetric: true, symmetric: false,
maxsize: MML.SIZE.INFINITY, maxsize: MML.SIZE.INFINITY,
minsize: '0em', //'1em', minsize: '0em', //'1em',
largeop: false, largeop: false,
@ -515,8 +574,8 @@ MathJax.ElementJax.mml.Augment({
if (!def) {def = this.CheckRange(mo)} if (!def) {def = this.CheckRange(mo)}
if (!def && nodefault) {def = {}} else { if (!def && nodefault) {def = {}} else {
if (!def) {def = MathJax.Hub.Insert({},this.defaultDef)} if (!def) {def = MathJax.Hub.Insert({},this.defaultDef)}
if (this.parent) {this.def = def} else {def = MathJax.Hub.Insert({},def)}
def.form = forms[0]; def.form = forms[0];
this.def = def;
} }
} }
this.useMMLspacing &= ~(this.SPACE_ATTR[name] || 0); this.useMMLspacing &= ~(this.SPACE_ATTR[name] || 0);
@ -564,12 +623,63 @@ MathJax.ElementJax.mml.Augment({
}, },
isEmbellished: function () {return true}, isEmbellished: function () {return true},
hasNewline: function () {return (this.Get("linebreak") === MML.LINEBREAK.NEWLINE)}, hasNewline: function () {return (this.Get("linebreak") === MML.LINEBREAK.NEWLINE)},
CoreParent: function () {
var parent = this;
while (parent && parent.isEmbellished() &&
parent.CoreMO() === this && !parent.isa(MML.math)) {parent = parent.Parent()}
return parent;
},
CoreText: function (parent) {
if (!parent) {return ""}
if (parent.isEmbellished()) {return parent.CoreMO().data.join("")}
while ((((parent.isa(MML.mrow) || parent.isa(MML.TeXAtom) ||
parent.isa(MML.mstyle) || parent.isa(MML.mphantom)) &&
parent.data.length === 1) || parent.isa(MML.munderover)) &&
parent.data[0]) {parent = parent.data[0]}
if (!parent.isToken) {return ""} else {return parent.data.join("")}
},
remapChars: {
'*':"\u2217",
'"':"\u2033",
"\u00B0":"\u2218",
"\u00B2":"2",
"\u00B3":"3",
"\u00B4":"\u2032",
"\u00B9":"1"
},
remap: function (text,map) {
text = text.replace(/-/g,"\u2212");
if (map) {
text = text.replace(/'/g,"\u2032").replace(/`/g,"\u2035");
if (text.length === 1) {text = map[text]||text}
}
return text;
},
setTeXclass: function (prev) { setTeXclass: function (prev) {
this.getValues("lspace","rspace"); // sets useMMLspacing var values = this.getValues("form","lspace","rspace","fence"); // sets useMMLspacing
if (this.useMMLspacing) {this.texClass = MML.TEXCLASS.NONE; return this} if (this.useMMLspacing) {this.texClass = MML.TEXCLASS.NONE; return this}
this.texClass = this.Get("texClass"); if (this.texClass === MML.TEXCLASS.NONE) {return prev} if (values.fence && !this.texClass) {
if (prev) {this.prevClass = prev.texClass || MML.TEXCLASS.ORD; this.prevLevel = prev.Get("scriptlevel")} if (values.form === MML.FORM.PREFIX) {this.texClass = MML.TEXCLASS.OPEN}
else {this.prevClass = MML.TEXCLASS.NONE} if (values.form === MML.FORM.POSTFIX) {this.texClass = MML.TEXCLASS.CLOSE}
}
this.texClass = this.Get("texClass");
if (this.data.join("") === "\u2061") {
// force previous node to be texClass OP, and skip this node
if (prev) {prev.texClass = MML.TEXCLASS.OP; prev.fnOP = true}
this.texClass = this.prevClass = MML.TEXCLASS.NONE;
return prev;
}
return this.adjustTeXclass(prev);
},
adjustTeXclass: function (prev) {
if (this.texClass === MML.TEXCLASS.NONE) {return prev}
if (prev) {
if (prev.autoOP && (this.texClass === MML.TEXCLASS.BIN ||
this.texClass === MML.TEXCLASS.REL))
{prev.texClass = MML.TEXCLASS.ORD}
this.prevClass = prev.texClass || MML.TEXCLASS.ORD;
this.prevLevel = prev.Get("scriptlevel")
} else {this.prevClass = MML.TEXCLASS.NONE}
if (this.texClass === MML.TEXCLASS.BIN && if (this.texClass === MML.TEXCLASS.BIN &&
(this.prevClass === MML.TEXCLASS.NONE || (this.prevClass === MML.TEXCLASS.NONE ||
this.prevClass === MML.TEXCLASS.BIN || this.prevClass === MML.TEXCLASS.BIN ||
@ -583,6 +693,17 @@ MathJax.ElementJax.mml.Augment({
this.texClass === MML.TEXCLASS.CLOSE || this.texClass === MML.TEXCLASS.CLOSE ||
this.texClass === MML.TEXCLASS.PUNCT)) { this.texClass === MML.TEXCLASS.PUNCT)) {
prev.texClass = this.prevClass = MML.TEXCLASS.ORD; prev.texClass = this.prevClass = MML.TEXCLASS.ORD;
} else if (this.texClass === MML.TEXCLASS.BIN) {
//
// Check if node is the last one in its container since the rule
// above only takes effect if there is a node that follows.
//
var child = this, parent = this.parent;
while (parent && parent.parent && parent.isEmbellished() &&
(parent.data.length === 1 ||
(parent.type !== "mrow" && parent.Core() === child))) // handles msubsup and munderover
{child = parent; parent = parent.parent}
if (parent.data[parent.data.length-1] === child) this.texClass = MML.TEXCLASS.ORD;
} }
return this; return this;
} }
@ -596,7 +717,8 @@ MathJax.ElementJax.mml.Augment({
mathvariant: MML.INHERIT, mathvariant: MML.INHERIT,
mathsize: MML.INHERIT, mathsize: MML.INHERIT,
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT mathcolor: MML.INHERIT,
dir: MML.INHERIT
} }
}); });
@ -611,7 +733,16 @@ MathJax.ElementJax.mml.Augment({
depth: "0ex", depth: "0ex",
linebreak: MML.LINEBREAK.AUTO linebreak: MML.LINEBREAK.AUTO
}, },
hasNewline: function () {return (this.Get("linebreak") === MML.LINEBREAK.NEWLINE)} hasDimAttr: function () {
return (this.hasValue("width") || this.hasValue("height") ||
this.hasValue("depth"));
},
hasNewline: function () {
// The MathML spec says that the linebreak attribute should be ignored
// if any dimensional attribute is set.
return (!this.hasDimAttr() &&
this.Get("linebreak") === MML.LINEBREAK.NEWLINE);
}
}); });
MML.ms = MML.mbase.Subclass({ MML.ms = MML.mbase.Subclass({
@ -622,6 +753,7 @@ MathJax.ElementJax.mml.Augment({
mathsize: MML.INHERIT, mathsize: MML.INHERIT,
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT, mathcolor: MML.INHERIT,
dir: MML.INHERIT,
lquote: '"', lquote: '"',
rquote: '"' rquote: '"'
} }
@ -644,7 +776,7 @@ MathJax.ElementJax.mml.Augment({
MML.mrow = MML.mbase.Subclass({ MML.mrow = MML.mbase.Subclass({
type: "mrow", type: "mrow",
isSpacelike: MML.mbase.childrenSpacelike, isSpacelike: MML.mbase.childrenSpacelike,
inferred: false, inferred: false, notParent: false,
isEmbellished: function () { isEmbellished: function () {
var isEmbellished = false; var isEmbellished = false;
for (var i = 0, m = this.data.length; i < m; i++) { for (var i = 0, m = this.data.length; i < m; i++) {
@ -685,17 +817,37 @@ MathJax.ElementJax.mml.Augment({
return this.SUPER(arguments).toString.call(this); return this.SUPER(arguments).toString.call(this);
}, },
setTeXclass: function (prev) { setTeXclass: function (prev) {
for (var i = 0, m = this.data.length; i < m; i++) var i, m = this.data.length;
if ((this.open || this.close) && (!prev || !prev.fnOP)) {
//
// <mrow> came from \left...\right
// so treat as subexpression (tex class INNER)
//
this.getPrevClass(prev); prev = null;
for (i = 0; i < m; i++)
{if (this.data[i]) {prev = this.data[i].setTeXclass(prev)}}
if (!this.hasOwnProperty("texClass")) this.texClass = MML.TEXCLASS.INNER;
return this;
} else {
//
// Normal <mrow>, so treat as
// thorugh mrow is not there
//
for (i = 0; i < m; i++)
{if (this.data[i]) {prev = this.data[i].setTeXclass(prev)}} {if (this.data[i]) {prev = this.data[i].setTeXclass(prev)}}
if (this.data[0]) {this.updateTeXclass(this.data[0])} if (this.data[0]) {this.updateTeXclass(this.data[0])}
return prev; return prev;
} }
},
getAnnotation: function (name) {
if (this.data.length != 1) return null;
return this.data[0].getAnnotation(name);
}
}); });
MML.mfrac = MML.mbase.Subclass({ MML.mfrac = MML.mbase.Subclass({
type: "mfrac", num: 0, den: 1, type: "mfrac", num: 0, den: 1,
linebreakContainer: true, linebreakContainer: true,
texClass: MML.TEXCLASS.INNER,
isEmbellished: MML.mbase.childEmbellished, isEmbellished: MML.mbase.childEmbellished,
Core: MML.mbase.childCore, Core: MML.mbase.childCore,
CoreMO: MML.mbase.childCoreMO, CoreMO: MML.mbase.childCoreMO,
@ -763,6 +915,7 @@ MathJax.ElementJax.mml.Augment({
scriptminsize: "8pt", scriptminsize: "8pt",
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT, mathcolor: MML.INHERIT,
dir: MML.INHERIT,
infixlinebreakstyle: MML.LINEBREAKSTYLE.BEFORE, infixlinebreakstyle: MML.LINEBREAKSTYLE.BEFORE,
decimalseparator: "." decimalseparator: "."
}, },
@ -771,9 +924,7 @@ MathJax.ElementJax.mml.Augment({
if (level == null) { if (level == null) {
level = this.Get("scriptlevel"); level = this.Get("scriptlevel");
} else if (String(level).match(/^ *[-+]/)) { } else if (String(level).match(/^ *[-+]/)) {
delete this.scriptlevel; var LEVEL = this.Get("scriptlevel",null,true);
var LEVEL = this.Get("scriptlevel");
this.scriptlevel = level;
level = LEVEL + parseInt(level); level = LEVEL + parseInt(level);
} }
return level; return level;
@ -783,6 +934,7 @@ MathJax.ElementJax.mml.Augment({
mpadded: {width: true, height: true, depth: true, lspace: true, voffset: true}, mpadded: {width: true, height: true, depth: true, lspace: true, voffset: true},
mtable: {width: true, height: true, depth: true, align: true} mtable: {width: true, height: true, depth: true, align: true}
}, },
getRemoved: {fontfamily:"fontFamily", fontweight:"fontWeight", fontstyle:"fontStyle", fontsize:"fontSize"},
setTeXclass: MML.mbase.setChildTeXclass setTeXclass: MML.mbase.setChildTeXclass
}); });
@ -832,42 +984,62 @@ MathJax.ElementJax.mml.Augment({
close: ')', close: ')',
separators: ',' separators: ','
}, },
texClass: MML.TEXCLASS.OPEN, addFakeNodes: function () {
setTeXclass: function (prev) {
this.getPrevClass(prev);
var values = this.getValues("open","close","separators"); var values = this.getValues("open","close","separators");
values.open = values.open.replace(/[ \t\n\r]/g,""); values.open = values.open.replace(/[ \t\n\r]/g,"");
values.close = values.close.replace(/[ \t\n\r]/g,""); values.close = values.close.replace(/[ \t\n\r]/g,"");
values.separators = values.separators.replace(/[ \t\n\r]/g,""); values.separators = values.separators.replace(/[ \t\n\r]/g,"");
// create a fake node for the open item //
// Create a fake node for the open item
//
if (values.open !== "") { if (values.open !== "") {
this.SetData("open",MML.mo(values.open).With({stretchy:true, texClass:MML.TEXCLASS.OPEN})); this.SetData("open",MML.mo(values.open).With({
prev = this.data.open.setTeXclass(prev); fence:true, form:MML.FORM.PREFIX, texClass:MML.TEXCLASS.OPEN
}));
//
// Clear flag for using MML spacing even though form is specified
//
this.data.open.useMMLspacing = 0;
} }
// get the separators //
// Create fake nodes for the separators
//
if (values.separators !== "") { if (values.separators !== "") {
while (values.separators.length < this.data.length) while (values.separators.length < this.data.length)
{values.separators += values.separators.charAt(values.separators.length-1)} {values.separators += values.separators.charAt(values.separators.length-1)}
}
// handle the first item, if any
if (this.data[0]) {prev = this.data[0].setTeXclass(prev)}
// add fake nodes for separators and handle the following item
for (var i = 1, m = this.data.length; i < m; i++) { for (var i = 1, m = this.data.length; i < m; i++) {
if (this.data[i]) { if (this.data[i]) {
if (values.separators !== "") { this.SetData("sep"+i,MML.mo(values.separators.charAt(i-1)).With({separator:true}))
this.SetData("sep"+i,MML.mo(values.separators.charAt(i-1))); this.data["sep"+i].useMMLspacing = 0;
prev = this.data["sep"+i].setTeXclass(prev);
}
prev = this.data[i].setTeXclass(prev);
} }
} }
// create fake node for the close item }
//
// Create fake node for the close item
//
if (values.close !== "") { if (values.close !== "") {
this.SetData("close",MML.mo(values.close).With({stretchy:true, texClass:MML.TEXCLASS.CLOSE})); this.SetData("close",MML.mo(values.close).With({
prev = this.data.close.setTeXclass(prev); fence:true, form:MML.FORM.POSTFIX, texClass:MML.TEXCLASS.CLOSE
}));
//
// Clear flag for using MML spacing even though form is specified
//
this.data.close.useMMLspacing = 0;
} }
// get the data from the open item },
texClass: MML.TEXCLASS.OPEN,
setTeXclass: function (prev) {
this.addFakeNodes();
this.getPrevClass(prev);
if (this.data.open) {prev = this.data.open.setTeXclass(prev)}
if (this.data[0]) {prev = this.data[0].setTeXclass(prev)}
for (var i = 1, m = this.data.length; i < m; i++) {
if (this.data["sep"+i]) {prev = this.data["sep"+i].setTeXclass(prev)}
if (this.data[i]) {prev = this.data[i].setTeXclass(prev)}
}
if (this.data.close) {prev = this.data.close.setTeXclass(prev)}
this.updateTeXclass(this.data.open); this.updateTeXclass(this.data.open);
this.texClass = MML.TEXCLASS.INNER;
return prev; return prev;
} }
}); });
@ -887,7 +1059,6 @@ MathJax.ElementJax.mml.Augment({
MML.msubsup = MML.mbase.Subclass({ MML.msubsup = MML.mbase.Subclass({
type: "msubsup", base: 0, sub: 1, sup: 2, type: "msubsup", base: 0, sub: 1, sup: 2,
linebreakContainer: true,
isEmbellished: MML.mbase.childEmbellished, isEmbellished: MML.mbase.childEmbellished,
Core: MML.mbase.childCore, Core: MML.mbase.childCore,
CoreMO: MML.mbase.childCoreMO, CoreMO: MML.mbase.childCoreMO,
@ -1007,13 +1178,19 @@ MathJax.ElementJax.mml.Augment({
texClass: MML.TEXCLASS.ORD, texClass: MML.TEXCLASS.ORD,
useHeight: 1 useHeight: 1
}, },
adjustChild_displaystyle: function () {
return (this.displaystyle != null ? this.displaystyle : this.defaults.displaystyle);
},
inheritFromMe: true, inheritFromMe: true,
noInherit: { noInherit: {
mover: {align: true},
munder: {align: true},
munderover: {align: true},
mtable: { mtable: {
align: true, rowalign: true, columnalign: true, groupalign: true, align: true, rowalign: true, columnalign: true, groupalign: true,
alignmentscope: true, columnwidth: true, width: true, rowspacing: true, alignmentscope: true, columnwidth: true, width: true, rowspacing: true,
columnspacing: true, rowlines: true, columnlines: true, frame: true, columnspacing: true, rowlines: true, columnlines: true, frame: true,
framespacing: true, equalrows: true, equalcolumns: true, framespacing: true, equalrows: true, equalcolumns: true, displaystyle: true,
side: true, minlabelspacing: true, texClass: true, useHeight: 1 side: true, minlabelspacing: true, texClass: true, useHeight: 1
} }
}, },
@ -1021,7 +1198,7 @@ MathJax.ElementJax.mml.Augment({
Append: function () { Append: function () {
for (var i = 0, m = arguments.length; i < m; i++) { for (var i = 0, m = arguments.length; i < m; i++) {
if (!((arguments[i] instanceof MML.mtr) || if (!((arguments[i] instanceof MML.mtr) ||
(arguments[i] instanceof MML.mlabeledtr))) {arguments[i] = MML.mtd(arguments[i])} (arguments[i] instanceof MML.mlabeledtr))) {arguments[i] = MML.mtr(arguments[i])}
} }
this.SUPER(arguments).Append.apply(this,arguments); this.SUPER(arguments).Append.apply(this,arguments);
}, },
@ -1072,7 +1249,7 @@ MathJax.ElementJax.mml.Augment({
}); });
MML.maligngroup = MML.mbase.Subclass({ MML.maligngroup = MML.mbase.Subclass({
type: "malign", type: "maligngroup",
isSpacelike: function () {return true}, isSpacelike: function () {return true},
defaults: { defaults: {
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
@ -1113,11 +1290,20 @@ MathJax.ElementJax.mml.Augment({
isSpacelike: function () {return this.selected().isSpacelike()}, isSpacelike: function () {return this.selected().isSpacelike()},
Core: function () {return this.selected().Core()}, Core: function () {return this.selected().Core()},
CoreMO: function () {return this.selected().CoreMO()}, CoreMO: function () {return this.selected().CoreMO()},
setTeXclass: function (prev) {return this.selected().setTeXclass(prev)} setTeXclass: function (prev) {
if (this.Get("actiontype") === MML.ACTIONTYPE.TOOLTIP && this.data[1]) {
// Make sure tooltip has proper spacing when typeset (see issue #412)
this.data[1].setTeXclass();
}
var selected = this.selected();
prev = selected.setTeXclass(prev);
this.updateTeXclass(selected);
return prev;
}
}); });
MML.semantics = MML.mbase.Subclass({ MML.semantics = MML.mbase.Subclass({
type: "semantics", type: "semantics", notParent: true,
isEmbellished: MML.mbase.childEmbellished, isEmbellished: MML.mbase.childEmbellished,
Core: MML.mbase.childCore, Core: MML.mbase.childCore,
CoreMO: MML.mbase.childCoreMO, CoreMO: MML.mbase.childCoreMO,
@ -1125,10 +1311,24 @@ MathJax.ElementJax.mml.Augment({
definitionURL: null, definitionURL: null,
encoding: null encoding: null
}, },
setTeXclass: MML.mbase.setChildTeXclass setTeXclass: MML.mbase.setChildTeXclass,
getAnnotation: function (name) {
var encodingList = MathJax.Hub.config.MathMenu.semanticsAnnotations[name];
if (encodingList) {
for (var i = 0, m = this.data.length; i < m; i++) {
var encoding = this.data[i].Get("encoding");
if (encoding) {
for (var j = 0, n = encodingList.length; j < n; j++) {
if (encodingList[j] === encoding) return this.data[i];
}
}
}
}
return null;
}
}); });
MML.annotation = MML.mbase.Subclass({ MML.annotation = MML.mbase.Subclass({
type: "annotation", isToken: true, type: "annotation", isChars: true,
linebreakContainer: true, linebreakContainer: true,
defaults: { defaults: {
definitionURL: null, definitionURL: null,
@ -1157,6 +1357,7 @@ MathJax.ElementJax.mml.Augment({
mathsize: MML.SIZE.NORMAL, mathsize: MML.SIZE.NORMAL,
mathcolor: "", // should be "black", but allow it to inherit from surrounding text mathcolor: "", // should be "black", but allow it to inherit from surrounding text
mathbackground: MML.COLOR.TRANSPARENT, mathbackground: MML.COLOR.TRANSPARENT,
dir: "ltr",
scriptlevel: 0, scriptlevel: 0,
displaystyle: MML.AUTO, displaystyle: MML.AUTO,
display: "inline", display: "inline",
@ -1186,7 +1387,11 @@ MathJax.ElementJax.mml.Augment({
return ""; return "";
}, },
linebreakContainer: true, linebreakContainer: true,
setTeXclass: MML.mbase.setChildTeXclass setTeXclass: MML.mbase.setChildTeXclass,
getAnnotation: function (name) {
if (this.data.length != 1) return null;
return this.data[0].getAnnotation(name);
}
}); });
MML.chars = MML.mbase.Subclass({ MML.chars = MML.mbase.Subclass({
@ -1234,7 +1439,6 @@ MathJax.ElementJax.mml.Augment({
var nNode, i, m; var nNode, i, m;
if (node.nodeType === 1) { // ELEMENT_NODE if (node.nodeType === 1) { // ELEMENT_NODE
nNode = document.createElement(node.nodeName); nNode = document.createElement(node.nodeName);
if (node.className) {nNode.className=iNode.className}
for (i = 0, m = node.attributes.length; i < m; i++) { for (i = 0, m = node.attributes.length; i < m; i++) {
var attribute = node.attributes[i]; var attribute = node.attributes[i];
if (attribute.specified && attribute.nodeValue != null && attribute.nodeValue != '') if (attribute.specified && attribute.nodeValue != null && attribute.nodeValue != '')
@ -1259,13 +1463,16 @@ MathJax.ElementJax.mml.Augment({
MML.TeXAtom = MML.mbase.Subclass({ MML.TeXAtom = MML.mbase.Subclass({
type: "texatom", type: "texatom",
inferRow: true, inferRow: true, notParent: true,
texClass: MML.TEXCLASS.ORD, texClass: MML.TEXCLASS.ORD,
Core: MML.mbase.childCore,
CoreMO: MML.mbase.childCoreMO,
isEmbellished: MML.mbase.childEmbellished,
setTeXclass: function (prev) { setTeXclass: function (prev) {
this.getPrevClass(prev);
this.data[0].setTeXclass(); this.data[0].setTeXclass();
return this; return this.adjustTeXclass(prev);
} },
adjustTeXclass: MML.mo.prototype.adjustTeXclass
}); });
MML.NULL = MML.mbase().With({type:"null"}); MML.NULL = MML.mbase().With({type:"null"});
@ -1597,8 +1804,13 @@ MathJax.ElementJax.mml.Augment({
// These are not in the W3C table, but FF works this way, // These are not in the W3C table, but FF works this way,
// and it makes sense, so add it here // and it makes sense, so add it here
// //
MML.mo.prototype.OPTABLE.infix["^"] = MO.WIDEREL; var OPTABLE = MML.mo.prototype.OPTABLE;
MML.mo.prototype.OPTABLE.infix["_"] = MO.WIDEREL; OPTABLE.infix["^"] = MO.WIDEREL;
OPTABLE.infix["_"] = MO.WIDEREL;
OPTABLE.prefix["\u2223"] = MO.OPEN;
OPTABLE.prefix["\u2225"] = MO.OPEN;
OPTABLE.postfix["\u2223"] = MO.CLOSE;
OPTABLE.postfix["\u2225"] = MO.CLOSE;
})(MathJax.ElementJax.mml); })(MathJax.ElementJax.mml);

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/Arrows.js * MathJax/jax/output/HTML-CSS/optable/Arrows.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/BasicLatin.js * MathJax/jax/output/HTML-CSS/optable/BasicLatin.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/CombDiacritMarks.js * MathJax/jax/output/HTML-CSS/optable/CombDiacritMarks.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/CombDiactForSymbols.js * MathJax/jax/output/HTML-CSS/optable/CombDiactForSymbols.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/Dingbats.js * MathJax/jax/output/HTML-CSS/optable/Dingbats.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/GeneralPunctuation.js * MathJax/jax/output/HTML-CSS/optable/GeneralPunctuation.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/GeometricShapes.js * MathJax/jax/output/HTML-CSS/optable/GeometricShapes.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/GreekAndCoptic.js * MathJax/jax/output/HTML-CSS/optable/GreekAndCoptic.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/Latin1Supplement.js * MathJax/jax/output/HTML-CSS/optable/Latin1Supplement.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/LetterlikeSymbols.js * MathJax/jax/output/HTML-CSS/optable/LetterlikeSymbols.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/MathOperators.js * MathJax/jax/output/HTML-CSS/optable/MathOperators.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/MiscMathSymbolsA.js * MathJax/jax/output/HTML-CSS/optable/MiscMathSymbolsA.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/MiscMathSymbolsB.js * MathJax/jax/output/HTML-CSS/optable/MiscMathSymbolsB.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/MiscSymbolsAndArrows.js * MathJax/jax/output/HTML-CSS/optable/MiscSymbolsAndArrows.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/MiscTechnical.js * MathJax/jax/output/HTML-CSS/optable/MiscTechnical.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/SpacingModLetters.js * MathJax/jax/output/HTML-CSS/optable/SpacingModLetters.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/SuppMathOperators.js * MathJax/jax/output/HTML-CSS/optable/SuppMathOperators.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/SupplementalArrowsA.js * MathJax/jax/output/HTML-CSS/optable/SupplementalArrowsA.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/optable/SupplementalArrowsB.js * MathJax/jax/output/HTML-CSS/optable/SupplementalArrowsB.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/jax/input/AsciiMath/config.js * MathJax/jax/input/AsciiMath/config.js
@ -10,7 +13,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2012 Design Science, Inc. * Copyright (c) 2012-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,13 +30,15 @@
MathJax.InputJax.AsciiMath = MathJax.InputJax({ MathJax.InputJax.AsciiMath = MathJax.InputJax({
id: "AsciiMath", id: "AsciiMath",
version: "2.0", version: "2.6.0",
directory: MathJax.InputJax.directory + "/AsciiMath", directory: MathJax.InputJax.directory + "/AsciiMath",
extensionDir: MathJax.InputJax.extensionDir + "/AsciiMath", extensionDir: MathJax.InputJax.extensionDir + "/AsciiMath",
config: { config: {
fixphi: true, // switch phi and varphi unicode values
useMathMLspacing: true, // use MathML spacing rather than TeX spacing?
displaystyle: true, // put limits above and below operators displaystyle: true, // put limits above and below operators
decimal: "." // can change to "," but watch out for "(1,2)" decimalsign: "." // can change to "," but watch out for "(1,2)"
} }
}); });
MathJax.InputJax.AsciiMath.Register("math/asciimath"); MathJax.InputJax.AsciiMath.Register("math/asciimath");

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/jax/input/MathML/config.js * MathJax/jax/input/MathML/config.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +27,7 @@
MathJax.InputJax.MathML = MathJax.InputJax({ MathJax.InputJax.MathML = MathJax.InputJax({
id: "MathML", id: "MathML",
version: "2.0", version: "2.6.0",
directory: MathJax.InputJax.directory + "/MathML", directory: MathJax.InputJax.directory + "/MathML",
extensionDir: MathJax.InputJax.extensionDir + "/MathML", extensionDir: MathJax.InputJax.extensionDir + "/MathML",
entityDir: MathJax.InputJax.directory + "/MathML/entities", entityDir: MathJax.InputJax.directory + "/MathML/entities",

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/a.js * MathJax/jax/output/HTML-CSS/entities/a.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/b.js * MathJax/jax/output/HTML-CSS/entities/b.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/c.js * MathJax/jax/output/HTML-CSS/entities/c.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/d.js * MathJax/jax/output/HTML-CSS/entities/d.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/e.js * MathJax/jax/output/HTML-CSS/entities/e.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/f.js * MathJax/jax/output/HTML-CSS/entities/f.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/fr.js * MathJax/jax/output/HTML-CSS/entities/fr.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/g.js * MathJax/jax/output/HTML-CSS/entities/g.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/h.js * MathJax/jax/output/HTML-CSS/entities/h.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/i.js * MathJax/jax/output/HTML-CSS/entities/i.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/j.js * MathJax/jax/output/HTML-CSS/entities/j.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/k.js * MathJax/jax/output/HTML-CSS/entities/k.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/l.js * MathJax/jax/output/HTML-CSS/entities/l.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/m.js * MathJax/jax/output/HTML-CSS/entities/m.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/n.js * MathJax/jax/output/HTML-CSS/entities/n.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/o.js * MathJax/jax/output/HTML-CSS/entities/o.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/opf.js * MathJax/jax/output/HTML-CSS/entities/opf.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/p.js * MathJax/jax/output/HTML-CSS/entities/p.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/q.js * MathJax/jax/output/HTML-CSS/entities/q.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/r.js * MathJax/jax/output/HTML-CSS/entities/r.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/s.js * MathJax/jax/output/HTML-CSS/entities/s.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/scr.js * MathJax/jax/output/HTML-CSS/entities/scr.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/t.js * MathJax/jax/output/HTML-CSS/entities/t.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/u.js * MathJax/jax/output/HTML-CSS/entities/u.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/v.js * MathJax/jax/output/HTML-CSS/entities/v.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/w.js * MathJax/jax/output/HTML-CSS/entities/w.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/x.js * MathJax/jax/output/HTML-CSS/entities/x.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/y.js * MathJax/jax/output/HTML-CSS/entities/y.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -2,7 +2,7 @@
* *
* MathJax/jax/output/HTML-CSS/entities/z.js * MathJax/jax/output/HTML-CSS/entities/z.js
* *
* Copyright (c) 2010 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/jax/input/MathML/jax.js * MathJax/jax/input/MathML/jax.js
@ -8,7 +11,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2010-2012 Design Science, Inc. * Copyright (c) 2010-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,39 +29,43 @@
(function (MATHML,BROWSER) { (function (MATHML,BROWSER) {
var MML; var MML;
var _ = function (id) {
return MathJax.Localization._.apply(MathJax.Localization,
[["MathML",id]].concat([].slice.call(arguments,1)))
};
MATHML.Parse = MathJax.Object.Subclass({ MATHML.Parse = MathJax.Object.Subclass({
Init: function (string) {this.Parse(string)}, Init: function (string,script) {this.Parse(string,script)},
// //
// Parse the MathML and check for errors // Parse the MathML and check for errors
// //
Parse: function (math) { Parse: function (math,script) {
var doc; var doc;
if (typeof math !== "string") {doc = math.parentNode} else { if (typeof math !== "string") {doc = math.parentNode} else {
if (math.match(/^<[a-z]+:/i) && !math.match(/^<[^<>]* xmlns:/)) doc = MATHML.ParseXML(this.preProcessMath.call(this,math));
{math = math.replace(/^<([a-z]+)(:math)/i,'<$1$2 xmlns:$1="http://www.w3.org/1998/Math/MathML"')} if (doc == null) {MATHML.Error(["ErrorParsingMathML","Error parsing 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")}
} }
var err = doc.getElementsByTagName("parsererror")[0]; var err = doc.getElementsByTagName("parsererror")[0];
if (err) MATHML.Error("Error parsing MathML: "+err.textContent.replace(/This page.*?errors:|XML Parsing Error: |Below is a rendering of the page.*/g,"")); if (err) MATHML.Error(["ParsingError","Error parsing MathML: %1",
if (doc.childNodes.length !== 1) MATHML.Error("MathML must be formed by a single element"); err.textContent.replace(/This page.*?errors:|XML Parsing Error: |Below is a rendering of the page.*/g,"")]);
if (doc.childNodes.length !== 1)
{MATHML.Error(["MathMLSingleElement","MathML must be formed by a single element"])}
if (doc.firstChild.nodeName.toLowerCase() === "html") { if (doc.firstChild.nodeName.toLowerCase() === "html") {
var h1 = doc.getElementsByTagName("h1")[0]; var h1 = doc.getElementsByTagName("h1")[0];
if (h1 && h1.textContent === "XML parsing error" && h1.nextSibling) if (h1 && h1.textContent === "XML parsing error" && h1.nextSibling)
MATHML.Error("Error parsing MathML: "+String(h1.nextSibling.nodeValue).replace(/fatal parsing error: /,"")); MATHML.Error(["ParsingError","Error parsing MathML: %1",
String(h1.nextSibling.nodeValue).replace(/fatal parsing error: /,"")]);
} }
if (doc.firstChild.nodeName.toLowerCase().replace(/^[a-z]+:/,"") !== "math") if (doc.firstChild.nodeName.toLowerCase().replace(/^[a-z]+:/,"") !== "math") {
MATHML.Error("MathML must be formed by a <math> element, not <"+doc.firstChild.nodeName+">"); MATHML.Error(["MathMLRootElement",
this.mml = this.MakeMML(doc.firstChild); "MathML must be formed by a <math> element, not %1",
"<"+doc.firstChild.nodeName+">"]);
}
var data = {math:doc.firstChild, script:script};
MATHML.DOMfilterHooks.Execute(data);
this.mml = this.MakeMML(data.math);
}, },
// //
@ -72,11 +79,11 @@
mml = this.TeXAtom(match[2]); mml = this.TeXAtom(match[2]);
} else if (!(MML[type] && MML[type].isa && MML[type].isa(MML.mbase))) { } else if (!(MML[type] && MML[type].isa && MML[type].isa(MML.mbase))) {
MathJax.Hub.signal.Post(["MathML Jax - unknown node type",type]); MathJax.Hub.signal.Post(["MathML Jax - unknown node type",type]);
return MML.merror("Unknown node type: "+type); return MML.Error(_("UnknownNodeType","Unknown node type: %1",type));
} else { } else {
mml = MML[type](); mml = MML[type]();
} }
this.AddAttributes(mml,node); this.CheckClass(mml,CLASS); this.AddAttributes(mml,node); this.CheckClass(mml,mml["class"]);
this.AddChildren(mml,node); this.AddChildren(mml,node);
if (MATHML.config.useMathMLspacing) {mml.useMMLspacing = 0x08} if (MATHML.config.useMathMLspacing) {mml.useMMLspacing = 0x08}
return mml; return mml;
@ -87,11 +94,15 @@
return mml; return mml;
}, },
CheckClass: function (mml,CLASS) { CheckClass: function (mml,CLASS) {
CLASS = CLASS.split(/ /); var NCLASS = []; CLASS = (CLASS||"").split(/ /); var NCLASS = [];
for (var i = 0, m = CLASS.length; i < m; i++) { for (var i = 0, m = CLASS.length; i < m; i++) {
if (CLASS[i].substr(0,4) === "MJX-") { if (CLASS[i].substr(0,4) === "MJX-") {
if (CLASS[i] === "MJX-arrow") { if (CLASS[i] === "MJX-arrow") {
mml.arrow = true; // This class was used in former versions of MathJax to attach an
// arrow to the updiagonalstrike notation. For backward
// compatibility, let's continue to accept this case. See issue 481.
if (!mml.notation.match("/"+MML.NOTATION.UPDIAGONALARROW+"/"))
mml.notation += " "+MML.NOTATION.UPDIAGONALARROW;
} else if (CLASS[i] === "MJX-variant") { } else if (CLASS[i] === "MJX-variant") {
mml.variantForm = true; mml.variantForm = true;
// //
@ -126,14 +137,20 @@
var name = node.attributes[i].name; var name = node.attributes[i].name;
if (name == "xlink:href") {name = "href"} if (name == "xlink:href") {name = "href"}
if (name.match(/:/)) continue; if (name.match(/:/)) continue;
if (name.match(/^_moz-math-((column|row)(align|line)|font-style)$/)) continue;
var value = node.attributes[i].value; var value = node.attributes[i].value;
value = this.filterAttribute(name,value);
var defaults = (mml.type === "mstyle" ? MML.math.prototype.defaults : mml.defaults);
if (value != null) {
if (value.toLowerCase() === "true") {value = true} if (value.toLowerCase() === "true") {value = true}
else if (value.toLowerCase() === "false") {value = false} else if (value.toLowerCase() === "false") {value = false}
if (mml.defaults[name] != null || MML.copyAttributes[name]) if (defaults[name] != null || MML.copyAttributes[name])
{mml[name] = value} else {mml.attr[name] = value} {mml[name] = value} else {mml.attr[name] = value}
mml.attrNames.push(name); mml.attrNames.push(name);
} }
}
}, },
filterAttribute: function (name,value) {return value}, // safe mode overrides this
// //
// Create the children for the mml node // Create the children for the mml node
@ -143,11 +160,16 @@
var child = node.childNodes[i]; var child = node.childNodes[i];
if (child.nodeName === "#comment") continue; if (child.nodeName === "#comment") continue;
if (child.nodeName === "#text") { if (child.nodeName === "#text") {
if (mml.isToken && !mml.mmlSelfClosing) { if ((mml.isToken || mml.isChars) && !mml.mmlSelfClosing) {
var text = child.nodeValue.replace(/&([a-z][a-z0-9]*);/ig,this.replaceEntity); var text = child.nodeValue;
mml.Append(MML.chars(this.trimSpace(text))); if (mml.isToken) {
text = text.replace(/&([a-z][a-z0-9]*);/ig,this.replaceEntity);
text = this.trimSpace(text);
}
mml.Append(MML.chars(text));
} else if (child.nodeValue.match(/\S/)) { } else if (child.nodeValue.match(/\S/)) {
MATHML.Error("Unexpected text node: '"+child.nodeValue+"'"); MATHML.Error(["UnexpectedTextNode",
"Unexpected text node: %1","'"+child.nodeValue+"'"]);
} }
} else if (mml.type === "annotation-xml") { } else if (mml.type === "annotation-xml") {
mml.Append(MML.xml(child)); mml.Append(MML.xml(child));
@ -157,6 +179,35 @@
{mml.Append.apply(mml,cmml.data); cmml.data = []} {mml.Append.apply(mml,cmml.data); cmml.data = []}
} }
} }
if (mml.type === "mrow" && mml.data.length >= 2) {
var first = mml.data[0], last = mml.data[mml.data.length-1];
if (first.type === "mo" && first.Get("fence") &&
last.type === "mo" && last.Get("fence")) {
if (first.data[0]) {mml.open = first.data.join("")}
if (last.data[0]) {mml.close = last.data.join("")}
}
}
},
//
// Clean Up the <math> source to prepare for XML parsing
//
preProcessMath: function (math) {
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);
}
if (math.match(/^<math/i) && !math.match(/^<[^<>]* xmlns=/)) {
// append the MathML namespace
math = math.replace(/^<(math)/i,'<math xmlns="http://www.w3.org/1998/Math/MathML"')
}
math = math.replace(/^\s*(?:\/\/)?<!(--)?\[CDATA\[((.|\n)*)(\/\/)?\]\]\1>\s*$/,"$2");
return math.replace(/&([a-z][a-z0-9]*);/ig,this.replaceEntity);
}, },
// //
@ -192,10 +243,11 @@
/************************************************************************/ /************************************************************************/
MATHML.Augment({ MATHML.Augment({
sourceMenuTitle: "Original MathML", sourceMenuTitle: /*_(MathMenu)*/ ["OriginalMathML","Original MathML"],
prefilterHooks: MathJax.Callback.Hooks(true), // hooks to run before processing MathML prefilterHooks: MathJax.Callback.Hooks(true), // hooks to run on MathML string before processing MathML
postfilterHooks: MathJax.Callback.Hooks(true), // hooks to run after processing MathML DOMfilterHooks: MathJax.Callback.Hooks(true), // hooks to run on MathML DOM before processing
postfilterHooks: MathJax.Callback.Hooks(true), // hooks to run on internal jax format after processing MathML
Translate: function (script) { Translate: function (script) {
if (!this.ParseXML) {this.ParseXML = this.createParser()} if (!this.ParseXML) {this.ParseXML = this.createParser()}
@ -203,29 +255,34 @@
if (script.firstChild && if (script.firstChild &&
script.firstChild.nodeName.toLowerCase().replace(/^[a-z]+:/,"") === "math") { script.firstChild.nodeName.toLowerCase().replace(/^[a-z]+:/,"") === "math") {
data.math = script.firstChild; data.math = script.firstChild;
this.prefilterHooks.Execute(data); math = data.math;
} else { } else {
math = MathJax.HTML.getScript(script); math = MathJax.HTML.getScript(script);
if (BROWSER.isMSIE) {math = math.replace(/(&nbsp;)+$/,"")} if (BROWSER.isMSIE) {math = math.replace(/(&nbsp;)+$/,"")}
data.math = math; this.prefilterHooks.Execute(data); math = data.math; data.math = math;
} }
var callback = this.prefilterHooks.Execute(data); if (callback) return callback;
math = data.math;
try { try {
mml = MATHML.Parse(math).mml; mml = MATHML.Parse(math,script).mml;
} catch(err) { } catch(err) {
if (!err.mathmlError) {throw err} if (!err.mathmlError) {throw err}
mml = this.formatError(err,math,script); mml = this.formatError(err,math,script);
} }
data.math = MML(mml); this.postfilterHooks.Execute(data); data.math = MML(mml);
return data.math; return this.postfilterHooks.Execute(data) || data.math;
}, },
prefilterMath: function (math,script) {return math}, prefilterMath: function (math,script) {return math},
prefilterMathML: function (math,script) {return math}, prefilterMathML: function (math,script) {return math},
formatError: function (err,math,script) { formatError: function (err,math,script) {
var message = err.message.replace(/\n.*/,""); var message = err.message.replace(/\n.*/,"");
MathJax.Hub.signal.Post(["MathML Jax - parse error",message,math,script]); MathJax.Hub.signal.Post(["MathML Jax - parse error",message,math,script]);
return MML.merror(message); return MML.Error(message);
}, },
Error: function (message) { Error: function (message) {
//
// Translate message if it is ["id","message",args]
//
if (message instanceof Array) {message = _.apply(_,message)}
throw MathJax.Hub.Insert(Error(message),{mathmlError: true}); throw MathJax.Hub.Insert(Error(message),{mathmlError: true});
}, },
// //
@ -234,10 +291,25 @@
parseDOM: function (string) {return this.parser.parseFromString(string,"text/xml")}, parseDOM: function (string) {return this.parser.parseFromString(string,"text/xml")},
parseMS: function (string) {return (this.parser.loadXML(string) ? this.parser : null)}, parseMS: function (string) {return (this.parser.loadXML(string) ? this.parser : null)},
parseDIV: function (string) { parseDIV: function (string) {
this.div.innerHTML = string.replace(/<([a-z]+)([^>]*)\/>/g,"<$1$2></$1>"); this.div.innerHTML =
return this.div; "<div>"+string.replace(/<([a-z]+)([^>]*)\/>/g,"<$1$2></$1>")+"</div>";
var doc = this.div.firstChild;
this.div.innerHTML = "";
return doc;
}, },
parseError: function (string) {return null}, parseError: function (string) {return null},
createMSParser: function() {
var parser = null;
var xml = ["MSXML2.DOMDocument.6.0","MSXML2.DOMDocument.5.0",
"MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0",
"MSXML2.DOMDocument.2.0","Microsoft.XMLDOM"];
for (var i = 0, m = xml.length; i < m && !parser; i++) {
try {
parser = new ActiveXObject(xml[i])
} catch (err) {}
}
return parser;
},
// //
// Create the parser using a DOMParser, or other fallback method // Create the parser using a DOMParser, or other fallback method
// //
@ -246,17 +318,9 @@
this.parser = new DOMParser(); this.parser = new DOMParser();
return(this.parseDOM); return(this.parseDOM);
} else if (window.ActiveXObject) { } else if (window.ActiveXObject) {
var xml = ["MSXML2.DOMDocument.6.0","MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0", this.parser = this.createMSParser();
"MSXML2.DOMDocument.3.0","MSXML2.DOMDocument.2.0","Microsoft.XMLDOM"];
for (var i = 0, m = xml.length; i < m && !this.parser; i++)
{try {this.parser = new ActiveXObject(xml[i])} catch (err) {}}
if (!this.parser) { if (!this.parser) {
alert("MathJax can't create an XML parser for MathML. Check that\n"+ MathJax.Localization.Try(this.parserCreationError);
"the 'Script ActiveX controls marked safe for scripting' security\n"+
"setting is enabled (use the Internet Options item in the Tools\n"+
"menu, and select the Security panel, then press the Custom Level\n"+
"button to check this).\n\n"+
"MathML equations will not be able to be processed by MathJax.");
return(this.parseError); return(this.parseError);
} }
this.parser.async = false; this.parser.async = false;
@ -270,6 +334,15 @@
else {document.body.insertBefore(this.div,document.body.firstChild)} else {document.body.insertBefore(this.div,document.body.firstChild)}
return(this.parseDIV); return(this.parseDIV);
}, },
parserCreationError: function () {
alert(_("CantCreateXMLParser",
"MathJax can't create an XML parser for MathML. Check that\n"+
"the 'Script ActiveX controls marked safe for scripting' security\n"+
"setting is enabled (use the Internet Options item in the Tools\n"+
"menu, and select the Security panel, then press the Custom Level\n"+
"button to check this).\n\n"+
"MathML equations will not be able to be processed by MathJax."));
},
// //
// Initialize the parser object (whichever type is used) // Initialize the parser object (whichever type is used)
// //
@ -278,6 +351,8 @@
MML.mspace.Augment({mmlSelfClosing: true}); MML.mspace.Augment({mmlSelfClosing: true});
MML.none.Augment({mmlSelfClosing: true}); MML.none.Augment({mmlSelfClosing: true});
MML.mprescripts.Augment({mmlSelfClosing:true}); MML.mprescripts.Augment({mmlSelfClosing:true});
MML.maligngroup.Augment({mmlSelfClosing:true});
MML.malignmark.Augment({mmlSelfClosing:true});
} }
}); });

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/jax/input/TeX/config.js * MathJax/jax/input/TeX/config.js
@ -7,7 +10,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2009-2012 Design Science, Inc. * Copyright (c) 2009-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +27,7 @@
MathJax.InputJax.TeX = MathJax.InputJax({ MathJax.InputJax.TeX = MathJax.InputJax({
id: "TeX", id: "TeX",
version: "2.0", version: "2.6.0",
directory: MathJax.InputJax.directory + "/TeX", directory: MathJax.InputJax.directory + "/TeX",
extensionDir: MathJax.InputJax.extensionDir + "/TeX", extensionDir: MathJax.InputJax.extensionDir + "/TeX",

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/jax/output/SVG/autoload/annotation-xml.js * MathJax/jax/output/SVG/autoload/annotation-xml.js
@ -6,7 +9,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2012 Design Science, Inc. * Copyright (c) 2013-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +25,7 @@
*/ */
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var VERSION = "2.0"; var VERSION = "2.6.0";
var MML = MathJax.ElementJax.mml, var MML = MathJax.ElementJax.mml,
SVG = MathJax.OutputJax.SVG; SVG = MathJax.OutputJax.SVG;
var BBOX = SVG.BBOX; var BBOX = SVG.BBOX;

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/jax/output/SVG/autoload/maction.js * MathJax/jax/output/SVG/autoload/maction.js
@ -6,7 +9,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +25,7 @@
*/ */
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var VERSION = "2.0"; var VERSION = "2.6.0";
var MML = MathJax.ElementJax.mml, var MML = MathJax.ElementJax.mml,
SVG = MathJax.OutputJax["SVG"]; SVG = MathJax.OutputJax["SVG"];
@ -44,20 +47,22 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
this.SVGgetStyles(); this.SVGgetStyles();
var svg = this.SVG(); var svg = this.SVG();
var selected = this.selected(); var selected = this.selected();
if (selected) { if (selected.type == "null") {this.SVGsaveData(svg);return svg;}
svg.Add(this.SVGdataStretched(this.Get("selection")-1,HW,D)); svg.Add(this.SVGdataStretched(this.Get("selection")-1,HW,D));
svg.removeable = false;
this.SVGhandleHitBox(svg); this.SVGhandleHitBox(svg);
}
this.SVGhandleSpace(svg); this.SVGhandleSpace(svg);
this.SVGhandleColor(svg); this.SVGhandleColor(svg);
this.SVGsaveData(svg); this.SVGsaveData(svg);
return svg; return svg;
}, },
SVGhandleHitBox: function (svg) { SVGhandleHitBox: function (svg) {
var frame = SVG.addElement(svg.element,"rect", var frame = SVG.Element("rect",
{width:svg.w, height:svg.h+svg.d, y:-svg.d, fill:"none", "pointer-events":"all"}); {width:svg.w, height:svg.h+svg.d, y:-svg.d, fill:"none", "pointer-events":"all"});
svg.element.insertBefore(frame,svg.element.firstChild);
var type = this.Get("actiontype"); var type = this.Get("actiontype");
if (this.SVGaction[type]) {this.SVGaction[type].call(this,svg,frame,this.Get("selection"))} if (this.SVGaction[type])
{this.SVGaction[type].call(this,svg,svg.element,this.Get("selection"))}
}, },
SVGstretchH: MML.mbase.prototype.SVGstretchH, SVGstretchH: MML.mbase.prototype.SVGstretchH,
SVGstretchV: MML.mbase.prototype.SVGstretchV, SVGstretchV: MML.mbase.prototype.SVGstretchV,
@ -109,11 +114,14 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
// //
SVGsetStatus: function (event) { SVGsetStatus: function (event) {
// FIXME: Do something better with non-token elements // FIXME: Do something better with non-token elements
window.status = this.messageID = MathJax.Message.Set
((this.data[1] && this.data[1].isToken) ? ((this.data[1] && this.data[1].isToken) ?
this.data[1].data.join("") : this.data[1].toString()); this.data[1].data.join("") : this.data[1].toString());
}, },
SVGclearStatus: function (event) {window.status = ""}, SVGclearStatus: function (event) {
if (this.messageID) {MathJax.Message.Clear(this.messageID,0)}
delete this.messageID;
},
// //
// Handle tooltips // Handle tooltips
@ -154,7 +162,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var math = this; while (math.type !== "math") {math = math.inherit} var math = this; while (math.type !== "math") {math = math.inherit}
var jax = MathJax.Hub.getJaxFor(math.inputID); var jax = MathJax.Hub.getJaxFor(math.inputID);
this.em = MML.mbase.prototype.em = jax.SVG.em; this.ex = jax.SVG.ex; this.em = MML.mbase.prototype.em = jax.SVG.em; this.ex = jax.SVG.ex;
this.linebreakWidth = jax.SVG.lineWidth * 1000; this.cwidth = jax.SVG.cwidth; this.linebreakWidth = jax.SVG.lineWidth; this.cwidth = jax.SVG.cwidth;
// //
// Make a new math element and temporarily move the tooltip to it // Make a new math element and temporarily move the tooltip to it

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/jax/output/SVG/autoload/menclose.js * MathJax/jax/output/SVG/autoload/menclose.js
@ -6,7 +9,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +25,7 @@
*/ */
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var VERSION = "2.0"; var VERSION = "2.6.0";
var MML = MathJax.ElementJax.mml, var MML = MathJax.ElementJax.mml,
SVG = MathJax.OutputJax.SVG, SVG = MathJax.OutputJax.SVG,
BBOX = SVG.BBOX; BBOX = SVG.BBOX;
@ -96,7 +99,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
toSVG: function (HW,DD) { toSVG: function (HW,DD) {
this.SVGgetStyles(); this.SVGgetStyles();
var svg = this.SVG(); var svg = this.SVG(), scale = this.SVGgetScale(svg);
this.SVGhandleSpace(svg); this.SVGhandleSpace(svg);
var base = this.SVGdataStretched(0,HW,DD); var base = this.SVGdataStretched(0,HW,DD);
@ -104,16 +107,22 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
if (values.color && !this.mathcolor) {values.mathcolor = values.color} if (values.color && !this.mathcolor) {values.mathcolor = values.color}
if (values.thickness == null) {values.thickness = ".075em"} if (values.thickness == null) {values.thickness = ".075em"}
if (values.padding == null) {values.padding = ".2em"} if (values.padding == null) {values.padding = ".2em"}
var mu = this.SVGgetMu(svg), scale = this.SVGgetScale(); var mu = this.SVGgetMu(svg);
var p = SVG.length2em(values.padding,mu,1/SVG.em) * scale; var p = SVG.length2em(values.padding,mu,1/SVG.em) * scale; // padding for enclosure
var t = SVG.length2em(values.thickness,mu,1/SVG.em) * scale; var t = SVG.length2em(values.thickness,mu,1/SVG.em); // thickness of lines
t = Math.max(1/SVG.em,t); // see issue #414
var H = base.h+p+t, D = base.d+p+t, W = base.w+2*(p+t); var H = base.h+p+t, D = base.d+p+t, W = base.w+2*(p+t);
var notation = values.notation.split(/ /);
var dx = 0, w, h, i, m, borders = [false,false,false,false]; var dx = 0, w, h, i, m, borders = [false,false,false,false];
if (!values.mathcolor) {values.mathcolor = "black"} if (!values.mathcolor) {values.mathcolor = "black"}
for (i = 0, m = notation.length; i < m; i++) { // perform some reduction e.g. eliminate duplicate notations.
switch (notation[i]) { var nl = MathJax.Hub.SplitList(values.notation), notation = {};
for (i = 0, m = nl.length; i < m; i++) notation[nl[i]] = true;
if (notation[MML.NOTATION.UPDIAGONALARROW]) notation[MML.NOTATION.UPDIAGONALSTRIKE] = false;
for (var n in notation) {
if (!notation.hasOwnProperty(n) || !notation[n]) continue;
switch (n) {
case MML.NOTATION.BOX: case MML.NOTATION.BOX:
borders = [true,true,true,true]; borders = [true,true,true,true];
break; break;
@ -154,22 +163,27 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
break; break;
case MML.NOTATION.UPDIAGONALSTRIKE: case MML.NOTATION.UPDIAGONALSTRIKE:
if (this.arrow) { svg.Add(BBOX.DLINE(H,D,W,t,values.mathcolor,"up"));
break;
case MML.NOTATION.UPDIAGONALARROW:
var l = Math.sqrt(W*W + (H+D)*(H+D)), f = 1/l * 10/SVG.em * t/.075; var l = Math.sqrt(W*W + (H+D)*(H+D)), f = 1/l * 10/SVG.em * t/.075;
w = W * f; h = (H+D) * f; var x = .4*h; w = W * f; h = (H+D) * f; var x = .4*h;
svg.Add(BBOX.DLINE(H-.5*h,D,W-.5*w,t,values.mathcolor,"up")); svg.Add(BBOX.DLINE(H-.5*h,D,W-.5*w,t,values.mathcolor,"up"));
svg.Add(BBOX.FPOLY( svg.Add(BBOX.FPOLY(
[[x+w,h], [x-.4*h,.4*w], [x+.3*w,.3*h], [x+.4*h,-.4*w], [x+w,h]], [[x+w,h], [x-.4*h,.4*w], [x+.3*w,.3*h], [x+.4*h,-.4*w], [x+w,h]],
values.mathcolor),W-w-x,H-h); values.mathcolor),W-w-x,H-h);
} else {
svg.Add(BBOX.DLINE(H,D,W,t,values.mathcolor,"up"));
}
break; break;
case MML.NOTATION.DOWNDIAGONALSTRIKE: case MML.NOTATION.DOWNDIAGONALSTRIKE:
svg.Add(BBOX.DLINE(H,D,W,t,values.mathcolor,"down")); svg.Add(BBOX.DLINE(H,D,W,t,values.mathcolor,"down"));
break; break;
case MML.NOTATION.PHASORANGLE:
borders[2] = true; W -= 2*p; p = (H+D)/2; W += p;
svg.Add(BBOX.DLINE(H,D,p,t,values.mathcolor,"up"));
break;
case MML.NOTATION.MADRUWB: case MML.NOTATION.MADRUWB:
borders[1] = borders[2] = true; borders[1] = borders[2] = true;
break; break;

View File

@ -1,3 +1,6 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/************************************************************* /*************************************************************
* *
* MathJax/jax/output/SVG/autoload/mglyph.js * MathJax/jax/output/SVG/autoload/mglyph.js
@ -6,7 +9,7 @@
* *
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
* *
* Copyright (c) 2011-2012 Design Science, Inc. * Copyright (c) 2011-2015 The MathJax Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,10 +25,11 @@
*/ */
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var VERSION = "2.0"; var VERSION = "2.6.0";
var MML = MathJax.ElementJax.mml, var MML = MathJax.ElementJax.mml,
SVG = MathJax.OutputJax.SVG, SVG = MathJax.OutputJax.SVG,
BBOX = SVG.BBOX; BBOX = SVG.BBOX,
LOCALE = MathJax.Localization;
var XLINKNS = "http://www.w3.org/1999/xlink"; var XLINKNS = "http://www.w3.org/1999/xlink";
@ -33,9 +37,10 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
type: "image", removeable: false, type: "image", removeable: false,
Init: function (img,w,h,align,mu,def) { Init: function (img,w,h,align,mu,def) {
if (def == null) {def = {}} if (def == null) {def = {}}
var W = img.width*1000/SVG.em, H = img.height*1000/SVG.em, y = 0; var W = img.width*1000/SVG.em, H = img.height*1000/SVG.em;
if (w !== "") {W = SVG.length2em(w,mu,W)} var WW = W, HH = H, y = 0;
if (h !== "") {H = SVG.length2em(h,mu,H)} if (w !== "") {W = SVG.length2em(w,mu,WW); H = (WW ? W/WW * HH : 0)}
if (h !== "") {H = SVG.length2em(h,mu,HH); if (w === "") {W = (HH ? H/HH * WW : 0)}}
if (align !== "" && align.match(/\d/)) {y = SVG.length2em(align,mu); def.y = -y} if (align !== "" && align.match(/\d/)) {y = SVG.length2em(align,mu); def.y = -y}
def.height = Math.floor(H); def.width = Math.floor(W); def.height = Math.floor(H); def.width = Math.floor(W);
def.transform = "translate(0,"+H+") matrix(1 0 0 -1 0 0)"; def.transform = "translate(0,"+H+") matrix(1 0 0 -1 0 0)";
@ -70,7 +75,9 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
MathJax.Hub.RestartAfter(img.onload); MathJax.Hub.RestartAfter(img.onload);
} }
if (this.img.status !== "OK") { if (this.img.status !== "OK") {
err = MML.merror("Bad mglyph: "+values.src).With({mathsize:"75%"}); err = MML.Error(
LOCALE._(["MathML","BadMglyph"],"Bad mglyph: %1",values.src),
{mathsize:"75%"});
this.Append(err); svg = err.toSVG(); this.data.pop(); this.Append(err); svg = err.toSVG(); this.data.pop();
} else { } else {
var mu = this.SVGgetMu(svg); var mu = this.SVGgetMu(svg);

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