// This script was automatically generated from a literate source. // Do not edit this file; look at the literate source instead! // // Greasemonkey user script to // Display LaTeX in Web pages by transforming to MathML // -------------------------------------------------------------------- // Original script by // Copyright (C) 2006 Steve Cheng // Home page: http://gold-saucer.afraid.org/mathml/greasemonkey/ // // Modified by // Copyright (C) 2010 Valery Alexeev // Version 1.15, May 7, 2010 // as follows: // // Added arxiv.org, front.math.ucdavis.edu, *mathscinet*, mail.google.com // Changed char_map to fix the display for \mathcal, \mathbb, \mathfrak // Fixed the displayed formulas with $$...$$ and \[...\] // Added \scr, \germ, \roman, etc used by Mathscinet. // Added miscellaneous symbols and arrows // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALNGS IN THE SOFTWARE. function latex2mml() { function GM_log() {} // First, find out where we are var va_loc = window.location.href; var va_view = 'web'; //alert( 'va_view=' + va_view ); // The script itself begins const mmlns = 'http://www.w3.org/1998/Math/MathML'; /* // VA: Fix displayed equations first. if( va_view == 'web' ){ document.body.innerHTML= document.body.innerHTML.replace(/\n/g," "); // remove end-of-lines document.body.innerHTML= document.body.innerHTML.replace(/(\$\$|\\\[)([^$]+)(\$\$|\\\])/g, "

\$ $2 \$

