commit efbc1612f3677b39970398704f073c8d669304b9
parent 58d876b417a998fe44bba4a19ee8c175218d1344
Author: Davide P. Cervone <dpvc@union.edu>
Date: Sat, 10 Sep 2011 19:29:29 -0400
Add support for extpfeil extension -- more stretchy arrows (resolves issue #93)
Diffstat:
2 files changed, 100 insertions(+), 0 deletions(-)
diff --git a/extensions/TeX/extpfeil.js b/extensions/TeX/extpfeil.js
@@ -0,0 +1,16 @@
+/*
+ * /MathJax/extensions/TeX/extpfeil.js
+ *
+ * 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;
+ * you may not use this file except in compliance with the License.
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+
+MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){var b="1.1";var c=MathJax.InputJax.TeX,a=c.Definitions;MathJax.Hub.Insert(a,{macros:{xtwoheadrightarrow:["Extension","AMSmath"],xtwoheadleftarrow:["Extension","AMSmath"],xmapsto:["Extension","AMSmath"],xlongequal:["Extension","AMSmath"],xtofrom:["Extension","AMSmath"],Newextarrow:["Extension","AMSmath"]}});MathJax.Hub.Register.StartupHook("TeX AMSmath Ready",function(){MathJax.Hub.Insert(a,{macros:{xtwoheadrightarrow:["xArrow",8608,12,16],xtwoheadleftarrow:["xArrow",8606,17,13],xmapsto:["xArrow",8614,6,7],xlongequal:["xArrow",61,7,7],xtofrom:["xArrow",8644,12,12],Newextarrow:"NewExtArrow"}})});c.Parse.Augment({NewExtArrow:function(d){var f=this.GetArgument(d),g=this.GetArgument(d),e=this.GetArgument(d);if(!f.match(/^\\([a-z]+|.)$/i)){c.Error("First argument to "+d+" must be a control sequence name")}if(!g.match(/^(\d+),(\d+)$/)){c.Error("Second argument to "+d+" must be two integers separated by a comma")}if(!e.match(/^(\d+|0x[0-9A-F]+)$/i)){c.Error("Third argument to "+d+" must be a unicode character number")}f=f.substr(1);g=g.split(",");e=parseInt(e);a.macros[f]=["xArrow",e,parseInt(g[0]),parseInt(g[1])]}});MathJax.Hub.Startup.signal.Post("TeX extpfeil Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/extpfeil.js");
+
diff --git a/unpacked/extensions/TeX/extpfeil.js b/unpacked/extensions/TeX/extpfeil.js
@@ -0,0 +1,84 @@
+/*************************************************************
+ *
+ * MathJax/extensions/TeX/extpfeil.js
+ *
+ * Implements additional stretchy arrow macros.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2011 Design Science, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
+ var VERSION = "1.1";
+
+ var TEX = MathJax.InputJax.TeX,
+ TEXDEF = TEX.Definitions;
+
+ //
+ // Define the arrows to load the AMSmath extension
+ // (since they need its xArrow method)
+ //
+ MathJax.Hub.Insert(TEXDEF,{
+ macros: {
+ xtwoheadrightarrow: ['Extension','AMSmath'],
+ xtwoheadleftarrow: ['Extension','AMSmath'],
+ xmapsto: ['Extension','AMSmath'],
+ xlongequal: ['Extension','AMSmath'],
+ xtofrom: ['Extension','AMSmath'],
+ Newextarrow: ['Extension','AMSmath']
+ }
+ });
+
+ //
+ // Redefine the macros when AMSmath is loaded
+ //
+ MathJax.Hub.Register.StartupHook("TeX AMSmath Ready",function () {
+ MathJax.Hub.Insert(TEXDEF,{
+ macros: {
+ xtwoheadrightarrow: ['xArrow',0x21A0,12,16],
+ xtwoheadleftarrow: ['xArrow',0x219E,17,13],
+ xmapsto: ['xArrow',0x21A6,6,7],
+ xlongequal: ['xArrow',0x003D,7,7],
+ xtofrom: ['xArrow',0x21C4,12,12],
+ Newextarrow: 'NewExtArrow'
+ }
+ });
+ });
+
+ //
+ // Implements \Newextarrow to define a new arrow (not compatible with \newextarrow, but
+ // the equivalent for MathJax)
+ //
+ TEX.Parse.Augment({
+ NewExtArrow: function (name) {
+ var cs = this.GetArgument(name),
+ space = this.GetArgument(name),
+ chr = this.GetArgument(name);
+ if (!cs.match(/^\\([a-z]+|.)$/i))
+ {TEX.Error("First argument to "+name+" must be a control sequence name")}
+ if (!space.match(/^(\d+),(\d+)$/))
+ {TEX.Error("Second argument to "+name+" must be two integers separated by a comma")}
+ if (!chr.match(/^(\d+|0x[0-9A-F]+)$/i))
+ {TEX.Error("Third argument to "+name+" must be a unicode character number")}
+ cs = cs.substr(1); space = space.split(","); chr = parseInt(chr);
+ TEXDEF.macros[cs] = ['xArrow',chr,parseInt(space[0]),parseInt(space[1])];
+ }
+ });
+
+ MathJax.Hub.Startup.signal.Post("TeX extpfeil Ready");
+});
+
+MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/extpfeil.js");