npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qq-wechat-emotion-parser

v1.0.4

Published

QQ、微信表情符号解析:字符串到图片URL

Downloads

14

Readme

QQ WechaT EmotioN ParseR

NPM version Build Status Coverage Status Dependency manager

嗯,这是一个很简单的小工具,作用是将网页中添加的QQ表情和或者微信表情字符串转化为表情图片。

  • 快速!这是目前最快速的表情字符串转换JS库,使用前缀树(Trie)实现,对于限长的表情库,算法复杂度达到O(n)。
  • 方便!无任何依赖,只需引入min.js即可使用。同时支持Node.js环境。

Demo

example 1

输入:

/::)

输出:

<img src="https://res.wx.qq.com/mpres/htmledition/images/icon/emotion/0.gif" alt="/::)">

效果:

example 2

输入:

I xx Gunzi, /::), No no no, I just xx xx/::B.

输出:

I xx Gunzi, <img src="https://res.wx.qq.com/mpres/htmledition/images/icon/emotion/0.gif" alt="/::)">, No no no, I just xx xx<img src="https://res.wx.qq.com/mpres/htmledition/images/icon/emotion/2.gif" alt="/::B">.

效果:

I xx Gunzi, , No no no, I just xx xx.

Usage

本工具对外暴露一个qqWechatEmotionParser()方法,此方法的输入是需要处理的字符串,输出是将字符表情转化为img标签的字符串。

浏览器环境

  1. 下载并引入https://github.com/buddys/qq-wechat-emotion-parser/blob/master/dist/qq-wechat-emotion-parser.min.js

    <script src="/path/to/qq-wechat-emotion-parser.min.js"></script>
  2. 调用window.qqWechatEmotionParser

    var text = 'I xx Gunzi /::), No no no, I just xx xx/:<L>.';
    var html = qqWechatEmotionParser(text);
       
    document.write(text);
    document.write('<br/>')
    document.write(html);

Node环境

  1. 安装:

    npm install qq-wechat-emotion-parser
  2. 使用:

    var qqWechatEmotionParser = require('qq-wechat-emotion-parser');
    
    var text = 'I xx Gunzi /::), No no no, I just xx xx/:<L>.';
    var html = qqWechatEmotionParser(text);
    
    console.log(html);

Contribution

贡献代码

欢迎通过Github提交issue或者贡献代码, 贡献代码前需要仔细阅读原代码尽量保持代码风格一致。

新增标签

表情在src/emotion.json文件下保存,通过编辑该json文件定义表情的字符表示以及图片源。需要注意以下两点:

  • 表情的字符表示应该尽量避免产生歧义
  • 图片托管应使用稳定,国内访问速度快的服务器

License

GPL V3.0

harttle, meriky @ Buddys Copyright (c) 2016