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
295 stars 13 forks source link

Is there any way to convert .nb files to .wln files? #70

Closed LoganJFisher closed 1 month ago

LoganJFisher commented 9 months ago

I tried starting a .nb file, but it wouldn't run. A .wln file with the same name was automatically created, but it doesn't seem to actually work. I'm not sure if I perhaps did something wrong.

JerryI commented 9 months ago

This is correct behaviour. The feature of an automatic conversion is still in development, we just have started it recently.

userrand commented 9 months ago

This is correct behaviour. The feature of an automatic conversion is still in development, we just have started it recently.

I am guessing that would be similar to the question of converting mathematica notebooks to jupyter like here (answers did not work for me) https://mathematica.stackexchange.com/questions/200693/how-to-export-a-notebook-to-jupyter ? There is a github repository that, like the answers in the previous link, uses mathematica to convert a .nb file to a jupyter file but I am not sure anymore whether or not I tried it (and if I did it not work) https://github.com/oovm/JupyterConvert/blob/master/Kernel/Notebook2Jupyter.m

I only managed to make something that kind of works starting with the mathematica frontend (I think my solution was similar to the first answer there, maybe basically the same ).

Even using the wolfram frontend it still did not completely work for all inputs . I think there was quite a range of possible scenarios to consider (2d inputs, comments, heading cells, maybe code cells, deeply nested grouped cells).

If you see a way to get a converter to extract all of the scenarios of inputs* in a reasonable amount of time, I can maybe offer some help in making a .nb to jupyter converter. Then from there a converter to .wln might be fairly easy.

*outputs might be too hard for me with considerations like network graphs,images,dynamic objects

LoganJFisher commented 9 months ago

I'd like to request that once a .nb to .wln converter is made, if the process is reversible then I'd value the ability to save-as to .nb format to make it easier to share a file with someone who is using Mathematica.

JerryI commented 4 months ago

Experimental support of .nb files as well as .md was added in a new release.

I-am-Rudi commented 1 month ago

I have been trying out the experimental feature but the only thing I get is several warnings and a black notebook window without any cells or the ability to add anything.

The warnings are: ToExpression::esntx, Syntax::tsntxi, Syntax::sntxf and Syntax::sntxi.

Is this expected behavior as the feature is still in development, or is something missing on my end?

Note: I am using the binary wolfram-js-frontend-bin from the AUR. It was last updated on the 8th of August 2024.

JerryI commented 1 month ago

I have been trying out the experimental feature but the only thing I get is several warnings and a black notebook window without any cells or the ability to add anything.

The warnings are: ToExpression::esntx, Syntax::tsntxi, Syntax::sntxf and Syntax::sntxi.

Is this expected behavior as the feature is still in development, or is something missing on my end?

Note: I am using the binary wolfram-js-frontend-bin from the AUR. It was last updated on the 8th of August 2024.

Yes. It is still buggy and depends on the notebook (and luck probably:)), some cell types are really painful to convert.

I can try to debug the problem using the notebook you tried to open.

I-am-Rudi commented 1 month ago

This actually happened for several different notebooks.

Here are some simpler ones I used for testing:

https://web.physics.ucsb.edu/~gravitybook/math/christoffel.nb https://web.physics.ucsb.edu/~gravitybook/math/frw.nb https://web.physics.ucsb.edu/~gravitybook/math/curvature.nb https://web.physics.ucsb.edu/~gravitybook/math/schorbits.nb

One of the other notebooks that I can not share (part of ongoing research) includes cells that can be hidden/shown via a button. I suppose that might also be difficult in conversion.

Also thanks for the work you are doing here, making WL freely accessible in notebooks will be great for science. Especially this feature of converting .nb to .wl will be very important for people to adopt this. If there is any way one can support this project I would be happy to do so.

JerryI commented 1 month ago

Also thanks for the work you are doing here, making WL freely accessible in notebooks will be great for science. Especially this feature of converting .nb to .wl will be very important for people to adopt this.

This was the initial motivation for some small steps towards WLJS Notebook 5-6 years ago. It is originated from being unable to share a work with a college, who did not have Mathematica / Internet, then HTML format worked quite well.

We are glad to hear your feedback on our project.

If there is any way one can support this project I would be happy to do so.

If you are good at Javascript / Wolfram Language, please see Contribution.md section. :)

One of the other notebooks that I can not share (part of ongoing research) includes cells that can be hidden/shown via a button. I suppose that might also be difficult in conversion.

Now it looks it works more of less, at least it imported those 4 notebooks Screenshot 2024-09-06 at 15 00 20

We will roll out this updated importer in a new version soon.

I-am-Rudi commented 3 weeks ago

I finally managed to try out the new update. Works like a charm even for the notebook I wasn't able to provide.

Thank you very much.