/*! markdown-it-emoji 1.4.0 https://github.com//markdown-it/markdown-it-emoji @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownitEmoji = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 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/ // 'use strict'; module.exports = { angry: [ '>:(', '>:-(' ], blush: [ ':")', ':-")' ], broken_heart: [ '= 0) { acc[key] = emojies[key]; } return acc; }, {}); } // Flatten shortcuts to simple object: { alias: emoji_name } shortcuts = Object.keys(options.shortcuts).reduce(function (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(function (alias) { acc[alias] = key; }); return acc; } acc[options.shortcuts[key]] = key; return acc; }, {}); // Compile regexp var names = Object.keys(emojies) .map(function (name) { return ':' + name + ':'; }) .concat(Object.keys(shortcuts)) .sort() .reverse() .map(function (name) { return quoteRE(name); }) .join('|'); var scanRE = RegExp(names); var replaceRE = RegExp(names, 'g'); return { defs: emojies, shortcuts: shortcuts, scanRE: scanRE, replaceRE: replaceRE }; }; },{}],4:[function(require,module,exports){ 'use strict'; module.exports = function emoji_html(tokens, idx /*, options, env */) { return tokens[idx].content; }; },{}],5:[function(require,module,exports){ // Emojies & shortcuts replacement logic. // // Note: In theory, it could be faster to parse :smile: in inline chain and // leave only shortcuts here. But, who care... // 'use strict'; module.exports = function create_rule(md, emojies, shortcuts, scanRE, replaceRE) { var arrayReplaceAt = md.utils.arrayReplaceAt, ucm = md.utils.lib.ucmicro, ZPCc = new RegExp([ ucm.Z.source, ucm.P.source, ucm.Cc.source ].join('|')); function splitTextToken(text, level, Token) { var token, last_pos = 0, nodes = []; text.replace(replaceRE, function (match, offset, src) { var emoji_name; // Validate emoji name if (shortcuts.hasOwnProperty(match)) { // replace shortcut with full name emoji_name = shortcuts[match]; // Don't allow letters before any shortcut (as in no ":/" in http://) if (offset > 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) { token = new Token('text', '', 0); token.content = text.slice(last_pos, offset); nodes.push(token); } 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) { token = new Token('text', '', 0); token.content = text.slice(last_pos); nodes.push(token); } return nodes; } return function emoji_replace(state) { var i, j, l, tokens, token, blockTokens = state.tokens, autolinkLevel = 0; for (j = 0, l = blockTokens.length; j < l; j++) { if (blockTokens[j].type !== 'inline') { continue; } 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 (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) ); } } } }; }; },{}],6:[function(require,module,exports){ 'use strict'; var emojies_defs = require('./lib/data/full.json'); var emojies_shortcuts = require('./lib/data/shortcuts'); var emoji_html = require('./lib/render'); var emoji_replace = require('./lib/replace'); var normalize_opts = require('./lib/normalize_opts'); module.exports = function emoji_plugin(md, options) { var defaults = { defs: emojies_defs, shortcuts: emojies_shortcuts, enabled: [] }; var opts = normalize_opts(md.utils.assign({}, defaults, options || {})); md.renderer.rules.emoji = emoji_html; md.core.ruler.push('emoji', emoji_replace(md, opts.defs, opts.shortcuts, opts.scanRE, opts.replaceRE)); }; },{"./lib/data/full.json":1,"./lib/data/shortcuts":2,"./lib/normalize_opts":3,"./lib/render":4,"./lib/replace":5}]},{},[6])(6) });