njpipeorgan / wolfram-language-notebook

Notebook support for Wolfram Language in VS Code
Apache License 2.0
162 stars 12 forks source link

Enable rendering a pdf (for instance with pandoc) #11

Closed sm1090 closed 2 years ago

sm1090 commented 2 years ago

Hi !

I am really impressed by this really nice piece of software. It does much better than the jupyter notebook on my computer running Linux.

A real issue though is that I cannot share my notebook. It would be really nice to add pdf printing capabilities. I tried several extensions to print the notebook with no success until now.

Thank you very much for your work !

njpipeorgan commented 2 years ago

Thanks for the feedback! I will look for a solution (and check pandoc).

njpipeorgan commented 2 years ago

It seems that there is no easy way of exporting the notebook directly from the extension alone, because the extension cannot easily read the content of all cell outputs. But a workaround is to export to a Wolfram notebook and then to a PDF, which will be supported in the next version.

If you want to do that right now without a front end, export to a Wolfram notebook first and then in the kernel: Export["a.pdf",Import["a.nb"],"PDF"]

sm1090 commented 2 years ago

Hi.

Thanks for your help.

Indeed, your solution would be perfect as it would be quite flexible. The Export[] function also exports in TeX format which is even better for what I would do (and pandoc would also work with a TeX format).

Unfortunately, I found two issues when I tried your method: -- The equations in the markdown cells are not rendered correctly. -- End of lines in the code cells are not taken into account.

I believe this could be caused by a bug in the exported .nb file, as wolframplayer crashes when trying to open this file on my computer.

I uploaded a simple example showing the problem on gofile.io

Many thanks again, and congratulations for your work.

njpipeorgan commented 2 years ago

Thanks. I will investigate these issues and get back to you.

njpipeorgan commented 2 years ago

The equations within markdown are rendered in notebooks now, and expressions in each input cell should be correctly separated. Please checkout the newest vsix (needs to be install manually). Let me know if you encounter any other issue.

sm1090 commented 2 years ago

Hi !

Very good job in such a short delay (moreover on a weekend): I just gave it a try and it seems to work well. I'll keep on testing it and I will give you my feedback.

Congratulations for your work and many thanks for sharing it !