mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
27 lines
658 B
JavaScript
27 lines
658 B
JavaScript
|
/**
|
||
|
* These are all the transformations that occur *within* block-level
|
||
|
* tags like paragraphs, headers, and list items.
|
||
|
*/
|
||
|
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;
|
||
|
});
|