Go to file
dependabot-preview[bot] cadaf816f0
chore(deps): bump clipboard-win from 4.0.3 to 4.1.0
Bumps [clipboard-win](https://github.com/DoumanAsh/clipboard-win) from 4.0.3 to 4.1.0.
- [Release notes](https://github.com/DoumanAsh/clipboard-win/releases)
- [Commits](https://github.com/DoumanAsh/clipboard-win/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-27 23:59:53 +00:00
.github/workflows chore: fix release on windows 2020-12-16 01:21:39 +08:00
assets deps: update assets 2021-03-02 23:27:49 +08:00
src fmt: make rustfmt happy 2021-04-26 18:05:24 +08:00
.gitignore add .vscode to gitignore 2020-08-07 20:00:52 +05:30
Cargo.lock chore(deps): bump clipboard-win from 4.0.3 to 4.1.0 2021-04-27 23:59:53 +00:00
Cargo.toml chore(deps): bump clipboard-win from 4.0.3 to 4.1.0 2021-04-27 23:59:53 +00:00
LICENSE Update the copyright year to 2020 2020-01-04 00:22:21 +08:00
README.md add dependency for Fedora 33 2021-04-03 02:50:52 +09:00

README.md

Silicon

Crates.io Documentation CI License

Silicon is an alternative to Carbon implemented in Rust.

It can render your source code into a beautiful image.

Why Silicon

Carbon is a wonderful tool to create a beautiful image of your source code.

But it is a web application, which brings the following disadvantages:

  • Cannot work without Internet & browser.
  • Doesn't work well with shell. (Although there is carbon-now-cli, its experience is not very good, especially when the network is not so good.)

However, Silicon doesn't have these problems. It's is implemented in Rust and can work without browser & Internet.

Silicon can render your source code on the fly while carbon-now-cli takes several seconds on it.

Disadvantages

It's not as beautiful as Carbon...

Install

Cargo

cargo install silicon

AUR

Silicon is available on AUR (Thanks to @radmen).

You can install it with any AUR helpers you like.

eg.

pikaur -S silicon

Homebrew

You can install Silicon using Homebrew:

brew install silicon

Dependencies

Ubuntu

sudo apt install expat
sudo apt install libxml2-dev
sudo apt install pkg-config libasound2-dev libssl-dev cmake libfreetype6-dev libexpat1-dev libxcb-composite0-dev

Fedora

sudo dnf install cmake expat-devel libxcb-devel freetype-devel libxml2-devel

Arch Linux

sudo pacman -S --needed pkgconf freetype2 fontconfig libxcb xclip

Examples

Read code from file

silicon main.rs -o main.png 

Read code from clipboard, and copy the result image to clipboard

silicon --from-clipboard -l rs --to-clipboard

Specify a fallback font list and their size

silicon -o main.png -l bash -f 'Hack; SimSun=31; code2000' <<EOF
echo Hello
echo 你好
echo ∠( ᐛ 」∠)_
EOF

Highlight specified line

silicon main.rs -o main.png --highlight-lines '1; 3-4'

Custom the image

silicon ./target/test.rs -o test.png \
    --shadow-color '#555' --background '#fff' \
    --shadow-blur-radius 30 --no-window-controls

Transparent background

The color can be #RGB[A] or #RRGGBB[AA]

silicon ./target/test.rs -o test.png --background '#fff0'

see silicon --help for detail

Adding new syntaxes / themes

Silicon reads syntax-definition and theme cache from bat's cache directory.

You can find the steps to add new syntaxes / themes for bat here: sharkdp/bat#adding-new-syntaxes--language-definitions.

Configuration file

You can write some common args to silicon --config-file.

Example:

# enable shadow
--shadow-color '#555'
--background '#fff'
--shadow-blur-radius 30
--no-window-controls

Related projects