Code → SVG screenshot generator
Turn code or terminal output into an SVG screenshot. No ext-gd / Imagick — output is plain text suitable for git diffs and CI artifacts. ANSI SGR (16 / 256 / 24-bit truecolor + bold / italic / underline) becomes <tspan> in the SVG.
composer require sugarcraft/candy-freeze
use SugarCraft\Freeze\SvgRenderer;
$svg = SvgRenderer::dracula()
->withLineNumbers(true)
->withWindow(true)
->withPadding(24)
->render($code);
file_put_contents('out.svg', $svg);
// ANSI input is honoured — SGR colours become <tspan> segments.
$svg = SvgRenderer::dark()
->render("\x1b[31merror:\x1b[0m something broke");
candyfreeze input.php -o out.svg, or SvgRenderer::dracula()->render($code).| Class | Method | Description |
|---|---|---|
| SvgRenderer | dracula(), dark(), light(), tokyoNight(), nord() | Create renderer with theme |
| SvgRenderer | withLineNumbers(bool) | Show line numbers |
| SvgRenderer | withWindow(bool) | Show window chrome |
| SvgRenderer | withPadding(pixels) | Set padding |
| SvgRenderer | withLigatures(bool) | Enable font-variant-ligatures |
| SvgRenderer | withBorderRadius(int) | Set corner radius |
| SvgRenderer | render(code) | Render code to SVG |
| LanguageDetector | detect(content) | Detect language from content (shebang or signatures) |
| LanguageDetector | detectFromFilename(filename) | Detect language from filename extension |
| Segment | withBg(?string) | Return segment with different background colour |
VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.