Skip to content

Repository files navigation

CodeBlockTitle Extension

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

About

CommonMark extension that parses title="..." from fenced code block info strings and renders them as <figcaption> inside <figure>.

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

Contributors

Languages