-
Notifications
You must be signed in to change notification settings - Fork 650
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
Export notebooks to docx, and epub #229
Comments
This sounds like a very interesting addition that I'd love to see. |
PDF printing is now in the master branch of jupyter book! updating this issue accordingly |
Hey, are there any plans/existing functionality for downloading the whole book as a PDF (as opposed to individual pages)? I feel like it would make it possible for students to write their Masters/PhD theses in Jupyter Books, which would be amazing. |
@NatalieThurlby definitely a goal for this project, just a matter of hours in the day :-) |
Being able to download the whole book as a single (PDF) document would be really great! Is there maybe another way to create a PDF for a whole project while building the HTML pages? I.e. not necessary having a download button but a precompiled PDF file which can be distributed otherwise. |
Can I add LaTeX export to the list? That'd be really cool for writing publications! |
done! |
@choldgraf if you point me in the direction where the download button calls its actual commands, I can have a crack at this over the holidays as some hobby-programming. If it's just |
The trickiest thing is that right now the "download" button will only do one of the following two things:
Supporting latex would require supporting the idea of a static file that is generated along with each page, I don't think it could be done on the client side (as the PrintJS library does). That might be a little bit tricky, but doable. It may just take a bit extra work to figure out the right pattern to follow there |
Hi @choldgraf , has this feature, exporting all pages to a pdf, been done? If not, is there any plan or update? |
Nope, not yet - it is partially on-hold pending some broader refactoring of the project (with the goal of making things like PDF output easier)...but it is still on the radar, just unsure how long it'll take to be implemented. |
@choldgraf I have some time to look into this now. You mentioned:
I think this shouldn't be too tricky. We could use either pandoc (for non-notebook files) or nbconvert (for notebooks); both of which have python interfaces. See here for pandoc. Nbconvert is already used anyway... I just forked the code and am looking through it. I think this needs to happen somewhere in the |
@pgierz thanks for offering to look into this! We are actually in the process of working on a backend-switch for jupyter book, and this might make it easier to output different kinds of formats. We are building off of a tool called Sphinx, which is kind of like Pandoc but written in Python. If you're interested, the docs for the new version are here: https://beta.jupyterbook.org/intro.html and more general information about the project is here: https://ebp.jupyterbook.org/en/latest/ I'm happy to step you through the new codebase and explain stuff if you'd like! I think that enhancements to Jupyter Book will be more impactful if they are on the new tool-chain. |
Hi @choldgraf, I'm familiar with Sphinx already (at least a little bit). I'll download the new code and poke around a little bit. Can I let you know if I get stuck or have any questions? |
So, I was able to make some progress!
WIDGET_VIEW_MIMETYPE = "application/vnd.jupyter.widget-view+json"
RENDER_PRIORITY = {
"html": [
WIDGET_VIEW_MIMETYPE,
"application/javascript",
"text/html",
"image/svg+xml",
"image/png",
"image/jpeg",
"text/latex",
"text/plain",
],
"latex": ["text/latex", "text/plain"],
# PG: Not sure about this...
"docx": ["text/plain"]
}
RENDER_PRIORITY["readthedocs"] = RENDER_PRIORITY["html"] However, now I'm running into errors:
I guess this comes out of the docx-converter but maybe my changes for I've forked everything and will check all the changes into branches labeled |
Also, maybe this issue should move somewhere to the ExecutableBookProject repos so the discussion is a bit clearer... |
Wow, thanks very much for the quick push on this! I agree we should add this to the MyST-NB repository for now so we can track progress (or maybe jupyter-sphinx, but let's start w/ myst-nb). There is also another team of folks who will work on a first-class latex -> pdf builder as well. As you mention, myst-nb is definitely still in a formative stage, there is much to be done! Wanna open an issue about DOCX in myst-nb and paste in your comments above? |
OK, done! :-) |
+1 for EPUB support! Now am trying to figure out what is meant by "book": So, how is I understand that you're in beta, so I'm not trying to diminish from your hard work at all; I'm very honestly just not "getting" it and I want to. Thanks. |
in fact Jupyter Book used to use Jekyll :-) mostly we're defining book as "a way of packaging multiple [notebooks/md files/etc] together in a bundle" with the goal of outputting many kinds of bundles. Fastpages is also great - though I think of it more as a quick way to have a blog, as opposed to a book. Major differences with Jupyter Book (other than obvious things like design), would be more "book-like" features such as cross-references, citations, figures, injecting notebook outputs into pages, etc. And yes, one day we want to support more outputs like EPUB and docx |
Thanks for the clarification @choldgraf ! |
Last night I spent some time looking into pandoc's EPUB support and softcover.io's build pipeline. Probably you already know all this, but what I found was:
^My attempts to resolve that were unsuccessful, despite spending time perusing related issues on TeX StackExchange.
So...I'm sure if these things had worked you would have done them already. Just noting what a few of the barriers might be to 'easy' fulfillment of this feature request. |
Thanks for looking into all that, and for reporting back! I believe that Sphinx also has its own EPUB builder that we might be able to piggy-back off of (since Jupyter Book now uses Sphinx under the hood). I'm not familiar with it but I know that readthedocs has some of this functionality which uses Sphinx too. E.g.: https://www.sphinx-doc.org/en/master/faq.html?highlight=epub#epub-info |
Potential Quick Win PathsStackOverflow seems to have potential directions for getting what you need:
The top solution uses the I haven't tested The official Sphinx docs also point to rinohtype as a potential alternative to the latex-backend for generating PDFs from Sphinx projects. A More Complicated PathI have used Sphinx to build PDFs of the SaltStack documentation. Sphinx does also have the ability to export EPUB, but I do not have experience with it. It does need to be generated from source, much like one generates the HTML (
Much of the source is private, other than what you can see with
Though, this did mean needing to get containers involved that brought in all the LaTeX requirements beforehand, and for the CI jobs to pull the containers down. They are part of the build pipelines and make life easy, though it then complicates the build process for newcomers and for new projects working to mimic the functionality. Not sure if starting with something like https://hub.docker.com/r/tk0miya/sphinx-pdf could make things easier or not?
Since EPB / Jupyter Book is going the Sphinx route, it does also mean that if anyone is using readthedocs.io for hosting their Sphinx output, they include pipeline jobs to help autocreate PDFs and ePUBs of the docs, too, as part of their free hosting: https://docs.readthedocs.io/en/stable/features.html#downloadable-documentation -- which could help make life easier for people who aren't wanting to implement their own pipelines. |
Just wanted to say that without epub, mobi and PDF support, I don't really see myself using this. Hoping these things can be added. |
So now that PDF is supported (in two ways), how difficult is it going to be to add ePub, for example? Is it just a matter of integrating copying what was done for PDF but using the sphinx.builders.epub3.Epub3Builder class? |
It would be useful if Jupyter Book could easily create the following things in addition to HTML-based versions of notebooks/md files:
PDF documents: see Export pages to PDF #267Users could then have a "download" button on each page that lets them download that page's content as each of these formats.
Let's keep this issue open to track which if any of these have been implemented.
The text was updated successfully, but these errors were encountered: