@@ -382,12 +382,13 @@ function createMmlNode(t,frag) {
382
382
}
383
383
384
384
function newcommand ( oldstr , newstr ) {
385
- AMsymbols = AMsymbols . concat ( [ { input :oldstr , tag :"mo" , output :newstr ,
386
- tex :null , ttype :DEFINITION } ] ) ;
387
- // #### Added from Version 2.0.1 #### //
388
- AMsymbols . sort ( compareNames ) ;
389
- for ( i = 0 ; i < AMsymbols . length ; i ++ ) AMnames [ i ] = AMsymbols [ i ] . input ;
390
- // #### End of Addition #### //
385
+ AMsymbols . push ( { input :oldstr , tag :"mo" , output :newstr , tex :null , ttype :DEFINITION } ) ;
386
+ refreshSymbols ( ) ;
387
+ }
388
+
389
+ function newsymbol ( symbolobj ) {
390
+ AMsymbols . push ( symbolobj ) ;
391
+ refreshSymbols ( ) ;
391
392
}
392
393
393
394
// character lists for Mozilla/Netscape fonts
@@ -666,14 +667,15 @@ function compareNames(s1,s2) {
666
667
var AMnames = [ ] ; //list of input symbols
667
668
668
669
function initSymbols ( ) {
669
- var texsymbols = [ ] , i ;
670
- for ( i = 0 ; i < AMsymbols . length ; i ++ )
670
+ var i ;
671
+ var symlen = AMsymbols . length ;
672
+ for ( i = 0 ; i < symlen ; i ++ ) {
671
673
if ( AMsymbols [ i ] . tex ) {
672
- texsymbols [ texsymbols . length ] = { input :AMsymbols [ i ] . tex ,
674
+ AMsymbols . push ( { input :AMsymbols [ i ] . tex ,
673
675
tag :AMsymbols [ i ] . tag , output :AMsymbols [ i ] . output , ttype :AMsymbols [ i ] . ttype ,
674
- acc :( AMsymbols [ i ] . acc || false ) } ;
676
+ acc :( AMsymbols [ i ] . acc || false ) } ) ;
675
677
}
676
- AMsymbols = AMsymbols . concat ( texsymbols ) ;
678
+ }
677
679
refreshSymbols ( ) ;
678
680
}
679
681
@@ -684,8 +686,7 @@ function refreshSymbols(){
684
686
}
685
687
686
688
function define ( oldstr , newstr ) {
687
- AMsymbols = AMsymbols . concat ( [ { input :oldstr , tag :"mo" , output :newstr ,
688
- tex :null , ttype :DEFINITION } ] ) ;
689
+ AMsymbols . push ( { input :oldstr , tag :"mo" , output :newstr , tex :null , ttype :DEFINITION } ) ;
689
690
refreshSymbols ( ) ; // this may be a problem if many symbols are defined!
690
691
}
691
692
@@ -1316,6 +1317,7 @@ else if(typeof window.attachEvent != 'undefined'){
1316
1317
1317
1318
//expose some functions to outside
1318
1319
asciimath.newcommand = newcommand;
1320
+ asciimath.newsymbol = newsymbol;
1319
1321
asciimath.AMprocesssNode = AMprocessNode;
1320
1322
asciimath.parseMath = parseMath;
1321
1323
asciimath.translate = translate;
@@ -1409,6 +1411,7 @@ ASCIIMATH.Augment({
1409
1411
1410
1412
define : define ,
1411
1413
newcommand : newcommand ,
1414
+ newsymbol : newsymbol ,
1412
1415
symbols : AMsymbols ,
1413
1416
names : AMnames ,
1414
1417
0 commit comments