fdekker/commonmark-ext-emoji

An emoji extension for league/commonmark

v1.1.2 2023-04-26 17:48 UTC

This package is auto-updated.

Last update: 2024-11-26 21:04:20 UTC


README

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.