'use strict'; // Generated, don't edit var emojies_defs = { "grinning": "😀", "smiley": "😃", "smile": "😄", "grin": "😁", "laughing": "😆", "satisfied": "😆", "sweat_smile": "😅", "joy": "😂", "wink": "😉", "blush": "😊", "innocent": "😇", "heart_eyes": "😍", "kissing_heart": "😘", "kissing": "😗", "kissing_closed_eyes": "😚", "kissing_smiling_eyes": "😙", "yum": "😋", "stuck_out_tongue": "😛", "stuck_out_tongue_winking_eye": "😜", "stuck_out_tongue_closed_eyes": "😝", "neutral_face": "😐", "expressionless": "😑", "no_mouth": "đŸ˜ļ", "smirk": "😏", "unamused": "😒", "relieved": "😌", "pensive": "😔", "sleepy": "đŸ˜Ē", "sleeping": "😴", "mask": "😷", "dizzy_face": "đŸ˜ĩ", "sunglasses": "😎", "confused": "😕", "worried": "😟", "open_mouth": "😮", "hushed": "đŸ˜¯", "astonished": "😲", "flushed": "đŸ˜ŗ", "frowning": "đŸ˜Ļ", "anguished": "😧", "fearful": "😨", "cold_sweat": "😰", "disappointed_relieved": "đŸ˜Ĩ", "cry": "đŸ˜ĸ", "sob": "😭", "scream": "😱", "confounded": "😖", "persevere": "đŸ˜Ŗ", "disappointed": "😞", "sweat": "😓", "weary": "😩", "tired_face": "đŸ˜Ģ", "rage": "😡", "pout": "😡", "angry": "😠", "smiling_imp": "😈", "smiley_cat": "đŸ˜ē", "smile_cat": "😸", "joy_cat": "😹", "heart_eyes_cat": "đŸ˜ģ", "smirk_cat": "đŸ˜ŧ", "kissing_cat": "đŸ˜Ŋ", "scream_cat": "🙀", "crying_cat_face": "đŸ˜ŋ", "pouting_cat": "😾", "heart": "â¤ī¸", "hand": "✋", "raised_hand": "✋", "v": "âœŒī¸", "point_up": "â˜ī¸", "fist_raised": "✊", "fist": "✊", "monkey_face": "đŸĩ", "cat": "🐱", "cow": "🐮", "mouse": "🐭", "coffee": "☕", "hotsprings": "â™¨ī¸", "anchor": "⚓", "airplane": "âœˆī¸", "hourglass": "⌛", "watch": "⌚", "sunny": "â˜€ī¸", "star": "⭐", "cloud": "â˜ī¸", "umbrella": "☔", "zap": "⚡", "snowflake": "â„ī¸", "sparkles": "✨", "black_joker": "🃏", "mahjong": "🀄", "phone": "â˜Žī¸", "telephone": "â˜Žī¸", "envelope": "âœ‰ī¸", "pencil2": "âœī¸", "black_nib": "âœ’ī¸", "scissors": "âœ‚ī¸", "wheelchair": "â™ŋ", "warning": "âš ī¸", "aries": "♈", "taurus": "♉", "gemini": "♊", "cancer": "♋", "leo": "♌", "virgo": "♍", "libra": "♎", "scorpius": "♏", "sagittarius": "♐", "capricorn": "♑", "aquarius": "♒", "pisces": "♓", "heavy_multiplication_x": "âœ–ī¸", "heavy_plus_sign": "➕", "heavy_minus_sign": "➖", "heavy_division_sign": "➗", "bangbang": "â€ŧī¸", "interrobang": "â‰ī¸", "question": "❓", "grey_question": "❔", "grey_exclamation": "❕", "exclamation": "❗", "heavy_exclamation_mark": "❗", "wavy_dash": "ã€°ī¸", "recycle": "â™ģī¸", "white_check_mark": "✅", "ballot_box_with_check": "â˜‘ī¸", "heavy_check_mark": "âœ”ī¸", "x": "❌", "negative_squared_cross_mark": "❎", "curly_loop": "➰", "loop": "âžŋ", "part_alternation_mark": "ã€Ŋī¸", "eight_spoked_asterisk": "âœŗī¸", "eight_pointed_black_star": "âœ´ī¸", "sparkle": "â‡ī¸", "copyright": "ÂŠī¸", "registered": "ÂŽī¸", "tm": "â„ĸī¸", "information_source": "â„šī¸", "m": "â“‚ī¸", "black_circle": "âšĢ", "white_circle": "âšĒ", "black_large_square": "âŦ›", "white_large_square": "âŦœ", "black_medium_square": "â—ŧī¸", "white_medium_square": "â—ģī¸", "black_medium_small_square": "◾", "white_medium_small_square": "â—Ŋ", "black_small_square": "â–Ēī¸", "white_small_square": "â–Ģī¸" }; // Emoticons -> Emoji mapping. // // (!) Some patterns skipped, to avoid collisions // without increase matcher complicity. Than can change in future. // // Places to look for more emoticons info: // // - http://en.wikipedia.org/wiki/List_of_emoticons#Western // - https://github.com/wooorm/emoticon/blob/master/Support.md // - http://factoryjoe.com/projects/emoticons/ // /* eslint-disable key-spacing */ var emojies_shortcuts = { angry: ['>:(', '>:-('], blush: [':")', ':-")'], broken_heart: [' 0 && !ZPCc.test(src[offset - 1])) return // Don't allow letters after any shortcut if (offset + match.length < src.length && !ZPCc.test(src[offset + match.length])) { return } } else { emoji_name = match.slice(1, -1); } // Add new tokens to pending list if (offset > last_pos) { const token = new Token('text', '', 0); token.content = text.slice(last_pos, offset); nodes.push(token); } const token = new Token('emoji', '', 0); token.markup = emoji_name; token.content = emojies[emoji_name]; nodes.push(token); last_pos = offset + match.length; }); if (last_pos < text.length) { const token = new Token('text', '', 0); token.content = text.slice(last_pos); nodes.push(token); } return nodes } return function emoji_replace (state) { let token; const blockTokens = state.tokens; let autolinkLevel = 0; for (let j = 0, l = blockTokens.length; j < l; j++) { if (blockTokens[j].type !== 'inline') { continue } let tokens = blockTokens[j].children; // We scan from the end, to keep position when new tags added. // Use reversed logic in links start/end match for (let i = tokens.length - 1; i >= 0; i--) { token = tokens[i]; if (token.type === 'link_open' || token.type === 'link_close') { if (token.info === 'auto') { autolinkLevel -= token.nesting; } } if (token.type === 'text' && autolinkLevel === 0 && scanRE.test(token.content)) { // replace current node blockTokens[j].children = tokens = arrayReplaceAt( tokens, i, splitTextToken(token.content, token.level, state.Token) ); } } } } } // Convert input options to more useable format // and compile search regexp function quoteRE (str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&') } function normalize_opts (options) { let emojies = options.defs; // Filter emojies by whitelist, if needed if (options.enabled.length) { emojies = Object.keys(emojies).reduce((acc, key) => { if (options.enabled.indexOf(key) >= 0) acc[key] = emojies[key]; return acc }, {}); } // Flatten shortcuts to simple object: { alias: emoji_name } const shortcuts = Object.keys(options.shortcuts).reduce((acc, key) => { // Skip aliases for filtered emojies, to reduce regexp if (!emojies[key]) return acc if (Array.isArray(options.shortcuts[key])) { options.shortcuts[key].forEach(alias => { acc[alias] = key; }); return acc } acc[options.shortcuts[key]] = key; return acc }, {}); const keys = Object.keys(emojies); let names; // If no definitions are given, return empty regex to avoid replacements with 'undefined'. if (keys.length === 0) { names = '^$'; } else { // Compile regexp names = keys .map(name => { return `:${name}:` }) .concat(Object.keys(shortcuts)) .sort() .reverse() .map(name => { return quoteRE(name) }) .join('|'); } const scanRE = RegExp(names); const replaceRE = RegExp(names, 'g'); return { defs: emojies, shortcuts, scanRE, replaceRE } } function emoji_plugin$1 (md, options) { const defaults = { defs: {}, shortcuts: {}, enabled: [] }; const opts = normalize_opts(md.utils.assign({}, defaults, options || {})); md.renderer.rules.emoji = emoji_html; md.core.ruler.after( 'linkify', 'emoji', create_rule(md, opts.defs, opts.shortcuts, opts.scanRE, opts.replaceRE) ); } function emoji_plugin (md, options) { const defaults = { defs: emojies_defs, shortcuts: emojies_shortcuts, enabled: [] }; const opts = md.utils.assign({}, defaults, options || {}); emoji_plugin$1(md, opts); } module.exports = emoji_plugin;