Sharing code snippets isn’t always easy: between character limits on Twitter and formatting limitations everywhere else, it sometimes feels like the internet is trying to keep beautifully-formatted sample code out. And while there are plenty of tools for converting syntax-highlighted code into distribution-ready images, there’s a certain inconvenience to leaving the command line to use them.
code2png, the easy way to generate beautiful snapshots from the comfort
of the command line.
npm is as easy as:
$ npm install -g code2png $ code2png hello.c -o hello.png
And et voilà! Out the other end comes a beautiful snapshot, syntax-highlighted and ready to take on the world.
Instead of creating beautiful snapshots from a desktop utility or the browser,
code2png brings a browser (namely, PhantomJS) to
where the code is. With a syntax-highlighting assist from
Prism snippets from
stdin or flat files are converted
into HTML documents, snapshotted, and returned to the filesystem.