JerryI / wolfram-js-frontend

Dynamic Notebook Environment for Wolfram Language written in Javascript
https://jerryi.github.io/wljs-docs/
GNU General Public License v3.0
306 stars 13 forks source link

Rubi support is not good #250

Open asukaminato0721 opened 3 months ago

asukaminato0721 commented 3 months ago

Describe the bug

it show the output messy.

To Reproduce

install the Rubi package https://rulebasedintegration.org/downloadRubi.html

<<Rubi`
Steps[Int[x^2,x]]

and

Steps[Int[2/(2 Sin[t] Cos[t] + 5 Cos[t]^2 + Sin[t]^2) ,t],RubiPrintInformation->False]

Expected behavior

https://rulebasedintegration.org/usingRubi.html

Screenshots

image

image

Desktop (please complete the following information):

JerryI commented 2 months ago

Actually it is not that complicated to rewrite boxes for it. The original code heavily relies on ItemBox, DynamicModule, which are not available for now in WLJS Notebook system (but may be in the future, nobody knows ;D ).

I just tried to put some random style and pane boxes on RubyRule and RubyResult, but what Dist, Subst mean... still a question. It must be some sort of rules from algebra used for demonstrating this or that strategy on taking those integrals

Screenshot 2024-08-28 at 13 24 50
JerryI commented 2 months ago

Sorry, I am blind and did not find this on the main page

image

At least stats are working out of the box

Screenshot 2024-08-28 at 13 30 48
JerryI commented 2 months ago

From now on I see two paths

a. pay enough attention on implementation of ItemBox, make it work without workarounds b. add separate sub-package like Ruby`WLJSFormFixes, which will rewrite the implementations of StandardForm

and as a side branch

JerryI commented 2 months ago

A workaround solution

stripHoldBox[h_, f_] := With[{e = Extract[h, 1, HoldForm]},
  MakeBoxes[e, f]
]

fatArrow = HTMLView["<div style=\"align-items: center;height: 1rem;margin-top: -2rem;position: absolute;font-size: 1.5rem;top: 0;bottom: 0;\">&xrarr;</div>"];

RubiRule /: MakeBoxes[RubiRule[_, right_, left_, ___], f:StandardForm] := With[{fatArrow=fatArrow},
  BoxBox[RowBox[{stripHoldBox[right, f], " ", MakeBoxes[fatArrow, f], "    ", stripHoldBox[right, f]}], PaneBox[]]
]

RubiIntermediateResult /: MakeBoxes[RubiIntermediateResult[result_, u___], f:StandardForm] := With[{},
  BoxBox[stripHoldBox[result, f], PaneBox[]]
]
JerryI commented 1 month ago

Present state

Steps[Int[2/(2 Sin[t] Cos[t] + 5 Cos[t]^2 + Sin[t]^2) ,t],RubiPrintInformation->False]
Screenshot 2024-09-13 at 22 20 47

Without RubiPrintInformation->False it will not work correctly. OpenerBox, ItemBox, DynamicModuleBox are not implemented, and it messes up a printed output.