Emojify markdown

This commit is contained in:
Jori Lallo committed 2016-06-05 23:24:05 -07:00
1 parent 6011de49a0
commit 33b823b66e
6 files changed
+30 -2

No files matched your search

+1
View File
@@ -40,6 +40,7 @@
"css-loader": "^0.23.1",
"debug": "^2.2.0",
"dotenv": "^2.0.0",
"emoji-name-map": "^1.1.1",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^5.0.0",
"eslint-plugin-react": "^3.16.1",
+8
View File
@@ -0,0 +1,8 @@
var fs = require('fs');
var path = require('path');
var mapping = require('emoji-name-map');
fs.writeFile(
path.join(__dirname, '../src/utils/emoji-mapping.json'),
JSON.stringify(mapping.emoji)
);
+2 -1
View File
@@ -2,6 +2,7 @@ import { observable, action, computed, autorun } from 'mobx';
import { client } from 'utils/ApiClient';
import localforage from 'localforage';
import { browserHistory } from 'react-router';
import emojify from 'utils/emojify';
const DOCUMENT_EDIT_SETTINGS = 'DOCUMENT_EDIT_SETTINGS';
@@ -10,7 +11,7 @@ const parseHeader = (text) => {
const match = firstLine.match(/^#+ +(.*)$/);
if (match) {
return match[1];
return emojify(match[1]);
}
}
+1
View File
@@ -0,0 +1 @@
{"100":"💯","1234":"🔢","grinning":"😀","grimacing":"😬","grin":"😁","joy":"😂","smiley":"😃","smile":"😄","sweat_smile":"😅","laughing":"😆","innocent":"😇","wink":"😉","blush":"😊","slightly_smiling":"🙂","upside_down":"🙃","relaxed":"☺️","yum":"😋","relieved":"😌","heart_eyes":"😍","kissing_heart":"😘","kissing":"😗","kissing_smiling_eyes":"😙","kissing_closed_eyes":"😚","stuck_out_tongue_winking_eye":"😜","stuck_out_tongue_closed_eyes":"😝","stuck_out_tongue":"😛","money_mouth":"🤑","nerd":"🤓","sunglasses":"😎","hugging":"🤗","smirk":"😏","no_mouth":"😶","neutral_face":"😐","expressionless":"😑","unamused":"😒","rolling_eyes":"🙄","thinking":"🤔","flushed":"😳","disappointed":"😞","worried":"😟","angry":"😠","rage":"😡","pensive":"😔","confused":"😕","slightly_sad":"🙁","white_frowning":"☹","persevere":"😣","confounded":"😖","tired_face":"😫","weary":"😩","triumph":"😤","open_mouth":"😮","scream":"😱","fearful":"😨","cold_sweat":"😰","hushed":"😯","frowning":"😦","anguished":"😧","cry":"😢","disappointed_relieved":"😥","sleepy":"😪","sweat":"😓","sob":"😭","dizzy_face":"😵","astonished":"😲","zipper_mouth":"🤐","mask":"😷","thermometer_face":"🤒","bandage_face":"🤕","sleeping":"😴","zzz":"💤","hankey":"💩","smiling_imp":"😈","imp":"👿","japanese_ogre":"👹","japanese_goblin":"👺","skull":"💀","ghost":"👻","alien":"👽","robot":"🤖","smiley_cat":"😺","smile_cat":"😸","joy_cat":"😹","heart_eyes_cat":"😻","smirk_cat":"😼","kissing_cat":"😽","scream_cat":"🙀","crying_cat_face":"😿","pouting_cat":"😾","raised_hands":"🙌","clap":"👏","wave":"👋","+1":"👍","-1":"👎","facepunch":"👊","fist":"✊","v":"✌️","ok_hand":"👌","hand":"✋","open_hands":"👐","muscle":"💪","pray":"🙏","point_up":"☝️","point_up_2":"👆","point_down":"👇","point_left":"👈","point_right":"👉","middle_finger":"🖕","splayed_fingers":"🖐","sign_of_horns":"🤘","vulcan_salute":"🖖","writing_hand":"✍","nail_care":"💅","lips":"👄","tongue":"👅","ear":"👂","nose":"👃","eye":"👁","eyes":"👀","bust_in_silhouette":"👤","busts_in_silhouette":"👥","speaking_head":"🗣","baby":"👶","boy":"👦","girl":"👧","man":"👨","woman":"👩","person_with_blond_hair":"👱","older_man":"👴","older_woman":"👵","man_with_gua_pi_mao":"👲","man_with_turban":"👳","cop":"👮","construction_worker":"👷","guardsman":"💂","sleuth":"🕵","santa":"🎅","angel":"👼","princess":"👸","bride_with_veil":"👰","runner":"🏃","walking":"🚶","dancer":"💃","dancers":"👯","couple":"👫","two_men_holding_hands":"👬","two_women_holding_hands":"👭","bow":"🙇","information_desk_person":"💁","no_good":"🙅","ok_woman":"🙆","raising_hand":"🙋","person_with_pouting_face":"🙎","person_frowning":"🙍","haircut":"💇","massage":"💆","couple_with_heart":"💑","female_couple_with_heart":"👩‍❤️‍👩","male_couple_with_heart":"👨‍❤️‍👨","couplekiss":"💏","female_couplekiss":"👩‍❤️‍💋‍👩","male_couplekiss":"👨‍❤️‍💋‍👨","family":"👪","family_man_woman_girl":"👨‍👩‍👧","family_man_woman_girl_boy":"👨‍👩‍👧‍👦","family_man_woman_boys":"👨‍👩‍👦‍👦","family_man_woman_girls":"👨‍👩‍👧‍👧","family_women_boy":"👩‍👩‍👦","family_women_girl":"👩‍👩‍👧","family_women_girl_boy":"👩‍👩‍👧‍👦","family_women_boys":"👩‍👩‍👦‍👦","family_women_girls":"👩‍👩‍👧‍👧","family_men_boy":"👨‍👨‍👦","family_men_girl":"👨‍👨‍👧","family_men_girl_boy":"👨‍👨‍👧‍👦","family_men_boys":"👨‍👨‍👦‍👦","family_men_girls":"👨‍👨‍👧‍👧","womans_clothes":"👚","shirt":"👕","jeans":"👖","necktie":"👔","dress":"👗","bikini":"👙","kimono":"👘","lipstick":"💄","kiss":"💋","footprints":"👣","high_heel":"👠","sandal":"👡","boot":"👢","mans_shoe":"👞","athletic_shoe":"👟","womans_hat":"👒","tophat":"🎩","helmet":"⛑","mortar_board":"🎓","crown":"👑","school_satchel":"🎒","pouch":"👝","purse":"👛","handbag":"👜","briefcase":"💼","eyeglasses":"👓","dark_sunglasses":"🕶","ring":"💍","closed_umbrella":"🌂","dog":"🐶","cat":"🐱","mouse":"🐭","hamster":"🐹","rabbit":"🐰","bear":"🐻","panda_face":"🐼","koala":"🐨","tiger":"🐯","lion_face":"🦁","cow":"🐮","pig":"🐷","pig_nose":"🐽","frog":"🐸","octopus":"🐙","monkey_face":"🐵","see_no_evil":"🙈","hear_no_evil":"🙉","speak_no_evil":"🙊","monkey":"🐒","chicken":"🐔","penguin":"🐧","bird":"🐦","baby_chick":"🐤","hatching_chick":"🐣","hatched_chick":"🐥","wolf":"🐺","boar":"🐗","horse":"🐴","unicorn_face":"🦄","bee":"🐝","bug":"🐛","snail":"🐌","beetle":"🐞"Line truncated
+16
View File
@@ -0,0 +1,16 @@
import emojiMapping from './emoji-mapping.json';
const EMOJI_REGEX = /:([A-Za-z0-9_\-\+]+?):/gm;
const emojify = (text) => {
const emojis = text.match(EMOJI_REGEX) || [];
let emojifiedText = text;
emojifiedText = text.replace(EMOJI_REGEX, (match, p1, offset, string) => {
return emojiMapping[p1] || match;
});
return emojifiedText;
};
export default emojify;
+2 -1
View File
@@ -1,6 +1,7 @@
import slug from 'slug';
import marked, { Renderer } from 'marked';
import highlight from 'highlight.js';
import emojify from './emojify';
slug.defaults.mode ='rfc3986';
@@ -35,7 +36,7 @@ marked.setOptions({
// TODO: This is syncronous and can be costly
const convertToMarkdown = (text) => {
return marked(text);
return marked(emojify(text));
};
export {