version 1.1, 2005/12/07 18:57:49
|
version 1.3, 2006/05/17 22:19:38
|
Line 1
|
Line 1
|
/* |
/* |
|
* mimeTeX.js |
|
* |
|
* Part of the jsMath package for mathematics on the web. |
|
* |
|
* This file makes jsMath more compatible with the mimeTeX program. |
|
* It does not make everything work, but it goes a long way. |
|
* |
|
* --------------------------------------------------------------------- |
|
* |
|
* Copyright 2004-2006 by Davide P. Cervone |
|
* |
|
* 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. |
|
*/ |
|
|
|
|
|
/* |
* Treat ~ as space |
* Treat ~ as space |
*/ |
*/ |
jsMath.Parser.prototype.nextIsSpace = function () { |
jsMath.Parser.prototype.nextIsSpace = function () { |
Line 155 jsMath.Package(jsMath.Parser,{
|
Line 181 jsMath.Package(jsMath.Parser,{
|
} |
} |
columns = columns.replace(/[^clr]/g,''); |
columns = columns.replace(/[^clr]/g,''); |
columns = columns.split(''); |
columns = columns.split(''); |
var data = this.mlist.data; |
var data = this.mlist.data; var style = delim[5] || 'T'; |
var arg = this.GetEnd(name); if (this.error) return; |
var arg = this.GetEnd(name); if (this.error) return; |
if (arg.match(/\$/)) {arg = arg.replace(/^([^$]*)\$/,''); columns = RegExp.$1} |
if (arg.match(/\$/)) {arg = arg.replace(/^([^$]*)\$/,''); columns = RegExp.$1} |
var parse = new jsMath.Parser(arg+'\\\\',null,data.size); |
var parse = new jsMath.Parser(arg+this.cmd+'\\',null,data.size,style); |
parse.matrix = name; parse.row = []; parse.table = []; |
parse.matrix = name; parse.row = []; parse.table = []; parse.rspacing = []; |
parse.Parse(); if (parse.error) {this.Error(parse); return} |
parse.Parse(); if (parse.error) {this.Error(parse); return} |
parse.HandleRow(name,1); // be sure the last row is recorded |
parse.HandleRow(name,1); // be sure the last row is recorded |
var box = jsMath.Box.Layout(data.size,parse.table,columns,cspacing); |
var box = jsMath.Box.Layout(data.size,parse.table,columns,cspacing,parse.rspacing,delim[4]||null); |
// Add parentheses, if needed |
// Add parentheses, if needed |
if (delim[0] && delim[1]) { |
if (delim[0] && delim[1]) { |
var left = jsMath.Box.Delimiter(box.h+box.d,this.delimiter[delim[0]],'T'); |
var left = jsMath.Box.Delimiter(box.h+box.d-jsMath.hd/4,this.delimiter[delim[0]],'T'); |
var right = jsMath.Box.Delimiter(box.h+box.d,this.delimiter[delim[1]],'T'); |
var right = jsMath.Box.Delimiter(box.h+box.d-jsMath.hd/4,this.delimiter[delim[1]],'T'); |
box = jsMath.Box.SetList([left,box,right],data.style,data.size); |
box = jsMath.Box.SetList([left,box,right],data.style,data.size); |
} |
} |
this.mlist.Add(jsMath.mItem.Atom((delim[0]? 'inner': 'ord'),box)); |
this.mlist.Add(jsMath.mItem.Atom((delim[0]? 'inner': 'ord'),box)); |
Line 179 jsMath.Package(jsMath.Parser,{
|
Line 205 jsMath.Package(jsMath.Parser,{
|
var data = this.mlist.data; |
var data = this.mlist.data; |
var arg = this.GetArgument(this.cmd+name); if (this.error) return; |
var arg = this.GetArgument(this.cmd+name); if (this.error) return; |
if (arg.match(/\$/)) {arg = arg.replace(/^([^$]*)\$/,''); delim[2] = RegExp.$1} |
if (arg.match(/\$/)) {arg = arg.replace(/^([^$]*)\$/,''); delim[2] = RegExp.$1} |
var parse = new jsMath.Parser(arg+'\\\\',null,data.size); |
var parse = new jsMath.Parser(arg+this.cmd+'\\',null,data.size,delim[5] || 'T'); |
parse.matrix = name; parse.row = []; parse.table = []; |
parse.matrix = name; parse.row = []; parse.table = []; parse.rspacing = []; |
parse.Parse(); if (parse.error) {this.Error(parse); return} |
parse.Parse(); if (parse.error) {this.Error(parse); return} |
parse.HandleRow(name,1); // be sure the last row is recorded |
parse.HandleRow(name,1); // be sure the last row is recorded |
var box = jsMath.Box.Layout(data.size,parse.table,delim[2]); |
var box = jsMath.Box.Layout(data.size,parse.table,delim[2]||null,delim[3]||null,parse.rspacing,delim[4]||null); |
// Add parentheses, if needed |
// Add parentheses, if needed |
if (delim[0] && delim[1]) { |
if (delim[0] && delim[1]) { |
var left = jsMath.Box.Delimiter(box.h+box.d,this.delimiter[delim[0]],'T'); |
var left = jsMath.Box.Delimiter(box.h+box.d-jsMath.hd/4,this.delimiter[delim[0]],'T'); |
var right = jsMath.Box.Delimiter(box.h+box.d,this.delimiter[delim[1]],'T'); |
var right = jsMath.Box.Delimiter(box.h+box.d-jsMath.hd/4,this.delimiter[delim[1]],'T'); |
box = jsMath.Box.SetList([left,box,right],data.style,data.size); |
box = jsMath.Box.SetList([left,box,right],data.style,data.size); |
} |
} |
this.mlist.Add(jsMath.mItem.Atom((delim[0]? 'inner': 'ord'),box)); |
this.mlist.Add(jsMath.mItem.Atom((delim[0]? 'inner': 'ord'),box)); |
} |
} |
}); |
|
|
|
|
}); |