mixn / carbon-now-cli
- среда, 11 июля 2018 г. в 02:07:36
JavaScript
🎨 Beautiful images of your code — from right inside your terminal.

🎨 Beautiful images of your code — from right inside your terminal.
carbon.now.sh by @dawn_labs is a wonderful tool that lets you generate beautiful images of your source code through a great UI, letting you customize aspects like fonts, themes, window controls and much more.
carbon-now-cli gives you the full power of Carbon — right at your fingertips, inside the terminal.
Generate beautiful images from a source file, or sections of a source file, by running a single command.
Want to customize everything before generating the image? Run it in
--start and --end--interactive.png or .svg — just like Carbon2x, 4x or 1x resolutions — just like Carbon$ npm i -g 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>
-e, --end Ending line of <file>
-i, --interactive Interactive mode
-l, --location Image save location, default: cwd
-o, --open Open in browser instead of saving
Assuming you have a file unfold.js with this content
// Example from https://carbon.now.sh/
const unfold = (f, seed) => {
const go = (f, seed, acc) => {
const res = f(seed)
return res ? go(f, res[1], acc.concat([res[0]])) : acc
}
return go(f, seed, [])
};and you’d like to make a beautiful image out of it. You could approach this in several ways.
$ carbon-now unfold.js
Takes the entire source of unfold.js, uses Carbon’s default settings and saves as .png into your cwd.
Result:
$ carbon-now unfold.js -i
Launches an interactive mode, prompting questions, allowing you to customize every aspect of Carbon, like syntax theme, font-family, padding, drop-shadow, etc.
Given this input…
…the result will look like so
If you’re not sure what each question, e.g. “Make squared image?”, refers to, just confirm by hitting Enter — they will default to sensible, nice-looking things.
If needed, you can always check the default settings.
$ carbon-now unfold.js -s 3 -e 6
Reads and creates image based only of lines 3 to 6, instead of the entire file. Will throw an error if -s > -e.
Of course selective mode can be combined with interactive mode, just with like any other option.
Result (without interactive mode):
For demonstration purposes, here is an example using all options.
$ carbon-now unfold.js -s 3 -e 6 -l ~/Desktop -i
This saves a beautiful image of lines 3 to 6 to ~/Desktop, after accepting custom wishes via interactive mode.
If you’re not sure about how the image will turn out you can always use -o or --open.
$ carbon-now unfold.js -s 3 -e 6 -i -o
This will open the image in the browser for final touches, instead of saving it immediately.
MIT © Miloš Sutanovac