From f124f9da201060e6fbc332e898a9a3c308ce2c4b Mon Sep 17 00:00:00 2001 From: Christian Perfect Date: Fri, 25 Apr 2014 13:48:44 +0100 Subject: [PATCH] some more fiddling with bracketing 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. --- ctop.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ctop.js b/ctop.js index ee09627..80a6731 100644 --- a/ctop.js +++ b/ctop.js @@ -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,'(',')')); @@ -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),