← All libraries

CandyShine

🌟 CandyShine

Markdown → ANSI renderer

port of glamour markdown ansi renderer themes

Built on league/commonmark + CandySprinkles. Word-wrap, OSC 8 hyperlinks, syntax highlighting, eight built-in themes plus custom JSON themes.

Install

composer require candycore/candy-shine

Quickstart

use CandyCore\Shine\{Renderer, Theme};

echo (new Renderer())->render(<<<MD
# Welcome

A few **bold** and _italic_ words, with `inline code` and a
[link](https://example.com).

- one
- two
- three

```php
echo "hello world";
```
MD);

// Custom theme
$theme = Theme::fromJson('./themes/my-theme.json');
echo (new Renderer($theme))->render($markdown);

What's in the box

CommonMark parserHeadings, paragraphs, lists, blockquotes, code blocks, tables, rules, links, images, HTML inline + block.
Eight themesansi, plain, notty, dark, light, dracula, tokyo-night, pink.
Custom JSONTheme::fromJson('./my-theme.json') — element-keyed style overrides.
Word-wrapConfigurable column width; honours SGR + grapheme cluster widths.
OSC 8 hyperlinksOptional --no-hyperlinks toggle for terminals that don't support them.
Syntax highlightingCode blocks tokenised + coloured per language.

Source & demos

Try the quickstart →

Demos.

VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.

Render

Render

Markdown → ANSI with the default ansi theme.
Themes

Themes

Same document rendered through all eight themes.