"); // VA: Experimental: may lead to slow down. \spcheck is used on MathSciNet // document.body.innerHTML= // document.body.innerHTML.replace(/\\spcheck/g,"^{\\vee}"); } */ function result_element(tag, num_attrs) { var node = document.createElementNS(mmlns, tag); var k = 2; while(--num_attrs >= 0) { if(arguments[k+1] != null) { node.setAttribute(arguments[k], arguments[k+1]); } k += 2; } for(; k < arguments.length; k++) { if(arguments[k] != null) { if(typeof(arguments[k]) == 'string') node.appendChild(document.createTextNode(arguments[k])); else node.appendChild(arguments[k]); } } return node; } function result_element_append(parent, child) { if(parent != null && child != null) { if(typeof(child) == 'string') parent.appendChild(document.createTextNode(child)); else parent.appendChild(child); } } function result_element_prepend(parent, child, next) { if(next == null) result_element_append(parent, child); else if (parent != null && child != null) parent.insertBefore(child, next); } function result_set_attr(elem, attr, value) { if(elem != null && attr != null) { if(value != null) elem.setAttribute(attr, value); else elem.removeAttribute(attr); } } function result_append_attr(elem, attr, value) { if(elem != null && attr != null) { var old_value = elem.getAttribute(elem, attr); if(old_value == null) elem.setAttribute(attr, value); else elem.setAttribute(attr, old_value + value); } } /* if( va_view == 'web' ){ if(!this.GM_getValue) { this.GM_getValue = function(key, value) { return value; } this.GM_log = function() {} } if(this.GM_registerMenuCommand) { GM_registerMenuCommand("Enable native display of math images", function() { GM_setValue("patch-images", true); do_patch_images = true; patch_element(document.documentElement); }); GM_registerMenuCommand("Disable native display of math images", function() { GM_setValue("patch-images", false); }); } } */ // VA: changed char_map const char_map = { 'script': [ '\uD835\uDC9C', '\u212C', '\uD835\uDC9E', //abc '\uD835\uDC9F', '\u2130', '\u2131', //def '\uD835\uDCA2', '\u210B', '\u2110', //ghi '\uD835\uDCA5', '\uD835\uDCA6', '\u2112', //jkl '\u2133', '\uD835\uDCA9', '\uD835\uDCAA', //mno '\uD835\uDCAB', '\uD835\uDCAC', '\u211B', //pqr '\uD835\uDCAE', '\uD835\uDCAF', '\uD835\uDCB0', //stu '\uD835\uDCB1', '\uD835\uDCB2', '\uD835\uDCB3', //vwx '\uD835\uDCB4', '\uD835\uDCB5' ], //yz 'fraktur': [ '\uD835\uDD04', '\uD835\uDD05', '\u212D', //abc '\uD835\uDD07', '\uD835\uDD08', '\uD835\uDD09', //def '\uD835\uDD0A', '\u210C', '\u2111', //ghi '\uD835\uDD0D', '\uD835\uDD0E', '\uD835\uDD0F', //jkl '\uD835\uDD10', '\uD835\uDD11', '\uD835\uDD12', //mno '\uD835\uDD13', '\uD835\uDD14', '\u211C', //pqr '\uD835\uDD16', '\uD835\uDD17', '\uD835\uDD18', //stu '\uD835\uDD19', '\uD835\uDD1A', '\uD835\uDD1B', //vwx '\uD835\uDD1C', '\u2128' ], //yz 'double-struck': [ '\uD835\uDD38', '\uD835\uDD39', '\u2102', //abc '\uD835\uDD3B', '\uD835\uDD3C', '\uD835\uDD3D', //def '\uD835\uDD3E', '\u210D', '\uD835\uDD40', //ghi '\uD835\uDD41', '\uD835\uDD42', '\uD835\uDD43', //jkl '\uD835\uDD44', '\u2115', '\uD835\uDD46', //mno '\u2119', '\u211A', '\u211D', //pqr '\uD835\uDD4A', '\uD835\uDD4B', '\uD835\uDD4C', //stu '\uD835\uDD4D', '\uD835\uDD4E', '\uD835\uDD4F', //vwx '\uD835\uDD50', '\u2124', ], //yz }; const uppercase_re = /[A-Z]/; function fix_mathvariant(node, style) { if(node.nodeType == node.TEXT_NODE) { if(style != null && style != '' && style in char_map) { node.data = node.data.replace(uppercase_re, function(s) {return char_map[style][s.charCodeAt(0)-65]}); } } else if(node.nodeType == node.ELEMENT_NODE) { var new_style = node.getAttribute('mathvariant'); if(new_style != null && new_style != '') style = new_style; for(var i=0; i < node.childNodes.length; i++) fix_mathvariant(node.childNodes.item(i), style); } } var g_punct_and_space = {"\\quad" : "\u2003" , "\\qquad" : "\u2003\u2003" , "\\thickspace" : "\u2002" , "\\;" : "\u2002" , "\\medspace" : "\u2005" , "\\:" : "\u2005" , "\\thinspace" : "\u2004" , "\\," : "\u2004" , "\\!" : "\u200b" , "." : "." , ";" : ";" , "?" : "?" , "\\qedsymbol" : "\u25a0" , } ; var g_left_delimiters = {"(" : "(" , "[" : "[" , "\\{" : "{" , "\\lgroup" : "(" , "\\lbrace" : "{" , "\\lvert" : "|" , "\\lVert" : "\u2016" , "\\lceil" : "\u2308" , "\\lfloor" : "\u230a" , "\\lmoustache" : "\u23b0" , "\\langle" : "\u2329" , } ; var g_right_delimiters = {")" : ")" , "]" : "]" , "\\}" : "}" , "\\rbrace" : "}" , "\\rgroup" : ")" , "\\rvert" : "|" , "\\rVert" : "\u2016" , "\\rceil" : "\u2309" , "\\rfloor" : "\u230b" , "\\rmoustache" : "\u23b1" , "\\rangle" : "\u232a" , } ; var g_operator_symbols = {"\\amalg" : "\u2a3f" , "\\ast" : "*" , "\\ast" : "\u2217" , "\\barwedge" : "\u22bc" , "\\barwedge" : "\u2305" , "\\bigcirc" : "\u25cb" , "\\bigtriangledown" : "\u25bd" , "\\bigtriangleup" : "\u25b3" , "\\boxdot" : "\u22a1" , "\\boxminus" : "\u229f" , "\\boxplus" : "\u229e" , "\\boxtimes" : "\u22a0" , "\\bullet" : "\u2022" , "\\bullet" : "\u2219" , "\\cap" : "\u2229" , "\\Cap" : "\u22d2" , "\\cdot" : "\u22c5" , "\\centerdot" : "\u00b7" , "\\circ" : "\u2218" , "\\circledast" : "\u229b" , "\\circledcirc" : "\u229a" , "\\circleddash" : "\u229d" , "\\cup" : "\u222a" , "\\Cup" : "\u22d3" , "\\curlyvee" : "\u22ce" , "\\curlywedge" : "\u22cf" , "\\dagger" : "\u2020" , "\\ddagger" : "\u2021" , "\\diamond" : "\u22c4" , "\\div" : "\u00f7" , "\\divideontimes" : "\u22c7" , "\\dotplus" : "\u2214" , "\\doublebarwedge" : "\u2306" , "\\doublecap" : "\u22d2" , "\\doublecup" : "\u22d3" , "\\gtrdot" : "\u22d7" , "\\intercal" : "\u22ba" , "\\land" : "\u2227" , "\\leftthreetimes" : "\u22cb" , "\\lessdot" : "\u22d6" , "\\lor" : "\u2228" , "\\ltimes" : "\u22c9" , "\\mp" : "\u2213" , "\\odot" : "\u2299" , "\\ominus" : "\u2296" , "\\oplus" : "\u2295" , "\\oslash" : "\u2298" , "\\otimes" : "\u2297" , "\\pm" : "\u00b1" , "\\rightthreetimes" : "\u22cc" , "\\rtimes" : "\u22ca" , "\\setminus" : "\u2216" , "\\smallsetminus" : "\u2216" , "\\sqcap" : "\u2293" , "\\sqcup" : "\u2294" , "\\star" : "\u22c6" , "\\times" : "\u00d7" , "\\triangleleft" : "\u25c1" , "\\triangleright" : "\u25b7" , "\\uplus" : "\u228e" , "\\vee" : "\u2228" , "\\spcheck" : "\u207a" , // has to be ^{\vee} instead but that's hard // to code //"\\spcheck" : "\u002a" , "\\veebar" : "\u22bb" , "\\veebar" : "\u2a61" , "\\wedge" : "\u2227" , "\\wr" : "\u2240" , "+" : "+" , "-" : "\u2212" , "*" : "*" , "," : "," , "/" : "\u2215" , ":" : ":" , "\\colon" : ":" , "|" : "|" , "\\vert" : "|" , "\\Vert" : "\u2016" , "\\|" : "\u2016" , "\\backslash" : "\\" , "'" : "\u2032" , "\\#" : "#" , "\\bmod" : "mod" , "\\mod" : "mod" , "\\downarrow" : "\u2193" , "\\Downarrow" : "\u21d3" , "\\uparrow" : "\u2191" , "\\Uparrow" : "\u21d1" , "\\updownarrow" : "\u2195" , "\\Updownarrow" : "\u21d5" , "\\bigcap" : "\u22c2" , "\\bigcup" : "\u22c3" , "\\bigodot" : "\u2a00" , "\\bigoplus" : "\u2a01" , "\\bigotimes" : "\u2a02" , "\\bigsqcup" : "\u2a06" , "\\biguplus" : "\u2a04" , "\\bigvee" : "\u22c1" , "\\bigwedge" : "\u22c0" , "\\coprod" : "\u2210" , "\\prod" : "\u220f" , "\\sum" : "\u2211" , "\\int" : "\u222b" , "\\smallint" : "\u222b" , "\\oint" : "\u222e" , "\\angle" : "\u2220" , "\\backprime" : "\u2035" , "\\bigstar" : "\u2605" , "\\blacklozenge" : "\u29eb" , "\\blacksquare" : "\u25a0" , "\\blacktriangle" : "\u25b4" , "\\blacktriangledown" : "\u25be" , "\\bot" : "\u22a5" , "\\clubsuit" : "\u2663" , "\\diagdown" : "\u2572" , "\\diagup" : "\u2571" , "\\diamondsuit" : "\u2662" , "\\emptyset" : "\u2205" , "\\exists" : "\u2203" , "\\flat" : "\u266d" , "\\forall" : "\u2200" , "\\heartsuit" : "\u2661" , "\\infty" : "\u221e" , "\\lnot" : "\u00ac" , "\\lozenge" : "\u25ca" , "\\measuredangle" : "\u2221" , "\\nabla" : "\u2207" , "\\natural" : "\u266e" , "\\neg" : "\u00ac" , "\\nexists" : "\u2204" , "\\prime" : "\u2032" , "\\sharp" : "\u266f" , "\\spadesuit" : "\u2660" , "\\sphericalangle" : "\u2222" , "\\square" : "\u25a1" , "\\surd" : "\u221a" , "\\top" : "\u22a4" , "\\triangle" : "\u25b5" , "\\triangledown" : "\u25bf" , "\\varnothing" : "\u2205" , "\\aleph" : "\u2135" , "\\Bbbk" : "\u1d55C" , "\\beth" : "\u2136" , "\\circledS" : "\u24c8" , "\\complement" : "\u2201" , "\\daleth" : "\u2138" , "\\ell" : "\u2113" , "\\eth" : "\u00f0" , "\\Finv" : "\u2132" , "\\Game" : "\u2141" , "\\gimel" : "\u2137" , "\\hbar" : "\u210f" , "\\hslash" : "\u210f" , "\\Im" : "\u2111" , "\\mho" : "\u2127" , "\\partial" : "\u2202" , "\\Re" : "\u211c" , "\\wp" : "\u2118" , } ; var g_relation_symbols = {"=" : "=" , "<" : "<" , ">" : ">" , "\\approx" : "\u2248" , "\\approxeq" : "\u224a" , "\\asymp" : "\u2248" , "\\backsim" : "\u223d" , "\\backsimeq" : "\u22cd" , "\\bumpeq" : "\u224f" , "\\Bumpeq" : "\u224e" , "\\circeq" : "\u2257" , "\\cong" : "\u2245" , "\\curlyeqprec" : "\u22de" , "\\curlyeqsucc" : "\u22df" , "\\doteq" : "\u2250" , "\\doteqdot" : "\u2251" , "\\eqcirc" : "\u2256" , "\\eqsim" : "\u2242" , "\\eqslantgtr" : "\u2a96" , "\\eqslantless" : "\u2a95" , "\\equiv" : "\u2261" , "\\fallingdotseq" : "\u2252" , "\\ge" : "\u2265" , "\\geq" : "\u2265" , "\\geqq" : "\u2267" , "\\geqslant" : "\u2a7e" , "\\gg" : "\u226b" , "\\gg" : "\u2aa2" , "\\ggg" : "\u22d9" , "\\gggtr" : "\u22d9" , "\\gnapprox" : "\u2a8a" , "\\gneq" : "\u2a88" , "\\gneqq" : "\u2269" , "\\gnsim" : "\u22e7" , "\\gtrapprox" : "\u2a86" , "\\gtreqless" : "\u22db" , "\\gtreqqless" : "\u2a8c" , "\\gtrless" : "\u2277" , "\\gtrsim" : "\u2273" , "\\gvertneqq" : "\u2269" , "\\le" : "\u2264" , "\\leq" : "\u2264" , "\\leqq" : "\u2266" , "\\leqslant" : "\u2a7d" , "\\lessapprox" : "\u2a85" , "\\lesseqgtr" : "\u22da" , "\\lesseqqgtr" : "\u2a8b" , "\\lessgtr" : "\u2276" , "\\lesssim" : "\u2272" , "\\ll" : "\u226a" , "\\llless" : "\u22d8" , "\\lnapprox" : "\u2a89" , "\\lneq" : "\u2a87" , "\\lneqq" : "\u2268" , "\\lnsim" : "\u22e6" , "\\lvertneqq" : "\u2268" , "\\ncong" : "\u2247" , "\\ne" : "\u2260" , "\\neq" : "\u2260" , "\\ngeq" : "\u2271" , "\\ngeqq" : "\u2267" , "\\ngeqslant" : "\u2a7e" , "\\ngtr" : "\u226f" , "\\nleq" : "\u2270" , "\\nleqq" : "\u2266" , "\\nleqslant" : "\u2a7d" , "\\nless" : "\u226e" , "\\nprec" : "\u2280" , "\\npreceq" : "\u2aaf" , "\\nsim" : "\u2241" , "\\nsucc" : "\u2281" , "\\nsucceq" : "\u2ab0" , "\\prec" : "\u227a" , "\\precapprox" : "\u2ab7" , "\\preccurlyeq" : "\u227c" , "\\preceq" : "\u2aaf" , "\\precnapprox" : "\u2ab9" , "\\precneqq" : "\u2ab5" , "\\precnsim" : "\u22e8" , "\\precsim" : "\u227e" , "\\risingdotseq" : "\u2253" , "\\sim" : "\u223c" , "\\simeq" : "\u2243" , "\\succ" : "\u227b" , "\\succapprox" : "\u2ab8" , "\\succcurlyeq" : "\u227d" , "\\succeq" : "\u2ab0" , "\\succnapprox" : "\u2aba" , "\\succneqq" : "\u2ab6" , "\\succnsim" : "\u22e9" , "\\succsim" : "\u227f" , "\\thickapprox" : "\u2248" , "\\thicksim" : "\u223c" , "\\triangleq" : "\u225c" , "\\longrightarrow" : "\u27F6" , "\\curvearrowleft" : "\u21b6" , "\\curvearrowright" : "\u21b7" , "\\downdownarrows" : "\u21ca" , "\\downharpoonleft" : "\u21c3" , "\\downharpoonright" : "\u21c2" , "\\gets" : "\u2190" , "\\hookleftarrow" : "\u21a9" , "\\hookrightarrow" : "\u21aa" , "\\leftarrow" : "\u2190" , "\\Leftarrow" : "\u21d0" , "\\leftarrowtail" : "\u21a2" , "\\leftharpoondown" : "\u21bd" , "\\leftharpoonup" : "\u21bc" , "\\leftleftarrows" : "\u21c7" , "\\leftrightarrow" : "\u2194" , "\\leftrightarrows" : "\u21c6" , "\\leftrightharpoons" : "\u21cb" , "\\leftrightsquigarrow" : "\u21ad" , "\\Lleftarrow" : "\u21da" , "\\longleftarrow" : "\u27f5" , "\\Longleftarrow" : "\u27f8" , "\\longleftrightarrow" : "\u27f7" , "\\Longleftrightarrow" : "\u27fa" , "\\looparrowleft" : "\u21ab" , "\\looparrowright" : "\u21ac" , "\\Lsh" : "\u21b0" , "\\mapsto" : "\u21a6" , "\\multimap" : "\u22b8" , "\\nearrow" : "\u2197" , "\\nleftarrow" : "\u219a" , "\\nLeftarrow" : "\u21cd" , "\\nleftrightarrow" : "\u21ae" , "\\nLeftrightarrow" : "\u21ce" , "\\nrightarrow" : "\u219b" , "\\nRightarrow" : "\u21cf" , "\\nwarrow" : "\u2196" , "\\restriction" : "\u21be" , "\\rightarrow" : "\u2192" , "\\Rightarrow" : "\u21d2" , "\\rightarrowtail" : "\u21a3" , "\\rightharpoondown" : "\u21c1" , "\\rightharpoonup" : "\u21c0" , "\\rightleftarrows" : "\u21c4" , "\\rightleftharpoons" : "\u21cc" , "\\rightrightarrows" : "\u21c9" , "\\rightsquigarrow" : "\u219d" , "\\Rrightarrow" : "\u21db" , "\\Rsh" : "\u21b1" , "\\searrow" : "\u2198" , "\\swarrow" : "\u2199" , "\\to" : "\u2192" , "\\twoheadleftarrow" : "\u219e" , "\\twoheadrightarrow" : "\u21a0" , "\\upharpoonleft" : "\u21bf" , "\\upharpoonright" : "\u21be" , "\\upuparrows" : "\u21c8" , "\\backepsilon" : "\u03f6" , "\\because" : "\u2235" , "\\between" : "\u226c" , "\\blacktriangleleft" : "\u25c0" , "\\blacktriangleright" : "\u25b6" , "\\bowtie" : "\u22c8" , "\\dashv" : "\u22a3" , "\\frown" : "\u2323" , "\\in" : "\u220a" , "\\mid" : "\u2223" , "\\models" : "\u22a7" , "\\ni" : "\u220b" , "\\ni" : "\u220d" , "\\nmid" : "\u2224" , "\\notin" : "\u2209" , "\\nparallel" : "\u2226" , "\\nshortmid" : "\u2224" , "\\nshortparallel" : "\u2226" , "\\nsubseteq" : "\u2286" , "\\nsubseteq" : "\u2288" , "\\nsubseteqq" : "\u2ac5" , "\\nsupseteq" : "\u2287" , "\\nsupseteq" : "\u2289" , "\\nsupseteqq" : "\u2ac6" , "\\ntriangleleft" : "\u22ea" , "\\ntrianglelefteq" : "\u22ec" , "\\ntriangleright" : "\u22eb" , "\\ntrianglerighteq" : "\u22ed" , "\\nvdash" : "\u22ac" , "\\nvDash" : "\u22ad" , "\\nVdash" : "\u22ae" , "\\nVDash" : "\u22af" , "\\owns" : "\u220d" , "\\parallel" : "\u2225" , "\\perp" : "\u22a5" , "\\pitchfork" : "\u22d4" , "\\propto" : "\u221d" , "\\shortmid" : "\u2223" , "\\shortparallel" : "\u2225" , "\\smallfrown" : "\u2322" , "\\smallsmile" : "\u2323" , "\\smile" : "\u2323" , "\\sqsubset" : "\u228f" , "\\sqsubseteq" : "\u2291" , "\\sqsupset" : "\u2290" , "\\sqsupseteq" : "\u2292" , "\\subset" : "\u2282" , "\\Subset" : "\u22d0" , "\\subseteq" : "\u2286" , "\\subseteqq" : "\u2ac5" , "\\subsetneq" : "\u228a" , "\\subsetneqq" : "\u2acb" , "\\supset" : "\u2283" , "\\Supset" : "\u22d1" , "\\supseteq" : "\u2287" , "\\supseteqq" : "\u2ac6" , "\\supsetneq" : "\u228b" , "\\supsetneqq" : "\u2acc" , "\\therefore" : "\u2234" , "\\trianglelefteq" : "\u22b4" , "\\trianglerighteq" : "\u22b5" , "\\varpropto" : "\u221d" , "\\varsubsetneq" : "\u228a" , "\\varsubsetneqq" : "\u2acb" , "\\varsupsetneq" : "\u228b" , "\\varsupsetneqq" : "\u2acc" , "\\vartriangle" : "\u25b5" , "\\vartriangleleft" : "\u22b2" , "\\vartriangleright" : "\u22b3" , "\\vdash" : "\u22a2" , "\\vDash" : "\u22a8" , "\\Vdash" : "\u22a9" , "\\Vvdash" : "\u22aa" , // AMS Arrows "\\dashleftarrow" : "\u21e0" , "\\dashrightarrow" : "\u21e2" , } ; var g_named_identifiers = {"\\arccos" : "arccos" , "\\arcsin" : "arcsin" , "\\arctan" : "arctan" , "\\arg" : "arg" , "\\cos" : "cos" , "\\cosh" : "cosh" , "\\cot" : "cot" , "\\coth" : "coth" , "\\csc" : "csc" , "\\deg" : "deg" , "\\det" : "det" , "\\dim" : "dim" , "\\exp" : "exp" , "\\gcd" : "gcd" , "\\hom" : "hom" , "\\ker" : "ker" , "\\lg" : "lg" , "\\ln" : "ln" , "\\log" : "log" , "\\Pr" : "Pr" , "\\sec" : "sec" , "\\sin" : "sin" , "\\sinh" : "sinh" , "\\tan" : "tan" , "\\tanh" : "tanh" , "\\inf" : "inf" , "\\injlim" : "inj lim" , "\\lim" : "lim" , "\\liminf" : "lim inf" , "\\limsup" : "lum sup" , "\\max" : "max" , "\\min" : "min" , "\\projlim" : "proj lim" , "\\sup" : "sup" , "\\alpha" : "\u03b1" , "\\beta" : "\u03b2" , "\\chi" : "\u03c7" , "\\delta" : "\u03b4" , "\\Delta" : "\u0394" , "\\digamma" : "\u03dd" , "\\epsilon" : "\u03f5" , "\\eta" : "\u03b7" , "\\gamma" : "\u03b3" , "\\Gamma" : "\u0393" , "\\iota" : "\u03b9" , "\\kappa" : "\u03ba" , "\\lambda" : "\u03bb" , "\\Lambda" : "\u039b" , "\\mu" : "\u03bc" , "\\nu" : "\u03bd" , "\\omega" : "\u03c9" , "\\Omega" : "\u03a9" , "\\phi" : "\u03c6" , "\\Phi" : "\u03a6" , "\\pi" : "\u03c0" , "\\Pi" : "\u03a0" , "\\psi" : "\u03c8" , "\\Psi" : "\u03a8" , "\\rho" : "\u03c1" , "\\sigma" : "\u03c3" , "\\Sigma" : "\u03a3" , "\\tau" : "\u03c4" , "\\theta" : "\u03b8" , "\\Theta" : "\u0398" , "\\upsilon" : "\u03c5" , "\\Upsilon" : "\u03d2" , "\\varepsilon" : "\u03b5" , "\\varkappa" : "\u03f0" , "\\varphi" : "\u03d5" , "\\varpi" : "\u03d6" , "\\varrho" : "\u03f1" , "\\varsigma" : "\u03c2" , "\\vartheta" : "\u03d1" , "\\xi" : "\u03be" , "\\Xi" : "\u039e" , "\\zeta" : "\u03b6" , "a" : "a" , "b" : "b" , "c" : "c" , "d" : "d" , "e" : "e" , "f" : "f" , "g" : "g" , "h" : "h" , "i" : "i" , "j" : "j" , "k" : "k" , "l" : "l" , "m" : "m" , "n" : "n" , "o" : "o" , "p" : "p" , "q" : "q" , "r" : "r" , "s" : "s" , "t" : "t" , "u" : "u" , "v" : "v" , "w" : "w" , "x" : "x" , "y" : "y" , "z" : "z" , "A" : "A" , "B" : "B" , "C" : "C" , "D" : "D" , "E" : "E" , "F" : "F" , "G" : "G" , "H" : "H" , "I" : "I" , "J" : "J" , "K" : "K" , "L" : "L" , "M" : "M" , "N" : "N" , "O" : "O" , "P" : "P" , "Q" : "Q" , "R" : "R" , "S" : "S" , "T" : "T" , "U" : "U" , "V" : "V" , "W" : "W" , "X" : "X" , "Y" : "Y" , "Z" : "Z" , "\\vdots" : "\u22ee" , "\\hdots" : "\u2026" , "\\ldots" : "\u2026" , "\\dots" : "\u2026" , "\\cdots" : "\u00b7\u00b7\u00b7" , "\\dotsb" : "\u00b7\u00b7\u00b7" , "\\dotsc" : "\u2026" , "\\dotsi" : "\u22c5\u22c5\u22c5" , "\\dotsm" : "\u22c5\u22c5\u22c5" , "\\dotso" : "\u2026" , "\\ddots" : "\u22f1" , // Common abbreviation for \mathbb letters "\\A" : "\uD835\uDD38" , "\\bA" : "\uD835\uDD38" , "\\B" : "\uD835\uDD39" , "\\bB" : "\uD835\uDD39" , "\\C" : "\u2102" , "\\bC" : "\u2102" , "\\D" : "\uD835\uDD3B" , "\\bD" : "\uD835\uDD3B" , "\\E" : "\uD835\uDD3C" , "\\bE" : "\uD835\uDD3C" , "\\F" : "\uD835\uDD3D" , "\\bF" : "\uD835\uDD3D" , "\\G" : "\uD835\uDD3E" , "\\bG" : "\uD835\uDD3E" , "\\H" : "\u210D" , "\\bH" : "\u210D" , "\\I" : "\uD835\uDD40" , "\\bI" : "\uD835\uDD40" , "\\J" : "\uD835\uDD41" , "\\bJ" : "\uD835\uDD41" , "\\K" : "\uD835\uDD42" , "\\bK" : "\uD835\uDD42" , "\\L" : "\uD835\uDD43" , "\\bL" : "\uD835\uDD43" , "\\M" : "\uD835\uDD44" , "\\bM" : "\uD835\uDD44" , "\\N" : "\u2115" , "\\bN" : "\u2115" , "\\O" : "\uD835\uDD46" , "\\bO" : "\uD835\uDD46" , "\\P" : "\u2119" , "\\bP" : "\u2119" , "\\Q" : "\u211A" , "\\bQ" : "\u211A" , "\\R" : "\u211D" , "\\bR" : "\u211D" , "\\S" : "\uD835\uDD4A" , "\\bS" : "\uD835\uDD4A" , "\\T" : "\uD835\uDD4B" , "\\bT" : "\uD835\uDD4B" , "\\U" : "\uD835\uDD4C" , "\\bU" : "\uD835\uDD4C" , "\\V" : "\uD835\uDD4D" , "\\bV" : "\uD835\uDD4D" , "\\W" : "\uD835\uDD4E" , "\\bW" : "\uD835\uDD4E" , "\\X" : "\uD835\uDD4F" , "\\bX" : "\uD835\uDD4F" , "\\Y" : "\uD835\uDD50" , "\\bY" : "\uD835\uDD50" , "\\Z" : "\u2124" , "\\bZ" : "\u2124" , // Common abbreviations for \mathcal letters "\\cA" : "\uD835\uDC9C" , "\\cB" : "\u212C" , "\\cC" : "\uD835\uDC9E" , "\\cD" : "\uD835\uDC9F" , "\\cE" : "\u2130" , "\\cF" : "\u2131" , "\\cG" : "\uD835\uDCA2" , "\\cH" : "\u210B" , "\\cI" : "\u2110" , "\\cJ" : "\uD835\uDCA5" , "\\cK" : "\uD835\uDCA6" , "\\cL" : "\u2112" , "\\cM" : "\u2133" , "\\cN" : "\uD835\uDCA9" , "\\cO" : "\uD835\uDCAA" , "\\OO" : "\uD835\uDCAA" , "\\cP" : "\uD835\uDCAB" , "\\cQ" : "\uD835\uDCAC" , "\\cR" : "\u211B" , "\\cS" : "\uD835\uDCAE" , "\\cT" : "\uD835\uDCAF" , "\\cU" : "\uD835\uDCB0" , "\\cV" : "\uD835\uDCB1" , "\\cW" : "\uD835\uDCB2" , "\\cX" : "\uD835\uDCB3" , "\\cY" : "\uD835\uDCB4" , "\\cZ" : "\uD835\uDCB5" , // Common operators "\\Pic" : "Pic" , "\\Spec" : "Spec" , "\\Proj" : "Proj" , // Misc "\\eps" : "\u03f5" , } ; var g_word_operators = {"\\arccos" : "arccos" , "\\arcsin" : "arcsin" , "\\arctan" : "arctan" , "\\arg" : "arg" , "\\cos" : "cos" , "\\cosh" : "cosh" , "\\cot" : "cot" , "\\coth" : "coth" , "\\csc" : "csc" , "\\deg" : "deg" , "\\det" : "det" , "\\dim" : "dim" , "\\exp" : "exp" , "\\gcd" : "gcd" , "\\hom" : "hom" , "\\ker" : "ker" , "\\lg" : "lg" , "\\ln" : "ln" , "\\log" : "log" , "\\Pr" : "Pr" , "\\sec" : "sec" , "\\sin" : "sin" , "\\sinh" : "sinh" , "\\tan" : "tan" , "\\tanh" : "tanh" , } ; var g_big_word_operators = {"\\inf" : "inf" , "\\injlim" : "inj lim" , "\\lim" : "lim" , "\\liminf" : "lim inf" , "\\limsup" : "lum sup" , "\\max" : "max" , "\\min" : "min" , "\\projlim" : "proj lim" , "\\sup" : "sup" , } ; var g_greek_letters = {"\\alpha" : "\u03b1" , "\\beta" : "\u03b2" , "\\chi" : "\u03c7" , "\\delta" : "\u03b4" , "\\Delta" : "\u0394" , "\\digamma" : "\u03dd" , "\\epsilon" : "\u03f5" , "\\eta" : "\u03b7" , "\\gamma" : "\u03b3" , "\\Gamma" : "\u0393" , "\\iota" : "\u03b9" , "\\kappa" : "\u03ba" , "\\lambda" : "\u03bb" , "\\Lambda" : "\u039b" , "\\mu" : "\u03bc" , "\\nu" : "\u03bd" , "\\omega" : "\u03c9" , "\\Omega" : "\u03a9" , "\\phi" : "\u03c6" , "\\Phi" : "\u03a6" , "\\pi" : "\u03c0" , "\\Pi" : "\u03a0" , "\\psi" : "\u03c8" , "\\Psi" : "\u03a8" , "\\rho" : "\u03c1" , "\\sigma" : "\u03c3" , "\\Sigma" : "\u03a3" , "\\tau" : "\u03c4" , "\\theta" : "\u03b8" , "\\Theta" : "\u0398" , "\\upsilon" : "\u03c5" , "\\Upsilon" : "\u03d2" , "\\varepsilon" : "\u03b5" , "\\varkappa" : "\u03f0" , "\\varphi" : "\u03d5" , "\\varpi" : "\u03d6" , "\\varrho" : "\u03f1" , "\\varsigma" : "\u03c2" , "\\vartheta" : "\u03d1" , "\\xi" : "\u03be" , "\\Xi" : "\u039e" , "\\zeta" : "\u03b6" , } ; function v_fraction_to_mathml (tokens ) { var v_numerator = v_piece_to_mathml (tokens ) ; var v_denominator = v_piece_to_mathml (tokens ) ; return result_element( "mfrac" ,0 , v_numerator , v_denominator ) ; } function v_binom_to_mathml (tokens ) { var v_top = v_piece_to_mathml (tokens ) ; var v_bottom = v_piece_to_mathml (tokens ) ; return result_element( "mrow" ,0 , result_element( "mo" ,0 , "(" ) , result_element( "mfrac" , 1 , "linethickness" , "0" , v_top , v_bottom ) , result_element( "mo" ,0 , ")" ) ) ; } function v_sqrt_to_mathml (tokens ) { var v_index = v_optional_arg_to_mathml (tokens ) ; var v_object = v_piece_to_mathml (tokens ) ; if( ( v_index != null ) ) { return result_element( "mroot" ,0 , v_object , v_index ) ; } else { return result_element( "msqrt" ,0 , v_object ) ; } } function v_parenthesized_operator (tokens , v_word ) { var v_object = v_piece_to_mathml (tokens ) ; if( ( v_word != null ) ) { return result_element( "mrow" ,0 , result_element( "mo" ,0 , "(" ) , result_element( "mo" ,0 , v_word ) , v_object , result_element( "mo" ,0 , ")" ) ) ; } else { return result_element( "mrow" ,0 , result_element( "mo" ,0 , "(" ) , v_object , result_element( "mo" ,0 , ")" ) ) ; } } function v_operatorname_to_mathml (tokens ) { var v_result = result_element( "mo" ,0 , tokens.list[tokens.index] ) ; tokens.index++; return v_result ; } function v_displaystyle_to_mathml (tokens ) { var v_result = v_subexpr_chain_to_mathml (tokens , g_hard_stop_tokens ) ; return result_element( "mstyle" , 2 , "displaystyle" , "true" , "scriptlevel" , "0" , v_result ) ; } function v_displaymath_to_mathml (tokens ) { var v_result = v_subexpr_chain_to_mathml (tokens , g_hard_stop_tokens ) ; v_finish_latex_block (tokens ); return result_element( "mstyle" , 2 , "displaystyle" , "true" , "scriptlevel" , "0" , v_result ) ; } function v_font_to_mathml (tokens , v_font_name ) { if( ( tokens.list[tokens.index] != "{" ) ) { var v_result = result_element( "mi" , 1 , "mathvariant" , v_font_name , tokens.list[tokens.index] ) ; if( ( v_font_name == "normal" ) ) { result_set_attr( v_result , "fontstyle" , "normal" ); } tokens.index++; return v_result ; } else { var v_result = v_piece_to_mathml (tokens ) ; result_set_attr( v_result , "mathvariant" , v_font_name ); if( ( v_font_name == "normal" ) ) { result_set_attr( v_result , "fontstyle" , "normal" ); } return v_result ; } } function v_old_font_to_mathml (tokens , v_font_name ) { return result_element( "mstyle" , 2 , "mathvariant" , v_font_name , "fontstyle" , ( ( v_font_name == "normal" ) ? "normal" : null ) , v_subexpr_chain_to_mathml (tokens , g_hard_stop_tokens ) ) ; } function v_size_to_mathml (tokens , v_min_size , v_max_size ) { var v_result = v_piece_to_mathml (tokens ) ; result_set_attr( v_result , "minsize" , v_min_size ); result_set_attr( v_result , "maxsize" , v_max_size ); return v_result ; } function v_accent_to_mathml (tokens , v_char ) { return result_element( "mover" , 1 , "accent" , "true" , v_piece_to_mathml (tokens ) , result_element( "mo" ,0 , v_char ) ) ; } function v_matrix_to_mathml (tokens , v_open_delim , v_close_delim ) { var v_mtable = v_matrix_to_mtable (tokens , result_element( "mtable" ,0) ) ; if( ( ( v_open_delim != null ) || ( v_close_delim != null ) ) ) { var v_mrow = result_element( "mrow" ,0) ; if( ( v_open_delim != null ) ) { result_element_append( v_mrow , result_element( "mo" ,0 , v_open_delim ) ); } result_element_append( v_mrow , v_mtable ); if( ( v_close_delim != null ) ) { result_element_append( v_mrow , result_element( "mo" ,0 , v_close_delim ) ); } return v_mrow ; } else { return v_mtable ; } } function v_array_to_mathml (tokens ) { var v_mtable = result_element( "mtable" ,0) ; if( ( tokens.list[tokens.index] == "{" ) ) { tokens.index++; while( ( ( tokens.list[tokens.index] != null ) && ( tokens.list[tokens.index] != "}" ) ) ) { if( ( tokens.list[tokens.index] == "c" ) ) { result_append_attr( v_mtable , "columnalign" , "center " ); } else if( ( tokens.list[tokens.index] == "l" ) ) { result_append_attr( v_mtable , "columnalign" , "left " ); } else if( ( tokens.list[tokens.index] == "r" ) ) { result_append_attr( v_mtable , "columnalign" , "right " ); } tokens.index++; } if( ( tokens.list[tokens.index] != null ) ) { tokens.index++; } } return v_matrix_to_mtable (tokens , v_mtable ) ; } function v_matrix_to_mtable (tokens , v_mtable ) { var v_mtr = result_element( "mtr" ,0) ; var v_mtd = result_element( "mtd" ,0) ; var v_token = tokens.list[tokens.index] ; result_element_append( v_mtable , v_mtr ); result_element_append( v_mtr , v_mtd ); while( ( ( v_token != null ) && ( v_token != "\\end" ) ) ) { if( ( v_token == "\\\\" ) ) { v_mtr = result_element( "mtr" ,0) ; v_mtd = result_element( "mtd" ,0) ; result_element_append( v_mtable , v_mtr ); result_element_append( v_mtr , v_mtd ); tokens.index++; } else if( ( v_token == "&" ) ) { v_mtd = result_element( "mtd" ,0) ; result_element_append( v_mtr , v_mtd ); tokens.index++; } else { result_element_append( v_mtd , v_subexpr_chain_to_mathml (tokens , g_hard_stop_tokens ) ); } v_token = tokens.list[tokens.index] ; } v_finish_latex_block (tokens ); return v_mtable ; } function v_over_to_mathml (tokens , v_char ) { return result_element( "mover" ,0 , v_piece_to_mathml (tokens ) , result_element( "mo" ,0 , v_char ) ) ; } function v_under_to_mathml (tokens , v_char ) { return result_element( "munder" ,0 , v_piece_to_mathml (tokens ) , result_element( "mo" ,0 , v_char ) ) ; } function v_delimiter_to_mathml (tokens , v_end_command , v_min_size , v_max_size ) { var v_mrow = result_element( "mrow" ,0) ; result_element_append( v_mrow , result_element( "mo" , 2 , "minsize" , v_min_size , "maxsize" , v_max_size , v_read_delimiter (tokens ) ) ); result_element_append( v_mrow , v_subexpr_chain_to_mathml (tokens , g_hard_stop_tokens ) ); if( ( tokens.list[tokens.index] != v_end_command ) ) { return v_mrow ; } tokens.index++; result_element_append( v_mrow , result_element( "mo" , 2 , "minsize" , v_min_size , "maxsize" , v_max_size , v_read_delimiter (tokens ) ) ); return v_mrow ; } function v_read_delimiter (tokens ) { var v_token = tokens.list[tokens.index] ; if( ( v_token == null ) ) { throw "unexpected eof" ; } else if( ( v_token == "." ) ) { tokens.index++; return "" ; } else if( ( v_token == "<" ) ) { tokens.index++; return "\u2329" ; } else if( ( v_token == ">" ) ) { tokens.index++; return "\u232a" ; } else if( ( v_token in g_punct_and_space ) ) { tokens.index++; return g_punct_and_space [ v_token ] ; } else if( ( v_token in g_left_delimiters ) ) { tokens.index++; return g_left_delimiters [ v_token ] ; } else if( ( v_token in g_right_delimiters ) ) { tokens.index++; return g_right_delimiters [ v_token ] ; } else if( ( v_token in g_operator_symbols ) ) { tokens.index++; return g_operator_symbols [ v_token ] ; } else { throw "invalid delimiter" ; } } function v_latex_block_to_mathml (tokens ) { v_cmd = tokens.list[tokens.index] ; if( ( v_cmd in g_tex_environments ) ) { tokens.index++; return g_tex_environments [ v_cmd ] (tokens ) ; } else { throw "unknown command" ; } } function v_finish_latex_block (tokens ) { if( ( tokens.list[tokens.index] == null ) ) { throw "unexpected eof" ; } tokens.index++; tokens.index++; } function v_combining_to_mathml (tokens , v_char ) { var v_base = tokens.list[tokens.index] ; tokens.index++; return result_element( "mo" ,0 , v_base , v_char ) ; } var g_char_escape_codes = {"93" : "#" , } ; function v_char_escape_to_mathml (tokens ) { var v_result = null ; if( ( tokens.list[tokens.index] in g_char_escape_codes ) ) { v_result = result_element( "mtext" ,0 , g_char_escape_codes [ tokens.list[tokens.index] ] ) ; } else { v_result = result_element( "merror" ,0 , "\\char" , tokens.list[tokens.index] ) ; } tokens.index++; return v_result ; } function v_text_to_mathml (tokens ) { if( ( tokens.list[tokens.index] != "{" ) ) { var v_result = result_element( "mtext" ,0 , tokens.list[tokens.index] ) ; tokens.index++; return v_result ; } tokens.index++; var v_result = null ; var v_mrow = null ; var v_node = null ; while( ( tokens.list[tokens.index] != null ) ) { if( ( tokens.list[tokens.index] == "}" ) ) { tokens.index++; return v_result ; } else if( ( tokens.list[tokens.index] == "$" ) ) { tokens.index++; v_node = v_subexpr_chain_to_mathml (tokens , g_hard_stop_tokens ) ; tokens.index++; } else { v_node = result_element( "mtext" ,0 , tokens.list[tokens.index] ) ; tokens.index++; } if( ( v_mrow != null ) ) { result_element_append( v_mrow , v_node ); } else if( ( v_result != null ) ) { v_mrow = result_element( "mrow" ,0 , v_result , v_node ) ; v_result = v_mrow ; } else { v_result = v_node ; } } return v_result ; } var g_tex_commands = { "\\frac" : v_fraction_to_mathml , "\\dfrac" : v_fraction_to_mathml , "\\tfrac" : v_fraction_to_mathml , "\\binom" : v_binom_to_mathml , "\\sqrt" : v_sqrt_to_mathml , "\\operatorname" : v_operatorname_to_mathml , "\\displaystyle" : v_displaystyle_to_mathml , "\\pod" : function(tokens ) {return v_parenthesized_operator (tokens , null ) ;} , "\\pmod" : function(tokens ) {return v_parenthesized_operator (tokens , "mod" ) ;} , "\\boldsymbol" : function(tokens ) {return v_font_to_mathml (tokens , "bold" ) ;} , "\\bold" : function(tokens ) {return v_font_to_mathml (tokens , "bold" ) ;} , "\\Bbb" : function(tokens ) {return v_font_to_mathml (tokens , "double-struck" ) ;} , "\\mathbb" : function(tokens ) {return v_font_to_mathml (tokens , "double-struck" ) ;} , "\\mathbbmss" : function(tokens ) {return v_font_to_mathml (tokens , "double-struck" ) ;} , "\\mathbf" : function(tokens ) {return v_font_to_mathml (tokens , "bold" ) ;} , "\\mathop" : function(tokens ) {return v_font_to_mathml (tokens , "normal" ) ;} , "\\mathopen" : function(tokens ) {return v_font_to_mathml (tokens , "normal" ) ;} , "\\mathclose" : function(tokens ) {return v_font_to_mathml (tokens , "normal" ) ;} , "\\mathrm" : function(tokens ) {return v_font_to_mathml (tokens , "normal" ) ;} , "\\mathfrak" : function(tokens ) {return v_font_to_mathml (tokens , "fraktur" ) ;} , "\\germ" : function(tokens ) {return v_font_to_mathml (tokens , "fraktur" ) ;} , "\\mathit" : function(tokens ) {return v_font_to_mathml (tokens , "italic" ) ;} , "\\mathscr" : function(tokens ) {return v_font_to_mathml (tokens , "script" ) ;} , "\\scr" : function(tokens ) {return v_font_to_mathml (tokens , "script" ) ;} , "\\mathcal" : function(tokens ) {return v_font_to_mathml (tokens , "script" ) ;} , "\\mathsf" : function(tokens ) {return v_font_to_mathml (tokens , "sans-serif" ) ;} , "\\mathtt" : function(tokens ) {return v_font_to_mathml (tokens , "monospace" ) ;} , "\\EuScript" : function(tokens ) {return v_font_to_mathml (tokens , "script" ) ;} , "\\bf" : function(tokens ) {return v_old_font_to_mathml (tokens , "bold" ) ;} , "\\rm" : function(tokens ) {return v_old_font_to_mathml (tokens , "normal" ) ;} , "\\roman" : function(tokens ) {return v_old_font_to_mathml (tokens , "normal" ) ;} , "\\tag" : function(tokens ) {return v_old_font_to_mathml (tokens , "bold" ) ;} , "\\big" : function(tokens ) {return v_size_to_mathml (tokens , "2" , "2" ) ;} , "\\Big" : function(tokens ) {return v_size_to_mathml (tokens , "3" , "3" ) ;} , "\\bigg" : function(tokens ) {return v_size_to_mathml (tokens , "4" , "4" ) ;} , "\\Bigg" : function(tokens ) {return v_size_to_mathml (tokens , "5" , "5" ) ;} , "\\acute" : function(tokens ) {return v_accent_to_mathml (tokens , "\u0301" ) ;} , "\\grave" : function(tokens ) {return v_accent_to_mathml (tokens , "\u0300" ) ;} , "\\tilde" : function(tokens ) {return v_accent_to_mathml (tokens , "\u0303" ) ;} , "\\bar" : function(tokens ) {return v_accent_to_mathml (tokens , "\u0304" ) ;} , "\\breve" : function(tokens ) {return v_accent_to_mathml (tokens , "\u0306" ) ;} , "\\check" : function(tokens ) {return v_accent_to_mathml (tokens , "\u030c" ) ;} , "\\hat" : function(tokens ) {return v_accent_to_mathml (tokens , "\u0302" ) ;} , "\\vec" : function(tokens ) {return v_accent_to_mathml (tokens , "\u20d7" ) ;} , "\\dot" : function(tokens ) {return v_accent_to_mathml (tokens , "\u0307" ) ;} , "\\ddot" : function(tokens ) {return v_accent_to_mathml (tokens , "\u0308" ) ;} , "\\dddot" : function(tokens ) {return v_accent_to_mathml (tokens , "\u20db" ) ;} , "\\underbrace" : function(tokens ) {return v_under_to_mathml (tokens , "\ufe38" ) ;} , "\\overbrace" : function(tokens ) {return v_over_to_mathml (tokens , "\ufe37" ) ;} , "\\underline" : function(tokens ) {return v_under_to_mathml (tokens , "\u0332" ) ;} , "\\overline" : function(tokens ) {return v_over_to_mathml (tokens , "\u00af" ) ;} , "\\widetilde" : function(tokens ) {return v_over_to_mathml (tokens , "\u0303" ) ;} , "\\widehat" : function(tokens ) {return v_over_to_mathml (tokens , "\u0302" ) ;} , "\\not" : function(tokens ) {return v_combining_to_mathml (tokens , "\u0338" ) ;} , "\\left" : function(tokens ) {return v_delimiter_to_mathml (tokens , "\\right" , "1" , null ) ;} , "\\bigl" : function(tokens ) {return v_delimiter_to_mathml (tokens , "\\bigr" , "2" , "2" ) ;} , "\\Bigl" : function(tokens ) {return v_delimiter_to_mathml (tokens , "\\Bigr" , "3" , "3" ) ;} , "\\biggl" : function(tokens ) {return v_delimiter_to_mathml (tokens , "\\biggr" , "4" , "4" ) ;} , "\\Biggl" : function(tokens ) {return v_delimiter_to_mathml (tokens , "\\Biggr" , "5" , "5" ) ;} , "\\char" : v_char_escape_to_mathml , "\\!" : function(tokens ) {return null ;} , "\\text" : v_text_to_mathml , "\\textnormal" : v_text_to_mathml , "\\textrm" : v_text_to_mathml , "\\textsl" : v_text_to_mathml , "\\textit" : v_text_to_mathml , "\\texttt" : v_text_to_mathml , "\\textbf" : v_text_to_mathml , "\\hbox" : v_text_to_mathml , "\\mbox" : v_text_to_mathml , "\\begin" : v_latex_block_to_mathml , } ; var g_tex_environments = {"smallmatrix" : function(tokens ) {return v_matrix_to_mathml (tokens , "(" , ")" ) ;} , "pmatrix" : function(tokens ) {return v_matrix_to_mathml (tokens , "(" , ")" ) ;} , "bmatrix" : function(tokens ) {return v_matrix_to_mathml (tokens , "[" , "]" ) ;} , "Bmatrix" : function(tokens ) {return v_matrix_to_mathml (tokens , "{" , "}" ) ;} , "vmatrix" : function(tokens ) {return v_matrix_to_mathml (tokens , "|" , "|" ) ;} , "Vmatrix" : function(tokens ) {return v_matrix_to_mathml (tokens , "\u2016" , "\u2016" ) ;} , "cases" : function(tokens ) {return v_matrix_to_mathml (tokens , "{" , null ) ;} , "array" : v_array_to_mathml , "displaymath" : v_displaymath_to_mathml , } ; var g_limit_commands = {"\\bigcap" : "\u22c2" , "\\bigcup" : "\u22c3" , "\\bigodot" : "\u2a00" , "\\bigoplus" : "\u2a01" , "\\bigotimes" : "\u2a02" , "\\bigsqcup" : "\u2a06" , "\\biguplus" : "\u2a04" , "\\bigvee" : "\u22c1" , "\\bigwedge" : "\u22c0" , "\\coprod" : "\u2210" , "\\prod" : "\u220f" , "\\sum" : "\u2211" , "\\inf" : "inf" , "\\injlim" : "inj lim" , "\\lim" : "lim" , "\\liminf" : "lim inf" , "\\limsup" : "lum sup" , "\\max" : "max" , "\\min" : "min" , "\\projlim" : "proj lim" , "\\sup" : "sup" , "\\underbrace" : null , "\\overbrace" : null , "\\underline" : null , "\\overline" : null , } ; function v_piece_to_mathml (tokens ) { var v_token = tokens.list[tokens.index] ; var v_result = null ; if( ( v_token == "{" ) ) { tokens.index++; v_result = v_subexpr_chain_to_mathml (tokens , g_hard_stop_tokens ) ; if( ( tokens.list[tokens.index] == "}" ) ) { tokens.index++; } } else if( ( v_token in g_relation_symbols ) ) { v_result = result_element( "mo" ,0 , g_relation_symbols [ v_token ] ) ; tokens.index++; } else if( ( v_token in g_operator_symbols ) ) { v_result = result_element( "mo" ,0 , g_operator_symbols [ v_token ] ) ; tokens.index++; } else if( ( v_token in g_left_delimiters ) ) { v_result = result_element( "mo" ,0 , g_left_delimiters [ v_token ] ) ; tokens.index++; } else if( ( v_token in g_right_delimiters ) ) { v_result = result_element( "mo" ,0 , g_right_delimiters [ v_token ] ) ; tokens.index++; } else if( ( v_token in g_word_operators ) ) { v_result = result_element( "mi" , 1 , "mathvariant" , "normal" , g_word_operators [ v_token ] ) ; tokens.index++; } else if( ( v_token in g_greek_letters ) ) { v_result = result_element( "mi" , 1 , "fontstyle" , "normal" , g_greek_letters [ v_token ] ) ; tokens.index++; } else if( ( v_token in g_named_identifiers ) ) { v_result = result_element( "mi" ,0 , g_named_identifiers [ v_token ] ) ; tokens.index++; } else if( ( v_token in g_punct_and_space ) ) { v_result = result_element( "mtext" ,0 , g_punct_and_space [ v_token ] ) ; tokens.index++; } else if( ( v_token in g_tex_commands ) ) { tokens.index++; v_result = g_tex_commands [ v_token ] (tokens ) ; } else { v_result = result_element( "mn" ,0 , v_token ) ; tokens.index++; } return v_result ; } function v_subexpr_to_mathml (tokens ) { var v_result = null ; var v_mmultiscripts = null ; var v_mprescripts = null ; if( ( ( tokens.list[tokens.length<=tokens.index+ 0 ? tokens.length-1 : tokens.index+ 0 ] == "{" ) && ( tokens.list[tokens.length<=tokens.index+ 1 ? tokens.length-1 : tokens.index+ 1 ] == "}" ) && ( ( tokens.list[tokens.length<=tokens.index+ 2 ? tokens.length-1 : tokens.index+ 2 ] == "_" ) || ( tokens.list[tokens.length<=tokens.index+ 2 ? tokens.length-1 : tokens.index+ 2 ] == "^" ) ) ) ) { v_mmultiscripts = result_element( "mmultiscripts" ,0) ; v_mprescripts = result_element( "mprescripts" ,0) ; result_element_append( v_mmultiscripts , v_mprescripts ); while( ( ( tokens.list[tokens.length<=tokens.index+ 0 ? tokens.length-1 : tokens.index+ 0 ] == "{" ) && ( tokens.list[tokens.length<=tokens.index+ 1 ? tokens.length-1 : tokens.index+ 1 ] == "}" ) && ( ( tokens.list[tokens.length<=tokens.index+ 2 ? tokens.length-1 : tokens.index+ 2 ] == "_" ) || ( tokens.list[tokens.length<=tokens.index+ 2 ? tokens.length-1 : tokens.index+ 2 ] == "^" ) ) ) ) { var v_subscript = null ; var v_superscript = null ; tokens.index++; tokens.index++; if( ( tokens.list[tokens.index] == "_" ) ) { tokens.index++; v_subscript = v_piece_to_mathml (tokens ) ; } else if( ( tokens.list[tokens.index] == "^" ) ) { tokens.index++; v_superscript = v_piece_to_mathml (tokens ) ; } if( ( tokens.list[tokens.index] == "_" ) ) { tokens.index++; v_subscript = v_piece_to_mathml (tokens ) ; } else if( ( tokens.list[tokens.index] == "^" ) ) { tokens.index++; v_superscript = v_piece_to_mathml (tokens ) ; } result_element_append( v_mmultiscripts , ( ( v_subscript != null ) ? v_subscript : result_element( "none" ,0) ) ); result_element_append( v_mmultiscripts , ( ( v_superscript != null ) ? v_superscript : result_element( "none" ,0) ) ); } } var v_limit_style = ( tokens.list[tokens.index] in g_limit_commands ) ; if( ( tokens.list[tokens.index] == null ) ) { if( ( v_mmultiscripts != null ) ) { result_element_prepend( v_mmultiscripts , result_element( "mrow" ,0) , v_mprescripts ); return v_mmultiscripts ; } else { return result_element( "mrow" ,0) ; } } else if( ( tokens.list[tokens.index] in g_left_delimiters ) ) { v_result = v_heuristic_subexpression (tokens ) ; } else { v_result = v_piece_to_mathml (tokens ) ; } var v_base = v_result ; var v_subscript = null ; var v_superscript = null ; if( ( tokens.list[tokens.index] == "_" ) ) { tokens.index++; v_subscript = v_piece_to_mathml (tokens ) ; } else if( ( tokens.list[tokens.index] == "^" ) ) { tokens.index++; v_superscript = v_piece_to_mathml (tokens ) ; } if( ( tokens.list[tokens.index] == "_" ) ) { tokens.index++; v_subscript = v_piece_to_mathml (tokens ) ; } else if( ( tokens.list[tokens.index] == "^" ) ) { tokens.index++; v_superscript = v_piece_to_mathml (tokens ) ; } if( ( v_mmultiscripts != null ) ) { result_element_prepend( v_mmultiscripts , v_base , v_mprescripts ); result_element_prepend( v_mmultiscripts , ( ( v_subscript != null ) ? v_subscript : result_element( "none" ,0) ) , v_mprescripts ); result_element_prepend( v_mmultiscripts , ( ( v_superscript != null ) ? v_superscript : result_element( "none" ,0) ) , v_mprescripts ); } while( ( ( tokens.list[tokens.length<=tokens.index+ 0 ? tokens.length-1 : tokens.index+ 0 ] == "{" ) && ( tokens.list[tokens.length<=tokens.index+ 1 ? tokens.length-1 : tokens.index+ 1 ] == "}" ) && ( ( tokens.list[tokens.length<=tokens.index+ 2 ? tokens.length-1 : tokens.index+ 2 ] == "_" ) || ( tokens.list[tokens.length<=tokens.index+ 2 ? tokens.length-1 : tokens.index+ 2 ] == "^" ) ) ) ) { if( ( v_mmultiscripts == null ) ) { v_mmultiscripts = result_element( "mmultiscripts" ,0 , v_base ) ; v_mprescripts = null ; if( ( ( v_superscript != null ) || ( v_subscript != null ) ) ) { result_element_append( v_mmultiscripts , ( ( v_subscript != null ) ? v_subscript : result_element( "none" ,0) ) ); result_element_append( v_mmultiscripts , ( ( v_superscript != null ) ? v_superscript : result_element( "none" ,0) ) ); } } var v_subscript = null ; var v_superscript = null ; tokens.index++; tokens.index++; if( ( tokens.list[tokens.index] == "_" ) ) { tokens.index++; v_subscript = v_piece_to_mathml (tokens ) ; } else if( ( tokens.list[tokens.index] == "^" ) ) { tokens.index++; v_superscript = v_piece_to_mathml (tokens ) ; } if( ( tokens.list[tokens.index] == "_" ) ) { tokens.index++; v_subscript = v_piece_to_mathml (tokens ) ; } else if( ( tokens.list[tokens.index] == "^" ) ) { tokens.index++; v_superscript = v_piece_to_mathml (tokens ) ; } result_element_prepend( v_mmultiscripts , ( ( v_subscript != null ) ? v_subscript : result_element( "none" ,0) ) , v_mprescripts ); result_element_prepend( v_mmultiscripts , ( ( v_superscript != null ) ? v_superscript : result_element( "none" ,0) ) , v_mprescripts ); } if( ( v_mmultiscripts != null ) ) { v_result = v_mmultiscripts ; } else if( ( ( v_subscript != null ) && ( v_superscript != null ) ) ) { v_result = result_element( ( v_limit_style ? "munderover" : "msubsup" ) ,0 , v_base , v_subscript , v_superscript ) ; } else if( ( v_subscript != null ) ) { v_result = result_element( ( v_limit_style ? "munder" : "msub" ) ,0 , v_base , v_subscript ) ; } else if( ( v_superscript != null ) ) { v_result = result_element( ( v_limit_style ? "mover" : "msup" ) ,0 , v_base , v_superscript ) ; } return v_result ; } function v_subexpr_chain_to_mathml (tokens , v_stop_tokens ) { var v_result = null ; var v_mrow = null ; var v_mfrac = null ; var v_wrapped_result = null ; while( ( ( tokens.list[tokens.index] != null ) && !( ( tokens.list[tokens.index] in v_stop_tokens ) ) ) ) { if( ( tokens.list[tokens.index] == "\\over" ) ) { tokens.index++; v_mfrac = result_element( "mfrac" ,0 , v_result ) ; v_wrapped_result = v_mfrac ; v_mrow = null ; v_result = null ; } else if( ( tokens.list[tokens.index] == "\\choose" ) ) { tokens.index++; v_mfrac = result_element( "mfrac" , 1 , "linethickness" , "0" , v_result ) ; v_wrapped_result = result_element( "mrow" ,0 , result_element( "mo" ,0 , "(" ) , v_mfrac , result_element( "mo" ,0 , ")" ) ) ; v_mrow = null ; v_result = null ; } else { var v_node = v_collect_precedence_group (tokens , g_relations_precedence_group , v_stop_tokens , function(tokens , v_stop_tokens ) {return v_collect_precedence_group (tokens , g_addition_precedence_group , v_stop_tokens , function(tokens , v_stop_tokens ) {return v_collect_precedence_group (tokens , g_multiplication_precedence_group , v_stop_tokens , v_collect_invisible_group ) ;} ) ;} ) ; if( ( v_mrow != null ) ) { result_element_append( v_mrow , v_node ); } else if( ( v_result != null ) ) { v_mrow = result_element( "mrow" ,0 , v_result , v_node ) ; v_result = v_mrow ; } else { v_result = v_node ; } } } if( ( v_mfrac != null ) ) { result_element_append( v_mfrac , v_result ); return v_wrapped_result ; } else { return v_result ; } } var g_optional_arg_stop_tokens = {"&" : null , "\\\\" : null , "}" : null , "$" : null , "\\end" : null , "\\right" : null , "\\bigr" : null , "\\Bigr" : null , "\\biggr" : null , "\\Biggr" : null , "\\choose" : null , "\\over" : null , "]" : null , } ; function v_optional_arg_to_mathml (tokens ) { if( ( tokens.list[tokens.index] != "[" ) ) { return null ; } tokens.index++; var v_result = v_subexpr_chain_to_mathml (tokens , g_optional_arg_stop_tokens ) ; if( ( tokens.list[tokens.index] == "]" ) ) { tokens.index++; } return v_result ; } var g_hard_stop_tokens = {"&" : null , "\\\\" : null , "}" : null , "$" : null , "\\end" : null , "\\right" : null , "\\bigr" : null , "\\Bigr" : null , "\\biggr" : null , "\\Biggr" : null , "\\choose" : null , "\\over" : null , } ; var g_right_delimiter_stop_tokens = {"&" : null , "\\\\" : null , "}" : null , "$" : null , "\\end" : null , "\\right" : null , "\\bigr" : null , "\\Bigr" : null , "\\biggr" : null , "\\Biggr" : null , "\\choose" : null , "\\over" : null , ")" : ")" , "]" : "]" , "\\}" : "}" , "\\rbrace" : "}" , "\\rgroup" : ")" , "\\rvert" : "|" , "\\rVert" : "\u2016" , "\\rceil" : "\u2309" , "\\rfloor" : "\u230b" , "\\rmoustache" : "\u23b1" , "\\rangle" : "\u232a" , } ; function v_heuristic_subexpression (tokens ) { var v_result = result_element( "mrow" ,0) ; result_element_append( v_result , v_piece_to_mathml (tokens ) ); result_element_append( v_result , v_subexpr_chain_to_mathml (tokens , g_right_delimiter_stop_tokens ) ); if( ( ( tokens.list[tokens.index] != null ) && !( ( tokens.list[tokens.index] in g_hard_stop_tokens ) ) ) ) { result_element_append( v_result , v_piece_to_mathml (tokens ) ); } return v_result ; } var g_relations_precedence_group = g_relation_symbols ; var g_addition_precedence_group = {"+" : null , "-" : null , "\\oplus" : null , } ; var g_multiplication_precedence_group = {"*" : null , "\\times" : null , "\\cdot" : null , "/" : null , } ; function v_collect_precedence_group (tokens , v_operators , v_stop_tokens , v_reader ) { var v_result = v_reader (tokens , v_stop_tokens ) ; var v_mrow = null ; while( ( ( tokens.list[tokens.index] != null ) && !( ( tokens.list[tokens.index] in v_stop_tokens ) ) && ( tokens.list[tokens.index] in v_operators ) ) ) { if( ( v_mrow == null ) ) { v_mrow = result_element( "mrow" ,0 , v_result ) ; v_result = v_mrow ; } result_element_append( v_mrow , v_piece_to_mathml (tokens ) ); if( ( ( tokens.list[tokens.index] != null ) && ( tokens.list[tokens.index] in v_stop_tokens ) ) ) { return v_result ; } else { result_element_append( v_mrow , v_reader (tokens , v_stop_tokens ) ); } } return v_result ; } function v_collect_invisible_group (tokens , v_stop_tokens ) { var v_result = v_subexpr_to_mathml (tokens ) ; var v_mrow = null ; while( ( ( tokens.list[tokens.index] != null ) && !( ( tokens.list[tokens.index] in v_stop_tokens ) ) && ( ( tokens.list[tokens.index] in g_named_identifiers ) || ( tokens.list[tokens.index] in g_left_delimiters ) ) ) ) { if( ( v_mrow == null ) ) { v_mrow = result_element( "mrow" ,0 , v_result ) ; v_result = v_mrow ; } result_element_append( v_mrow , result_element( "mo" ,0 , "\u2062" ) ); if( ( ( tokens.list[tokens.index] != null ) && ( tokens.list[tokens.index] in v_stop_tokens ) ) ) { return v_result ; } else { result_element_append( v_mrow , v_subexpr_to_mathml (tokens ) ); } } return v_result ; } const tokenize_re = /(\\begin|\\operatorname|\\mathrm|\\mathop|\\end)\s*\{\s*([A-Z a-z]+)\s*\}|(\\[a-zA-Z]+|\\[\\#\{\},:;!])|(\s+)|([0-9\.]+)|([\$!"#%&'()*+,-.\/:;<=>?\[\]^_`\{\|\}~])|([a-zA-Z])/g; const tokenize_text_re = /[\${}\\]|\\[a-zA-Z]+|[^{}\$]+/g; const tokenize_text_commands = { '\\textrm': 1, '\\textsl': 1, '\\textit': 1, '\\texttt': 1, '\\textbf': 1, '\\textnormal': 1, '\\text': 1, '\\hbox': 1, '\\mbox': 1 }; function tokenize_latex_math(input) { var result = new Array(); var in_text_mode = 0; var brace_level = []; var pos = 0; if(input.charAt(0) == '$' && input.charAt(input.length-1) == '$') input = input.slice(1, input.length-1); while(1) { if(!in_text_mode) { tokenize_re.lastIndex = pos; var m = tokenize_re.exec(input); pos = tokenize_re.lastIndex; if(m == null) { return result; } else if(m[1] != null) { result.push(m[1], m[2]); } else if(m[3] == '\\sp') { result.push('^'); } else if(m[3] == '\\sb') { result.push('_'); } else { if(m[0] == '$') { in_text_mode = 1; } else if(m[4] != null) { continue; } else if(m[3] != null && m[3] in tokenize_text_commands) { in_text_mode = 2; brace_level.push(0); } result.push(m[0]); } } else { tokenize_text_re.lastIndex = pos; var m = tokenize_text_re.exec(input); pos = tokenize_text_re.lastIndex; if(m == null) { return result; } else if(m[0] == '$') { in_text_mode = 0; } else if(m[0] == '{') { brace_level[brace_level.length-1]++; } else if(m[0] == '}') { if(--brace_level[brace_level.length-1] <= 0) { in_text_mode = 0; brace_level.pop(); } } result.push(m[0]); } } } /* function post_process_mathml(event) { var url = GM_getValue('click-post-url', null); if(url == null) return; var ser = new XMLSerializer(); var xhr = GM_xmlhttpRequest({ method: 'POST', url: url, headers: { 'Content-Type': 'text/xml; charset=utf-8', 'Content-Location': document.location }, data: ser.serializeToString(event.currentTarget), onerror: function(details) { alert("There was an error processing the request. " + "HTTP status code " + details.status + ' ' + details.statusText); }, onload: function(details) { window.status = "Successfully posted MathML. Status: " + details.status + ' ' + details.statusText; }}); window.status = "Posting MathML to " + url + "..."; } */ function patch_img(node) { if(node.currentTarget) node = node.currentTarget; var alt = node.getAttribute('alt'); if(alt == null || /^\\includegraphics|^\$\\displaystyle \\xymatrix/.test(alt)) return; var latex_string = null; if((node.parentNode.tagName == 'DIV' && node.parentNode.getAttribute('CLASS') == 'mathdisplay') || (node.parentNode.tagName == 'SPAN' && node.parentNode.getAttribute('CLASS') == 'MATH')) { var parent = node.parentNode; var previous = parent.previousSibling; const non_whitespace = /[^\s]/; if(previous && previous.nodeType == node.TEXT_NODE && !non_whitespace.test(previous.data)) previous = previous.previousSibling; if(previous && previous.nodeType == node.ELEMENT_NODE && previous.tagName == 'P' && previous.lastChild) { previous = previous.lastChild; if(previous && previous.nodeType == node.TEXT_NODE && !non_whitespace.test(previous.data)) previous = previous.previousSibling; } if(previous && previous.nodeType == node.COMMENT_NODE) { latex_string = previous.data.replace(/^\s*MATH\s*/, '') .replace(/\s+$/, ''); } } if(!latex_string && /^\$.+\$$/.test(alt) && !(/\.{3} \.{3}/.test(alt))) { latex_string = alt; } if(latex_string == null) return; tokens = new Object(); tokens.list = tokenize_latex_math(latex_string); tokens.list.push(null); tokens.index = 0; var mathml = null; try { var mrow = v_subexpr_chain_to_mathml(tokens, {}); fix_mathvariant(mrow, null); mathml = document.createElementNS(mmlns, 'math'); mathml.setAttribute("latex", latex_string); mathml.setAttribute("mathvariant", "normal"); mathml.appendChild(mrow); mathml.addEventListener("click", post_process_mathml, false); } catch(e) { GM_log("Display LaTeX failed with error " + e + " on " + latex_string); } if(mathml == null) return; node.parentNode.replaceChild(mathml, node); } function patch_text(node0) { var text = node0.nodeValue; var results = /\$[^$]+\$|\[tex\](.+?)\[\/tex\]/.exec(text); if(results) { var latex_string = (results[1] == null ? results[0] : '$'+results[1]+'$'); tokens = new Object(); tokens.list = tokenize_latex_math(latex_string); tokens.list.push(null); tokens.index = 0; var mathml = null; try { var mrow = v_subexpr_chain_to_mathml(tokens, {}); fix_mathvariant(mrow, null); mathml = document.createElementNS(mmlns, 'math'); mathml.setAttribute("latex", latex_string); mathml.setAttribute("mathvariant", "normal"); mathml.appendChild(mrow); mathml.addEventListener("click", post_process_mathml, false); } catch(e) { GM_log("Display LaTeX failed with error " + e + " on " + latex_string); } if(mathml == null) return; var node2 = node0.splitText(results.index); node2.deleteData(0, results[0].length); node2.parentNode.insertBefore(mathml, node2); patch_text(node2); } } function patch_element(node) { if(node.nodeType == node.TEXT_NODE) patch_text(node); else if(node.nodeType == node.ELEMENT_NODE) {if(node.tagName == 'TEXTAREA' || node.tagName == 'textarea' || node.tagName == 'INPUT' || node.tagName == 'input' || node.tagName == 'SCRIPT' || node.tagName == 'script') return; if(do_patch_images && (node.tagName == 'IMG' || node.tagName == 'img')) { if(!delayed_patch) patch_img(node); else node.addEventListener("click", patch_img, false); return; } var child = node.firstChild; while(child) { var next = child.nextSibling; if (child.className == 'stopLatex2mml') { break; } patch_element(child); child = next; } } } this.patch_element = patch_element; /* var do_patch_images = GM_getValue("patch-images", false); var delayed_patch = GM_getValue("delayed-patch", false); */ var do_patch_images = true; var delayed_patch = false; /* if( va_view == 'web' ){ patch_element(document.documentElement); } */ };