fdekker / commonmark-ext-emoji

league/commonmark 的表情符号扩展

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

This package is auto-updated.

Last update: 2024-08-26 20:26:19 UTC


README

Minimum PHP Version Software License Run tests

CommonMark 表情符号扩展

PHPLeague/CommonMark 的表情符号支持扩展。

支持表情符号

安装

通过以下方式将库作为依赖项包含到您的项目中:

composer require "fdekker/commonmark-ext-emoji"

使用方法

// 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)');

输出

Works 👍 👍 👍

要了解更多关于配置扩展的信息,请访问: https://commonmark.thephpleague.com/2.4/extensions/github-flavored-markdown/

自定义

您可以通过实现 EmojiDataProviderInterface 来提供您自己的表情符号列表。