Wouldn't it be better as a PDF so that it can be selected? But somehow still retain the color / formatting.
I built this to generate PNGs to drop into a Keynote presentation, so PDFs don't quite work for my use case. It 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...
Show HN: Generate high-res images of code samples with Chrome Headless
41–50 of 92 posts
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#42Anyone knows a tool which can help us draw simple diagrams like the one that was mentioned in the README?? https://github.com/mplewis/src2png/blob/master/docs/foreach_...
`mscgen` [1] was a popular one back in the day. I think `graphviz` can do it too. Since sequence diagrams are part of UML, most UML tools can do those. [1] https://en.wikipedia.org/wiki/MscGen
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#43Anyone knows a tool which can help us draw simple diagrams like the one that was mentioned in the README?? https://github.com/mplewis/src2png/blob/master/docs/foreach_...
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#44What's wrong with pygments? I've been using it to get highlighted code as latex, html, whatever, since forever. I'm all for reinventing deficient wheels, but is there anything wrong with this? pygmentize -f png -l python -o test.png test.py Spinning up a browser for it seems like an odd choice. At least the author acknowledges that.
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#45Earlier quoted context omitted.
Yep – I can't copy my code out of Atom and keep its highlighting in Keynote, unfortunately.
sorry for the minirant 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…
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
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#46Earlier quoted context omitted.
Yep – I can't copy my code out of Atom and keep its highlighting in Keynote, unfortunately.
sorry for the minirant 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…
On Android all text formatting is compatible between apps nicely, and can easily be copied between apps.
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#47Re: Show HN: Generate high-res images of code samples with Chrome Headless
#48What's wrong with pygments? I've been using it to get highlighted code as latex, html, whatever, since forever. I'm all for reinventing deficient wheels, but is there anything wrong with this? pygmentize -f png -l python -o test.png test.py Spinning up a browser for it seems like an odd choice. At least the author acknowledges that.
Here's an example of Pygments C++ output: http://imgur.com/a/7TbMb
And the same file through Prism.js + Puppeteer: https://github.com/mplewis/src2png/blob/master/docs/arduino....
Pygments does a great job of generating detailed PNGs. The default settings aren't quite what I'm looking for, but they look like they could be tweaked to increase the resolution and change the color scheme.
I'm embedding my examples in a Keynote deck, so I'm picky about font family, size, resolution, etc. I bet I could get similar results by writing a custom script for Pygments. Thanks for sharing!
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#49You might want to check sharp to remove the imagemagick dependency, I'm pretty sure sharp supports edge trimming in one way or another. Great project!
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#50This is a step backward from my current workflow which uses vector graphics.