Switch to make singlehtml + Chromium for PDF output - #307
Open
legoktm wants to merge 1 commit into
Open
Conversation
Instead of going through LaTeX, which has some limitations (e.g. can't use newer emojis), we can use sphinx's pre-existing "singlehtml" target, and just have a browser print it to PDF. Chromium has a better CLI setup for this, but in the future we can swap to Firefox if desired. I think for the most part this will be a nicer experience for users, because it'll be much closer to what's already online (some CSS is different), and because it's just HTML, there'll be far less less gotchas of things that work in HTML mode but not in PDF mode.
Member
|
I've been using https://weasyprint.org/ to turn HTML documents into PDF (as a python library but it can be used as a CLI as well) with great results 🙂. It requires to configure a bit more the CSS "print" target, but the upside is that you can have documents that have a nice paper feeling, disable some menus and information that don't make sense for print, but are are displayed in the HTML rendered for browsers. It seems that there exists an integration for sphinx: https://pypi.org/project/sphinx-weasyprint-builder. I haven't tried it, but if you're willing to spend some time tweaking the CSS, I bet you won't regret it (plus, it doesn't need an actual browser) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of going through LaTeX, which has some limitations (e.g. can't use newer emojis), we can use sphinx's pre-existing "singlehtml" target, and just have a browser print it to PDF. Chromium has a better CLI setup for this, but in the future we can swap to Firefox if desired.
I think for the most part this will be a nicer experience for users, because it'll be much closer to what's already online (some CSS is different), and because it's just HTML, there'll be far less less gotchas of things that work in HTML mode but not in PDF mode.
This was done by Claude after I got nerdsniped by @jskinne3.
Test plan
Checklist
This change accounts for: