added multi code point support

This commit is contained in:
CRIMX 2016-12-23 01:16:35 +08:00
parent 7ebe2e558d
commit 5d743a227c

View file

@ -47,14 +47,18 @@ if (options.enable !== false) {
data.content = data.content.replace(/:(\w+):/ig, function (match, p1) {
if (githubEmojis[p1]) {
// unicode code point
var codepoint = /\/(\w+)\.\w+$/.exec(githubEmojis[p1].split('?')[0])
var codepoint = /\/([\w-]+)\.\w+$/.exec(githubEmojis[p1].split('?')[0])
codepoint = codepoint && codepoint[1]
if (options.unicode && codepoint) {
codepoint = codepoint.split('-').map(function (item) {
return '&#x' + item + ';'
}).join('')
return '<span class="' + options.className +
'" title="' + match +
'" data-src="' + githubEmojis[p1] +
'">&#x' + codepoint + ';</span>'
'">' + codepoint + '</span>'
} else {
return '<img class="' + options.className +
'" title="' + match + '" alt="' + match + '" src="' +