Stackedit/public/libs/MathJax/extensions/MathML/content-mathml.js

20 lines
63 KiB
JavaScript
Raw Normal View History

2013-11-19 22:02:44 +00:00
/*
* /MathJax/extensions/MathML/content-mathml.js
*
* Copyright (c) 2009-2013 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/content-mathml"]={version:"2.3"};MathJax.Hub.Register.StartupHook("MathML Jax Ready",function(){var c=MathJax.InputJax.MathML,e=c.Parse.prototype;c.prefilterHooks.Add(function(h){if(!c.ctopXSLT){return}if(!c.ParseXML){c.ParseXML=c.createParser()}var i=c.ParseXML(e.preProcessMath(h.math));var g=c.ctopXSLT.transformToDocument(i);if((typeof g)==="string"){h.math=g}else{if(window.XMLSerializer){var f=new XMLSerializer();h.math=f.serializeToString(g.documentElement,i)}}});var a='<x:stylesheet version="1.0" xmlns:x="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1998/Math/MathML" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:e="http://exslt.org/strings" xmlns:c="http://exslt.org/common" exclude-result-prefixes="m e c"> <!-- Copyright David Carlisle 2001, 2002, 2008, 2009. Use and distribution of this code are permitted under the terms of the<a href="http://www.w3.org/Consortium/Legal/copyright-software-19980720" >W3C Software Notice and License</a>. 2001-2002 MathML2 version 2008-2009 Updates for MathML3 --> <x:output method="xml" /> <x:template match="/"><x:apply-templates/></x:template> <x:template match="*"><x:copy><x:copy-of select="@*"/><x:apply-templates/></x:copy></x:template> <x:template match="m:cn"><mn><x:apply-templates/></mn></x:template> <x:template match="m:cn[@type=\'complex-cartesian\']"><mrow><mn><x:apply-templates select="text()[1]"/></mn><mo>+</mo><mn><x:apply-templates select="text()[2]"/></mn><mo>&#8290;</mo><mi>i</mi></mrow></x:template> <x:template match="m:apply[*[1][self::m:csymbol=\'complex_cartesian\']]"><mrow><mn><x:apply-templates select="*[2]"/></mn><mo>+</mo><mn><x:apply-templates select="*[3]"/></mn><mo>&#8290;</mo><mi>i</mi></mrow></x:template> <x:template match="m:cn[@type=\'rational\']"><mrow><mn><x:apply-templates select="text()[1]"/></mn><mo>/</mo><mn><x:apply-templates select="text()[2]"/></mn></mrow></x:template> <x:template match="m:apply[*[1][self::m:csymbol=\'rational\']]"><mrow><mn><x:apply-templates select="*[2]"/></mn><mo>/</mo><mn><x:apply-templates select="*[3]"/></mn></mrow></x:template> <x:template match="m:cn[not(@type) or @type=\'integer\']"><x:choose><x:when test="not(@base) or @base=10"><mn><x:apply-templates/></mn></x:when><x:otherwise><msub><mn><x:apply-templates/></mn><mn><x:value-of select="@base"/></mn></msub></x:otherwise></x:choose></x:template> <x:template match="m:cn[@type=\'complex-polar\']"><mrow><mn><x:apply-templates select="text()[1]"/></mn><mo>&#8290;</mo><msup><mi>e</mi><mrow><mi>i</mi><mo>&#8290;</mo><mn><x:apply-templates select="text()[2]"/></mn></mrow></msup></mrow></x:template> <x:template match="m:apply[*[1][self::m:csymbol=\'complex_polar\']]"><mrow><x:apply-templates select="*[2]"/><mo>&#8290;</mo><msup><mi>e</mi><mrow><mi>i</mi><mo>&#8290;</mo><x:apply-templates select="*[3]"/></mrow></msup></mrow></x:template> <x:template match="m:cn[@type=\'e-notation\']"><mn><x:apply-templates select="m:sep/preceding-sibling::node()"/><x:text>E</x:text><x:apply-templates select="m:sep/following-sibling::node()"/></mn></x:template> <x:template match="m:cn[@type=\'hexdouble\']"><mn><x:text>0x</x:text><x:apply-templates/></mn></x:template> <x:template match="m:ci/text()"><mi><x:value-of select="."/></mi></x:template> <x:template match="m:ci"><mrow><x:apply-templates/></mrow></x:template> <x:template match="m:csymbol/text()"><mi><x:value-of select="."/></mi></x:template> <x:template match="m:csymbol"><mrow><x:apply-templates/></mrow></x:template> <x:template match="m:apply|m:reln"><mrow><x:choose><x:when test="*[1]/*/*"><mfenced separators=""> <x:apply-templates select="*[1]"> <x:with-param name="p" select="10"/> </x:apply-templates></mfenced></x:when><x:otherwise><x:apply-templates select="*[1]"> <x:with-param name="p" select="10"/></x:apply-templates></x:otherwise></x:choose><mo>&#8289;</mo><mfenced open="(" close=")" separators=","><x:apply-templates select="*[position()>1]"/></mfenced></mrow></x:template> <x:template match="m:bind"><mrow><x:choose><x:when test="*[1]/*/*"><mfenced separ