Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jupyterlite doesn't have print option #543

Open
NAbdolkhani opened this issue Mar 9, 2022 · 9 comments
Open

jupyterlite doesn't have print option #543

NAbdolkhani opened this issue Mar 9, 2022 · 9 comments

Comments

@NAbdolkhani
Copy link

In this new interface, the print option is gone and there is no way to save the notebook as pdf. Is there an alternative? or can't you just bring the print option back?

@bollwyvl
Copy link
Collaborator

bollwyvl commented Mar 9, 2022

just bring the print option back?

The print feature upstream relies on server-side nbconvert to generate the "dead pixels" HTML.

To get to something better we have a few options:

  • run nbconvert in python in the browser
    • this would probably be the most faithful to the existing experience, and might support plugins, etc.
    • at present nbconvert cannot be installed directly, due to a missing tornado and pyzmq
      • we could potentially shim these... or provide a patched nbconvert
    • we've been trying to avoid requiring any heavy-duty wasm inside the server component
  • re-implement some subset of nbconvert in JS
    • this would probably be the most performant
    • theoretically, we could pack all of the jinja templates from nbconvert and use nunjucks, but...
  • work with more directly with in-app HTML
    • this would potentially be interesting, as it might handle a broader swathe of outputs (canvas, etc.)

@pierrepo
Copy link
Contributor

pierrepo commented Mar 11, 2022

Dear @bollwyvl I had a similar issue while trying to export a notebook as html. If I understand correctly your previous answer, this is also because nbconvert (or any substitute) is not (yet) available in jupyterlite. Am I correct?

@bollwyvl
Copy link
Collaborator

bollwyvl commented Mar 12, 2022 via email

@bollwyvl
Copy link
Collaborator

nbconvert (with mad hacks) is now (somewhat) available in (a soon-to-be-released) jupyterlite.

#756 (comment)

@sean-morris
Copy link

@bollwyvl I am hung up on the "somewhat" available part. From the link above, it appears that v0.1.0b12 includes the ability to print a notebook to a pdf. I working with this version.

The example from this gist is pretty intense. Is the implication that you need to run through the commands on the page referenced to create a context for converting and downloading a notebook to a PDF?

I have moved through the gist but ran into issues right at the end of the process. The HTMLExporter in nbconvert has been moved for one, that was not a big deal -- nbconvert.exporters.HTMLExporter -- but the second involves a problem with bleach not having the attribute ALLOWED_STYLES defined. The error suggests upgrading bleach to 5 or greater. But this did not work.

I am able to read in the notebook which is great -- I just need the last step!

Am I missing something here?

@bollwyvl
Copy link
Collaborator

bollwyvl commented May 9, 2023 via email

@sean-morris
Copy link

Ok, I am with you. I will look into an extension. Thanks that helps a lot.

@westurner
Copy link

westurner commented Jul 28, 2023

Is there any reason nbconvert cannot be compiled into a jupyterlite build (w/ emscripten)?

When I:

@westurner
Copy link

westurner commented Jul 28, 2023

nbconvert (with mad hacks) is now (somewhat) available in (a soon-to-be-released) jupyterlite.

#756 (comment)
[...]

"Running nbconvert inside JupyterLite"
https://gist.github.com/bollwyvl/6b3cb4c46b1764c6d9ae1e5831f86d7a#file-nbconvert-in-jupyterlite-ipynb

Future Work

  • explore packaging this technique for JupyterLite
    • by creating a custom JupyterLite addon, it would be possible to fire up a kernel and service the expected JupyterLab UI components
    • do a better shim of nbclient
      • this could use JupyterLite machinery to actually run kernels
    • further simplify the nbconvert API
      • nbclient could be an optional, or at least not catastrophically-failing dependency

BUG,404: JupyterLite: File > Print does not print nbconvert'ed notebooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants