From 5d743a227c5a174c84a378b77c87079da9954857 Mon Sep 17 00:00:00 2001 From: CRIMX Date: Fri, 23 Dec 2016 01:16:35 +0800 Subject: [PATCH] added multi code point support --- index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 19c2a30..cefb9f5 100644 --- a/index.js +++ b/index.js @@ -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 '&#x' + codepoint + ';' + '">' + codepoint + '' } else { return '