carbon-now-cli - プログラミングコードを画像化
プログラミングコードをブログなどで綺麗に表示したいと思っても、ブログの環境が対応していないケースがあります。多少のハイライトは入っていても、タブ幅、フォント、テーマなどカスタマイズしたい要素は無数に存在します。 そこで使えるのがコードの画像化ですが、毎回手作業でやるのは面倒です。自動化したいならcarbon-now-cliを使ってみましょう。
carbon-now-cliの使い方
carbon-now-cliをインストールすると carbon-now
コマンドが使えるようになるので、後は画像化したいコードの書かれたファイルを引数に渡すだけです。
$ carbon-now path_to.js
✔ Processing path_to.js
✔ Preparing connection
↓ Opening in browser [skipped]
✔ Fetching beautiful image
Done!
The file can be found here: ./carbon.png ?
作った例です。
carbon-now-cliのヘルプです。
$ carbon-now --help
Beautiful images of your code — from right inside your terminal.
Usage
$ carbon-now <file>
Options
-s, --start Starting line of </file><file>
-e, --end Ending line of </file><file>
-i, --interactive Interactive mode
-l, --location Screenshot save location, default: cwd
-o, --open Open in browser instead of saving
Examples
See: https://github.com/mixn/carbon-now-cli#examples
carbon-now-cliは carbon.now というサイトをヘッドレスのブラウザ(実際には立ち上がっているのが見えてしまっていますが)でアクセスして画像を保存しているだけです。コードの画像化は carbon.now が行っています。簡単な仕組みですが便利なコマンドです。
carbon-now-cliはnode/JavaScript製のオープンソース・ソフトウェア(MIT License)です。
mixn/carbon-now-cli: ? Beautiful images of your code — from right inside your terminal.