定制 giberti/commonmark-emoji-extension 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

giberti/commonmark-emoji-extension

最新稳定版本:1.4.1

Composer 安装命令:

composer require giberti/commonmark-emoji-extension

包简介

Adds emoji support for CommonMark

README 文档

README

An extension to provide GitHub and Slack style emoji for the League CommonMark package. By default, it will substitute official unicode CLDR short names for the emoji, but can also use aliases to map common language to the official name. The generated output wraps the emoji in a <span> to permit additional styling and provides a title attribute for accessibility.

Quality

Build and Test

Installing

composer require giberti/commonmark-emoji-extension

Usage

use Giberti\EmojiExtension\EmojiExtension;

Basic

To use, add a new instance of EmojiExtension to the CommonMark environment and use as you would normally.

// Get a configured instance of the converter
$environment = new \League\CommonMark\Environment\Environment();
$environment->addExtension(new \League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension());
$environment->addExtension(new \Giberti\EmojiExtension\EmojiExtension());
$converter = new \League\CommonMark\MarkdownConverter($environment);

// <p>I can haz <span class="emoji" title="hot_beverage">☕</span>?</p>
echo $converter->convert('I can haz :hot_beverage:?')->getContent();

Providing Aliases

GitHub and Slack both shortcuts that do not map directly to the official Unicode CLDR Short Name. Mappings can be injected at the time the instance of EmojiExtension is created.

The Aliases should be passed as an associative array with the key being the new alias and the value being the CLDR Short Name equivalent.

$aliases = [
    ':coffee:' => ':hot_beverage:',
    ':smile:' => ':grinning_face_with_smiling_eyes:',
    // ... any other aliases you wish to support
];

// Get a configured instance of the converter
$environment = new \League\CommonMark\Environment\Environment();
$environment->addExtension(new \League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension());
$environment->addExtension(new \Giberti\EmojiExtension\EmojiExtension($aliases));
$converter = new \League\CommonMark\MarkdownConverter($environment);

// <p>I can haz <span class="emoji" title="coffee">☕</span>?</p>
echo $converter->convert('I can haz :coffee:?')->getContent();

统计信息

  • 总下载量: 3.83k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固