From 36dbf9c2569b2dfeb1c1673b564d968cc3cec3f1 Mon Sep 17 00:00:00 2001 From: Christian Perfect Date: Fri, 2 May 2014 12:15:23 +0100 Subject: [PATCH] Clean up partialdiff; put complicated differends (?) to the right of the fraction see #8 --- ctop.js | 206 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 130 insertions(+), 76 deletions(-) diff --git a/ctop.js b/ctop.js index 77544f0..6b56f5a 100644 --- a/ctop.js +++ b/ctop.js @@ -1286,68 +1286,103 @@ CToP.applyTokens["root"] = function(parentNode,contentMMLNode,firstArg,args,bvar } CToP.applyTokens["diff"] = function(parentNode,contentMMLNode,firstArg,args,bvars,qualifiers,precedence) { - var m; - var mrow1 = CToP.createElement('mrow'); - if(bvars.length){ - m = CToP.createElement('mfrac'); - var msup, bvar; - var mi = CToP.createElement('mi'); - mi.textContent = 'd'; + if(bvars.length){ // d/dx form + var outNode; + var mfrac = CToP.createElement('mfrac'); + var toprow = CToP.createElement('mrow'); + var bottomrow = CToP.createElement('mrow'); + mfrac.appendChild(toprow); + mfrac.appendChild(bottomrow); + + var bvar; + var degreeNode; + + var d = CToP.createElement('mi'); + d.textContent = 'd'; + var children = CToP.children(bvars[0]); for(var j=0;j1) { var msup = CToP.createElement('msup'); CToP.applyTransform(msup,bvar,0); CToP.appendToken(msup,'mn',degree); - mrow.appendChild(msup); + bottomrow.appendChild(msup); } else { - CToP.applyTransform(mrow,bvar,0); + CToP.applyTransform(bottomrow,bvar,0); } } for(var i=0;i0){ if(hadFirst){ - CToP.appendToken(mrow,'mo','+'); + CToP.appendToken(degreeRow,'mo','+'); } - CToP.appendToken(mrow,'mn',degree); + CToP.appendToken(degreeRow,'mn',degree); } } - msup.appendChild(mrow); - mrow = CToP.createElement('mrow'); - mrow.appendChild(msup); + if(args.length){ - CToP.applyTransform(mrow,args[0],0); + differendNode = args[0]; } - m.appendChild(mrow); - mrow = CToP.createElement('mrow'); + for(var i=0;i