Skip to content

frankdekker/commonmark-ext-emoji

Repository files navigation

Minimum PHP Version Software License Run tests

Emoji Extension for CommonMark

The PHPLeague/CommonMark extension for emoji's support.

Support emoji's:

Installation

Include the library as dependency in your own project via:

composer require "fdekker/commonmark-ext-emoji"

Usage:

// Define your configuration, if needed
$config = [];

// Configure the Environment with all the CommonMark and GFM parsers/renderers
$environment = new Environment($config);
$environment->addExtension(new CommonMarkCoreExtension());
$environment->addExtension(new GithubFlavoredMarkdownExtension());
$environment->addExtension(new EmojiExtension(EmojiDataProvider::light()));

$converter = new MarkdownConverter($environment);
echo $converter->convert('Works (y) :thumbsup: (thumbsup)');

Outputs:

Works 👍 👍 👍

To read more about configuring extension visit: https://commonmark.thephpleague.com/2.4/extensions/github-flavored-markdown/

Customization

You can implement EmojiDataProviderInterface to supply your own emoji's list.