Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

**Python bindings for [Silicon](https://github.com/Aloxaf/silicon)'s renderer — create beautiful images of your source code, powered by Rust.**

<p align="center">
<img src="docs/assets/hero-example.png" alt="Silicate example - Python code rendered with Dracula theme" width="700">
</p>

Unlike wrapper approaches that shell out to a CLI, Silicate uses [PyO3](https://pyo3.rs) to call Silicon's Rust library directly, giving you native performance with a clean Python API.

## Installation
Expand Down Expand Up @@ -44,6 +48,25 @@ print(silicate.list_themes())
print(silicate.list_languages())
```

## Theme gallery

Silicate ships with 24+ built-in themes. Here are a few:

<table>
<tr>
<td align="center"><strong>Dracula</strong><br><img src="docs/assets/hero-example.png" width="400"></td>
<td align="center"><strong>Nord</strong><br><img src="docs/assets/example-nord.png" width="400"></td>
</tr>
<tr>
<td align="center"><strong>Monokai Extended</strong><br><img src="docs/assets/example-monokai.png" width="400"></td>
<td align="center"><strong>GitHub</strong><br><img src="docs/assets/example-github.png" width="400"></td>
</tr>
<tr>
<td align="center"><strong>Solarized Dark</strong><br><img src="docs/assets/example-solarized.png" width="400"></td>
<td align="center"><strong>Your code here</strong><br><img src="docs/assets/example-usage.png" width="400"></td>
</tr>
</table>

### Options

All parameters after `code` (and `output` for `to_file`) are keyword-only:
Expand All @@ -62,6 +85,9 @@ All parameters after `code` (and `output` for `to_file`) are keyword-only:
| `shadow_blur_radius` | `50.0` | Shadow blur radius |
| `pad_horiz` | `80` | Horizontal padding (px) |
| `pad_vert` | `100` | Vertical padding (px) |
| `shadow_offset_x` | `0` | Shadow offset in X axis |
| `shadow_offset_y` | `0` | Shadow offset in Y axis |
| `code_pad_right` | `25` | Right padding inside code window (px) |
| `highlight_lines` | `None` | 1-based line numbers to highlight |
| `tab_width` | `4` | Spaces per tab |
| `line_offset` | `1` | Starting line number |
Expand All @@ -85,3 +111,7 @@ uv run python -c "import silicate; print(silicate.list_themes())"
## License

MIT

---

Built by [All Tuner Labs](https://alltuner.com)
6 changes: 6 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def generate(
shadow_blur_radius: float = 50.0,
pad_horiz: int = 80,
pad_vert: int = 100,
shadow_offset_x: int = 0,
shadow_offset_y: int = 0,
code_pad_right: int = 25,
highlight_lines: list[int] | None = None,
tab_width: int = 4,
line_offset: int = 1,
Expand All @@ -44,6 +47,9 @@ Generate a code image and return raw PNG bytes.
| `shadow_blur_radius` | `float` | `50.0` | Gaussian blur radius for shadow |
| `pad_horiz` | `int` | `80` | Horizontal padding in pixels |
| `pad_vert` | `int` | `100` | Vertical padding in pixels |
| `shadow_offset_x` | `int` | `0` | Shadow offset in X axis |
| `shadow_offset_y` | `int` | `0` | Shadow offset in Y axis |
| `code_pad_right` | `int` | `25` | Padding to the right of the code in pixels |
| `highlight_lines` | `list[int] \| None` | `None` | 1-based line numbers to highlight |
| `tab_width` | `int` | `4` | Spaces per tab character |
| `line_offset` | `int` | `1` | Starting line number |
Expand Down
Binary file added docs/assets/example-github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/example-monokai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/example-nord.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/example-solarized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/example-usage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/hero-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

**Python bindings for [Silicon](https://github.com/Aloxaf/silicon)'s renderer — create beautiful images of your source code, powered by Rust.**

<p align="center">
<img src="assets/hero-example.png" alt="Silicate example - Python code rendered with Dracula theme" width="700">
</p>

Unlike wrapper approaches that shell out to a CLI, Silicate uses [PyO3](https://pyo3.rs) to call Silicon's Rust library directly, giving you native performance with a clean Python API.

## Features
Expand Down Expand Up @@ -35,6 +39,32 @@ silicate.to_file(
)
```

## Theme gallery

Silicate ships with 24+ built-in themes. Here are a few examples across different languages:

<div class="grid" markdown>

### Dracula — Python
![Dracula theme example](assets/hero-example.png)

### Nord — Rust
![Nord theme example](assets/example-nord.png)

### Monokai Extended — TypeScript
![Monokai theme example](assets/example-monokai.png)

### GitHub — SQL
![GitHub theme example](assets/example-github.png)

### Solarized Dark — Go
![Solarized theme example](assets/example-solarized.png)

### Silicate itself — Python
![Usage example](assets/example-usage.png)

</div>

## How it works

```mermaid
Expand All @@ -47,3 +77,7 @@ graph LR
```

Silicate embeds the Silicon Rust library via [PyO3](https://pyo3.rs), compiled with [maturin](https://github.com/PyO3/maturin). The syntax highlighting engine, font rendering, and image composition all run in native Rust — Python only handles the API surface.

---

Built by [All Tuner Labs](https://alltuner.com)
96 changes: 74 additions & 22 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -1,33 +1,85 @@
/* Silicate brand colors — indigo/violet code-editor theme */
/* All Tuner Labs brand colors and MkDocs Material theme overrides. */
/* Provides wine/burgundy color scheme with light/dark mode support. */

/* All Tuner Labs Brand Colors */
:root {
/* Primary palette */
--silicon-indigo: #6366f1;
--silicon-violet: #8b5cf6;
--silicon-slate: #1e293b;
--silicon-light: #f1f5f9;
--wine: #5B2333;
--white-smoke: #F7F4F3;
--taupe-gray: #928E8D;
--raisin-black: #2C2826;
}

/* Light mode custom colors */
[data-md-color-scheme="default"] {
--md-primary-fg-color: var(--wine);
--md-primary-fg-color--light: #7a2f45;
--md-primary-fg-color--dark: #4a1b28;
--md-primary-bg-color: var(--white-smoke);

--md-accent-fg-color: var(--wine);
--md-accent-fg-color--transparent: rgba(91, 35, 51, 0.1);

/* Material overrides — light mode */
--md-primary-fg-color: var(--silicon-indigo);
--md-primary-fg-color--light: #818cf8;
--md-primary-fg-color--dark: #4f46e5;
--md-accent-fg-color: var(--silicon-violet);
--md-default-bg-color: var(--white-smoke);
--md-default-fg-color: var(--raisin-black);
--md-default-fg-color--light: var(--taupe-gray);
--md-default-fg-color--lighter: #b5b2b1;
--md-default-fg-color--lightest: #d4d3d2;

--md-code-bg-color: #ffffff;
--md-code-fg-color: var(--raisin-black);
}

/* Dark mode custom colors */
[data-md-color-scheme="slate"] {
/* Material overrides — dark mode */
--md-primary-fg-color: #818cf8;
--md-primary-fg-color--light: #a5b4fc;
--md-primary-fg-color--dark: #6366f1;
--md-accent-fg-color: #a78bfa;
--md-primary-fg-color: var(--wine);
--md-primary-fg-color--light: #7a2f45;
--md-primary-fg-color--dark: #4a1b28;

--md-accent-fg-color: #8a3d51;
--md-accent-fg-color--transparent: rgba(138, 61, 81, 0.1);

--md-default-bg-color: var(--raisin-black);
--md-default-fg-color: var(--white-smoke);
--md-default-fg-color--light: var(--taupe-gray);

--md-code-bg-color: #1a1816;
--md-code-fg-color: var(--white-smoke);
}

/* Custom link colors for light mode */
[data-md-color-scheme="default"] .md-content a {
color: var(--wine);
}

[data-md-color-scheme="default"] .md-content a:hover {
color: #7a2f45;
}

/* Custom link colors for dark mode - use white-smoke for readability */
[data-md-color-scheme="slate"] .md-content a {
color: var(--white-smoke);
}

[data-md-color-scheme="slate"] .md-content a:hover {
color: var(--taupe-gray);
}

/* Sidebar navigation links in dark mode */
[data-md-color-scheme="slate"] .md-nav__link {
color: var(--white-smoke);
}

[data-md-color-scheme="slate"] .md-nav__link:hover {
color: var(--taupe-gray);
}

/* Code block styling */
.md-typeset code {
border-radius: 4px;
[data-md-color-scheme="slate"] .md-nav__link--active {
color: var(--white-smoke);
}

/* Navigation tab highlight */
.md-tabs__link--active {
border-bottom: 2px solid var(--md-accent-fg-color);
/* Custom header logo sizing */
.md-header__button.md-logo img,
.md-header__button.md-logo svg {
height: 2rem;
width: auto;
}
17 changes: 17 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ for theme in silicate.list_themes():

Available themes include: `1337`, `Coldark-Cold`, `Coldark-Dark`, `DarkNeon`, `Dracula`, `GitHub`, `Monokai Extended`, `Nord`, `OneHalfDark`, `OneHalfLight`, `Solarized (dark)`, `Solarized (light)`, `Sublime Snazzy`, `TwoDark`, `Visual Studio Dark+`, `gruvbox-dark`, `gruvbox-light`, `zenburn`, and more.

Here's the same code rendered with different themes:

<table>
<tr>
<td align="center"><strong>Dracula</strong><br><img src="assets/hero-example.png" width="400"></td>
<td align="center"><strong>Nord</strong><br><img src="assets/example-nord.png" width="400"></td>
</tr>
<tr>
<td align="center"><strong>Monokai Extended</strong><br><img src="assets/example-monokai.png" width="400"></td>
<td align="center"><strong>GitHub</strong><br><img src="assets/example-github.png" width="400"></td>
</tr>
</table>

### Languages

```python
Expand Down Expand Up @@ -162,3 +175,7 @@ silicate.to_file(
pad_vert=80,
)
```

The code above produces:

![Full example output](assets/example-nord.png)
12 changes: 8 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
site_name: Silicate
site_description: Python bindings for Silicon's renderer
site_url: https://silicate.alltuner.com
site_author: David Poblador i Garcia
site_url: https://silicate.alltuner.com/
site_description: Python bindings for Silicon's renderer — create beautiful images of your source code, powered by Rust
site_author: All Tuner Labs, S.L.

repo_url: https://github.com/alltuner/silicate
repo_name: alltuner/silicate
edit_uri: edit/main/docs/

theme:
name: material
logo: assets/logo.png
favicon: assets/logo.png
palette:
# Light mode
- media: "(prefers-color-scheme: light)"
Expand All @@ -29,8 +31,10 @@ theme:
features:
- navigation.instant
- navigation.tracking
- navigation.tabs
- navigation.sections
- navigation.expand
- navigation.top
- toc.integrate
- search.suggest
- search.highlight
- content.code.copy
Expand Down
28 changes: 27 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,42 @@ authors = [
{ name = "David Poblador i Garcia", email = "david@poblador.com" }
]
requires-python = ">=3.9"
keywords = ["code", "image", "screenshot", "syntax-highlighting", "silicon", "rust"]
keywords = [
"code",
"image",
"screenshot",
"syntax-highlighting",
"silicon",
"rust",
"code-to-image",
"carbon",
"code-screenshot",
"png",
"developer-tools",
"pyo3",
"rendering",
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: MIT License",
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Multimedia :: Graphics",
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Documentation",
"Topic :: Text Processing :: Markup",
"Topic :: Utilities",
"Typing :: Typed",
]

[project.urls]
Expand Down
12 changes: 12 additions & 0 deletions python/silicate/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def generate(
shadow_blur_radius: float = 50.0,
pad_horiz: int = 80,
pad_vert: int = 100,
shadow_offset_x: int = 0,
shadow_offset_y: int = 0,
code_pad_right: int = 25,
highlight_lines: list[int] | None = None,
tab_width: int = 4,
line_offset: int = 1,
Expand All @@ -34,6 +37,9 @@ def generate(
shadow_blur_radius: Gaussian blur radius for the shadow.
pad_horiz: Horizontal padding in pixels.
pad_vert: Vertical padding in pixels.
shadow_offset_x: Shadow offset in X axis.
shadow_offset_y: Shadow offset in Y axis.
code_pad_right: Padding to the right of the code in pixels.
highlight_lines: List of 1-based line numbers to highlight.
tab_width: Number of spaces per tab character.
line_offset: Starting line number.
Expand All @@ -57,6 +63,9 @@ def to_file(
shadow_blur_radius: float = 50.0,
pad_horiz: int = 80,
pad_vert: int = 100,
shadow_offset_x: int = 0,
shadow_offset_y: int = 0,
code_pad_right: int = 25,
highlight_lines: list[int] | None = None,
tab_width: int = 4,
line_offset: int = 1,
Expand All @@ -81,6 +90,9 @@ def to_file(
shadow_blur_radius: Gaussian blur radius for the shadow.
pad_horiz: Horizontal padding in pixels.
pad_vert: Vertical padding in pixels.
shadow_offset_x: Shadow offset in X axis.
shadow_offset_y: Shadow offset in Y axis.
code_pad_right: Padding to the right of the code in pixels.
highlight_lines: List of 1-based line numbers to highlight.
tab_width: Number of spaces per tab character.
line_offset: Starting line number.
Expand Down
Loading
Loading