lib/gollum/frontend/public/javascript/MathJax/extensions/toMathML.js in gollum-1.1.1 vs lib/gollum/frontend/public/javascript/MathJax/extensions/toMathML.js in gollum-1.2.0

- old
+ new

@@ -1,140 +1,18 @@ -/************************************************************* - * - * MathJax/extensions/toMathML.js +/* + * ../SourceForge/trunk/mathjax/extensions/toMathML.js * - * Implements a toMathML() method for the mml Element Jax that returns - * a MathML string from a given math expression. - * - * --------------------------------------------------------------------- - * * Copyright (c) 2010 Design Science, Inc. + * + * Part of the MathJax library. + * See http://www.mathjax.org for details. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0; * 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.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () { - var MML = MathJax.ElementJax.mml; - - MML.mbase.Augment({ +MathJax.Unpack([ + ['MathJax.Hub.Register.','LoadHook("[','MathJax',']/jax/element/mml/jax.js",','function(){','var b="1.0";var a=',2,'.ElementJax.mml;a.mbase','.Augment({toMathML:function(','k){var g=(this.inferred&&this.parent.inferRow);if(k==null){k=""}var e','=this.','type,d',10,'MathMLattributes','();if(e==="mspace"){','return k+"<"+e+d','+" />"}','var j=[];var h=(','this.isToken','?"":k+(g?"":" "));for(var f=0,c',10,'data.length;f<c;f++){if(','this.data[','f]){j.push(',22,'f].toMathML(h))}else{if(!',18,'){j.push(','h+"<mrow />")}}}if(',18,'){',15,'+">"+j.join("")+"</"+e+">"}if(g){return j.join("\\n")}if(j.length===0||(j.length===1&&j[0]==="")){',15,16,15,'+">\\n"+j.join("\\n")+"\\n"+k+"</"+e+">"},',13,':',4,'var j=[],g',10,'defaults;var c',10,'copyAttributes',',l',10,'skipAttributes',';','if(this.type==="','math"){j.push(\'xmlns="http://www.w3.org/1998/Math/MathML"\')}',49,'mstyle"){g=a.math.prototype.defaults}for(var d in g){if(!l[d]&&g.hasOwnProperty(d)){var e=(d==="open"||d==="close");if(this[d]!=null&&(e||this[d]!==g[d])){var k=this[d];delete this[d];if(e||this.Get(d)!==k',27,'d+\'="\'+','this.quoteHTML(','k)+\'"\')}this[d]=k}}}for(var h=0,f=c.length;h<f;h++){if(this[c[h]]!=null',27,'c[h]+\'="\'+',55,'this[c[h]])+\'"\')}}if(j.length){return" "+j.join(" ")}else{return""}},',44,':["fontfamily","fontsize","fontweight","fontstyle","color","background","id","class","href","style"],',47,':{texClass:1,useHeight:1,texprimestyle:1},quoteHTML:function(e){e=String(e).split("");for(var f=0,d=e.length;f<d;f++){var h=e[f].charCodeAt(0);if(h<32||h>126){e[f]="&#x"+h.toString(16).toUpperCase()+";"}else{var g={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;"}[e[f]];if(g){e[f]=g}}}return e.join("")}});a.msubsup',8,'h){var e=this.type;if(this.data[this.','sup',']==null){e="','msub"}if(',22,'this.sub',68,'msup','"}var d=this.MathMLattributes();delete this.data[0].inferred;var g=[];for(var f=0,c=this.data.length;f<c;f++){if(this.data[f]){g.push(this.data[f].toMathML(h+" "))}}return h+"<"+e+d+">\\n"+g.join("\\n")+"\\n"+h+"</"+e+">"}});a.','munderover',8,66,'under',68,'mover"}if(',22,'this.over',68,'munder',74,'TeXAtom',8,'c){return',' c+"<mrow>\\n"+',22,'0].toMathML(c+" ")+"\\n"+c+"</mrow>"}});a.chars',8,88,'(c||"")+',55,'this.toString','())}});a.entity',8,88,'(c||"")+"&"+',22,'0]+";<!-- "+',96,'()+" -->"}});',0,'StartupHook("TeX mathchoice Ready",',4,'a.TeXmathchoice',8,88,' this.Core().toMathML(c)}})});',2,'.Hub.Startup.signal.Post("toMathML Ready")});',2,'.Ajax.loadComplete("[',2,']/extensions/toMathML.js");'] +]); - toMathML: function (space) { - var inferred = (this.inferred && this.parent.inferRow); - if (space == null) {space = ""} - var tag = this.type, attr = this.MathMLattributes(); - if (tag === "mspace") {return space + "<"+tag+attr+" />"} - var data = []; var SPACE = (this.isToken ? "" : space+(inferred ? "" : " ")); - for (var i = 0, m = this.data.length; i < m; i++) { - if (this.data[i]) {data.push(this.data[i].toMathML(SPACE))} - else if (!this.isToken) {data.push(SPACE+"<mrow />")} - } - if (this.isToken) {return space + "<"+tag+attr+">"+data.join("")+"</"+tag+">"} - if (inferred) {return data.join("\n")} - if (data.length === 0 || (data.length === 1 && data[0] === "")) - {return space + "<"+tag+attr+" />"} - return space + "<"+tag+attr+">\n"+data.join("\n")+"\n"+ space +"</"+tag+">"; - }, - - MathMLattributes: function () { - var attr = [], defaults = this.defaults; - var copy = this.copyAttributes, - skip = this.skipAttributes; - - if (this.type === "mstyle") {defaults = MML.math.prototype.defaults} - for (var id in defaults) {if (!skip[id] && defaults.hasOwnProperty(id)) { - var force = (id === "open" || id === "close"); - if (this[id] != null && (force || this[id] !== defaults[id])) { - var value = this[id]; delete this[id]; - if (force || this.Get(id) !== value) - {attr.push(id+'="'+this.quoteHTML(value)+'"')} - this[id] = value; - } - }} - for (var i = 0, m = copy.length; i < m; i++) { - if (this[copy[i]] != null) {attr.push(copy[i]+'="'+this.quoteHTML(this[copy[i]])+'"')} - } - if (attr.length) {return " "+attr.join(" ")} else {return ""} - }, - copyAttributes: [ - "fontfamily","fontsize","fontweight","fontstyle", - "color","background", - "id","class","href","style" - ], - skipAttributes: {texClass: 1, useHeight: 1, texprimestyle: 1}, - - quoteHTML: function (string) { - string = String(string).split(""); - for (var i = 0, m = string.length; i < m; i++) { - var n = string[i].charCodeAt(0); - if (n < 0x20 || n > 0x7E) { - string[i] = "&#x"+n.toString(16).toUpperCase()+";"; - } else { - var c = {'&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;'}[string[i]]; - if (c) {string[i] = c} - } - } - return string.join(""); - } - }); - - MML.msubsup.Augment({ - toMathML: function (space) { - var tag = this.type; - if (this.data[this.sup] == null) {tag = "msub"} - if (this.data[this.sub] == null) {tag = "msup"} - var attr = this.MathMLattributes(); - delete this.data[0].inferred; - var data = []; - for (var i = 0, m = this.data.length; i < m; i++) - {if (this.data[i]) {data.push(this.data[i].toMathML(space+" "))}} - return space + "<"+tag+attr+">\n" + data.join("\n") + "\n" + space + "</"+tag+">"; - } - }); - - MML.munderover.Augment({ - toMathML: function (space) { - var tag = this.type; - if (this.data[this.under] == null) {tag = "mover"} - if (this.data[this.over] == null) {tag = "munder"} - var attr = this.MathMLattributes(); - delete this.data[0].inferred; - var data = []; - for (var i = 0, m = this.data.length; i < m; i++) - {if (this.data[i]) {data.push(this.data[i].toMathML(space+" "))}} - return space + "<"+tag+attr+">\n" + data.join("\n") + "\n" + space + "</"+tag+">"; - } - }); - - MML.TeXAtom.Augment({ - toMathML: function (space) { - // FIXME: Handle spacing using mpadded? - return space+"<mrow>\n"+this.data[0].toMathML(space+" ")+"\n"+space+"</mrow>"; - } - }); - - MML.chars.Augment({ - toMathML: function (space) {return (space||"") + this.quoteHTML(this.toString())} - }); - - MML.entity.Augment({ - toMathML: function (space) {return (space||"") + "&"+this.data[0]+";<!-- "+this.toString()+" -->"} - }); - - MathJax.Hub.Register.StartupHook("TeX mathchoice Ready",function () { - MML.TeXmathchoice.Augment({ - toMathML: function (space) {return this.Core().toMathML(space)} - }); - }); - -}); - -MathJax.Ajax.loadComplete("[MathJax]/extensions/toMathML.js");