2017-10-24 20:44:49 +08:00
|
|
|
/**
|
2018-10-26 17:31:24 +08:00
|
|
|
* Turn emoji codes into emojis
|
|
|
|
*
|
|
|
|
* List of supported emojis: https://github.com/showdownjs/showdown/wiki/Emojis
|
2017-10-24 20:44:49 +08:00
|
|
|
*/
|
|
|
|
showdown.subParser('emoji', function (text, options, globals) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
if (!options.emoji) {
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
text = globals.converter._dispatch('emoji.before', text, options, globals);
|
|
|
|
|
|
|
|
var emojiRgx = /:([\S]+?):/g;
|
|
|
|
|
|
|
|
text = text.replace(emojiRgx, function (wm, emojiCode) {
|
|
|
|
if (showdown.helper.emojis.hasOwnProperty(emojiCode)) {
|
|
|
|
return showdown.helper.emojis[emojiCode];
|
|
|
|
}
|
|
|
|
return wm;
|
|
|
|
});
|
|
|
|
|
|
|
|
text = globals.converter._dispatch('emoji.after', text, options, globals);
|
|
|
|
|
|
|
|
return text;
|
|
|
|
});
|