Vim can do this 1. Open your script/code in vim editor 2. Enable syntax & set the required color scheme :syntax on :colorscheme darkblue 3. Print the file in PS file format :hardcopy >/tmp/filename.ps 4. Convert the PS file to PDF format $ ps2pdf /tmp/filename.ps 5. Now you can open filename.pdf
Show HN: Generate high-res images of code samples with Chrome Headless
71–80 of 92 posts
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#72Anyone 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_...
I tend to like https://www.draw.io/ for that sort of thing (there is a chrome app if you want to run offline).
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#73What'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.
Hey, thanks for the suggestion. I've used Pygments in the past and didn't even think to check if it had a PNG output mode. 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 the…
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#74Why "Show HN" but not publish to NPM? Seems neat, just publish it. Also, ever try this technique? https://gist.github.com/jimbojsb/1630790 I've used it with success before.
Thank you! I don't want to publish it yet because I want to clean it up a lot first – ditch the dev server, clean up the build pipeline, add some actual CLI arguments, etc. I'll check out that app on brew, it looks like a cool approach. Thanks!
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#75 1. Write in emacs org-mode code blocks
2. Export to html (requires htmlize)
3. Copy and paste the html from safari to keynote
The Emacs theme determines the syntax highlighting. Org-mode controls the html export (font family, font size, line spacing), with optional line number or output from executions. The copy-pasting from safari to keynote preserves all the formatting.Re: Show HN: Generate high-res images of code samples with Chrome Headless
#76Earlier quoted context omitted.
Why not just do a screenshot of the code from Atom?
That doesn't scale well beyond doing a handful of them, I would think.
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#77If I want to scratch my left hear, I would use my left hand. Why in the world I'll do it with my right foot? What happened to the simple screenshot? This seems to be the flow: +----------+ +----------+ +-------------+ | | | | | | | NodeJS +------->+ POI +--------->+ Puppeteer +----+ | | | | | | | +----------+ +----------+ +-------------+ | | | +----------+ +----------+ +-------------+ | | | | | | | | | NodeJS * drawn…
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#78Re: Show HN: Generate high-res images of code samples with Chrome Headless
#79Vim can do this 1. Open your script/code in vim editor 2. Enable syntax & set the required color scheme :syntax on :colorscheme darkblue 3. Print the file in PS file format :hardcopy >/tmp/filename.ps 4. Convert the PS file to PDF format $ ps2pdf /tmp/filename.ps 5. Now you can open filename.pdf
4. Using ghostscript: gs -sDEVICE=jpeg -dJPEGQ=100 -dNOPAUSE -dBATCH -dSAFER -r300 -sOutputFile=filename.jpg filename.ps
Re: Show HN: Generate high-res images of code samples with Chrome Headless
#80Earlier 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…
I can easily do the same with Notepad++ and Powerpoint, just need to copy-paste in RTF.