Skip to content

boris-glumpler/commonmark-hint-extension

 
 

Repository files navigation

We need your support to maintain this package. 💖 https://github.com/sponsors/ueberdosis

CommonMark Hint Extension

Tests Sponsor

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.

About

Render :::important Hints::: in league/commonmark

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%