[common] text & [web] common > scripts > text compiler: support emoji

This commit is contained in:
otofune
2017-02-28 20:33:27 +00:00
parent a7021b9514
commit 67ea1498ff
4 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,14 @@
/**
* Emoji
*/
module.exports = text => {
const match = text.match(/^:[a-zA-Z0-9+-_]+:/);
if (!match) return null;
const emoji = match[0];
return {
type: 'emoji',
content: emoji,
emoji: emoji.substr(1, emoji.length - 2)
};
};

View File

@ -8,7 +8,8 @@ const elements = [
require('./elements/mention'),
require('./elements/hashtag'),
require('./elements/code'),
require('./elements/inline-code')
require('./elements/inline-code'),
require('./elements/emoji')
];
function analyze(source) {