Skip to content

Commit

Permalink
some more fiddling with bracketing
Browse files Browse the repository at this point in the history
bracket single arguments of functions unless the surrounding precedence is <2, i.e. not +, - or *.

An attempt at getting function composition to bracket correctly (see #32). This touches the generic function application code, so it might break something else.
  • Loading branch information
christianp committed Apr 25, 2014
1 parent 0d99272 commit f124f9d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ctop.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,12 @@ var CToP = {
return function(parentNode,contentMMLNode,firstArg,args,bvars,qualifiers,precedence) {
var mrow = CToP.createElement('mrow');
if(firstArg.childNodes.length){
CToP.applyTransform(mrow,firstArg,0);
CToP.applyTransform(mrow,firstArg,1);
} else {
CToP.appendToken(mrow,'mi',name);
}
CToP.appendToken(mrow,'mo','\u2061');
if(args.length==1 && !(args[0].localName=='apply' || args[0].localName=='reln' || args[0].localName=='bind')) {
if(precedence<2 && args.length==1 && !(args[0].localName=='apply' || args[0].localName=='reln' || args[0].localName=='bind')) {
CToP.applyTransform(mrow,args[0],precedence);
} else {
mrow.appendChild(CToP.mfenced(args,'(',')'));
Expand Down Expand Up @@ -761,7 +761,7 @@ CToP.applyTokens = {
"notprsubset": CToP.binary('\u2284',2),
"setdiff": CToP.binary('\u2216',2),
"eq": CToP.infix('=',1),
"compose": CToP.infix('\u2218',1),
"compose": CToP.infix('\u2218',0),
"left_compose": CToP.infix('\u2218',1),
"xor": CToP.infix('xor',3),
"neq": CToP.infix('\u2260',1),
Expand Down

0 comments on commit f124f9d

Please sign in to comment.