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.
composer require alto/commonmarkuse Alto\CommonMark\Extension\CodeBlockTitle\CodeBlockTitleExtension;
use League\CommonMark\Environment\Environment;
$environment = new Environment();
$environment->addExtension(new CodeBlockTitleExtension());```php title="src/App.php"
<?php
echo "Hello";
```new CodeBlockTitleExtension()uses the default CommonMark fenced-code renderer.- You can inject a custom base renderer via the constructor when needed.
```javascript title="app.js"
console.log('Hello');
```This extension is actively developed in the alto/commonmark monorepo.
MIT License -- Simon André & Alto