ueberdosis / commonmark-hint-extension
A hint extension for league/commonmark
Fund package maintenance!
ueberdosis/
Installs: 6 358
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 3
Forks: 3
Open Issues: 0
Requires
- php: ^8.0
- league/commonmark: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^4.8
README
We need your support to maintain this package. 💖 https://github.com/sponsors/ueberdosis
CommonMark Hint Extension
A hint extension for league/commonmark that renders the following Markdown as HTML.
Example
Markdown
:::important Warning! This is how the **Markdown** looks. :::
HTML
<div class="hint important"> <h2 class="hint-title"> Warning! </h2> <p class="hint-content"> This is how the <strong>Markdown</strong> looks. </p> </div>
Installation
You can install the package via composer:
composer require ueberdosis/commonmark-hint-extension
Usage
<?php use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\MarkdownConverter; use Ueberdosis\CommonMark\HintExtension; // Configure the Environment with all the CommonMark parsers/renderers $environment = new Environment(); $environment->addExtension(new CommonMarkCoreExtension()); // Add this extension $environment->addExtension(new HintExtension()); // Instantiate the converter engine and start converting some Markdown! $converter = new MarkdownConverter($environment); $markdown = <<<MARKDOWN :::important Warning! This is how the **Markdown** looks. ::: MARKDOWN; echo $converter->convertToHtml($markdown);
Testing
composer test
Credits
License
The MIT License (MIT). Please see License File for more information.