alto / commonmark-code-block-title
CommonMark extension that parses title="..." from fenced code block info strings and renders them as <figcaption> inside <figure>.
Package info
github.com/altophp/commonmark-code-block-title
pkg:composer/alto/commonmark-code-block-title
Fund package maintenance!
v1.0.0
2026-07-30 02:00 UTC
Requires
- php: ^8.3
- league/commonmark: ^2.7
README
Summary
The detail that signals craft. Adds a title="..." attribute to any fenced code block info string and wraps the result in a semantic <figure>/<figcaption> pair. A small delta -- but the kind of finish that separates a polished documentation site from a functional one.
Installation
composer require
composer require alto/commonmark
Registration
use Alto\CommonMark\Extension\CodeBlockTitle\CodeBlockTitleExtension; use League\CommonMark\Environment\Environment; $environment = new Environment(); $environment->addExtension(new CodeBlockTitleExtension());
Usage
```php title="src/App.php" <?php echo "Hello"; ```
Configuration
new CodeBlockTitleExtension()uses the default CommonMark fenced-code renderer.- You can inject a custom base renderer via the constructor when needed.
Minimal Example
```javascript title="app.js" console.log('Hello'); ```
Development
This extension is actively developed in the alto/commonmark monorepo.
License
MIT License -- Simon André & Alto