One time setup
$ python -m venv ve
$ source ve/bin/activate
$ pip install pygments WeasyPrint
Then $ pygmentize -f html src.py | weasyprint - out.pdf
Both pygmentize and weasyprint have many options to play with. I find a set and create a shell script.This also does pngs, etc:
$ pygmentize -f html src.py | weasyprint - out.png $ pygmentize -o out.png src.py
Neat. :TOhtml
I found it to create the prettiest syntax highlighted code. But I'm bias because it produces html using my vim color scheme which I'm partial too :)You can script vim too by specifying a list of commands in a file then running it:
$ vim -S myscript some_fileIt seems like it should be pretty easy to print a PDF from Puppeteer though – they expose a #pdf method.
https://github.com/GoogleChrome/puppeteer/blob/master/docs/a...
This is something I find really frustrating in computing. We can do and are constantly doing such awesome and incredible things with computers. But at the same time transferring (copy-pasting) text from one application to another remains a challenge. And a reasonable solution for that is to bring in the 600lb gorilla that is a modern web browser to render fixed-width text into a bitmap so that it can be embedded into a presentation. It just feels so wrong, like the whole field is actually rotten inside under the shiny surface, while the state of the art blazes forwards thousand miles away from the real world. I, as a member of this community, feel utterly powerless to actually make the situation noticeably better, partly because of so much relies on interoperability, and partly because of the massive inertia that modern software carries.
I want out.
EDIT: Apparently, the problem is (or was in 2014) that Keynote doesn't support HTML and Chrome (Atom is Electron-based, right?) doesn't support RTF. Well worth a read: https://apple.stackexchange.com/a/124167
On Android all text formatting is compatible between apps nicely, and can easily be copied between apps.
I can easily do the same with Notepad++ and Powerpoint, just need to copy-paste in RTF.