News for hackers. Stuff that matters.
Re:Show HN: Generate high-res images of code samples with Ch... by sago on Monday September 11, 2017 @01:55PM (#15220554)
My workflow:

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
Re:Show HN: Generate high-res images of code samples with Ch... by hk__2 on Monday September 11, 2017 @02:40PM (#15220966)
Can’t you it directly using Pygments’ ImageFormatter?

http://pygments.org/docs/formatters/#ImageFormatter

Re:Show HN: Generate high-res images of code samples with Ch... by sago on Monday September 11, 2017 @02:52PM (#15221111)
Apparently so! I don't generate images myself, so i didn't know.

    $ pygmentize -o out.png src.py 
Neat.
Re:Show HN: Generate high-res images of code samples with Ch... by ngharo on Monday September 11, 2017 @05:27PM (#15222513)
I use vim for writing out html:

  :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_file