You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 lines
2.0 KiB

/*! markdown-it-emoji 2.0.2 https://github.com/markdown-it/markdown-it-emoji @license MIT */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).markdownitEmoji=t()}(this,(function(){"use strict";var e=function(e,t){return e[t].content};return function(t,n){var r=function(e){var t,n=e.defs;e.enabled.length&&(n=Object.keys(n).reduce((function(t,r){return e.enabled.indexOf(r)>=0&&(t[r]=n[r]),t}),{})),t=Object.keys(e.shortcuts).reduce((function(t,r){return n[r]?Array.isArray(e.shortcuts[r])?(e.shortcuts[r].forEach((function(e){t[e]=r})),t):(t[e.shortcuts[r]]=r,t):t}),{});var r,o=Object.keys(n);r=0===o.length?"^$":o.map((function(e){return":"+e+":"})).concat(Object.keys(t)).sort().reverse().map((function(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")})).join("|");var c=RegExp(r),s=RegExp(r,"g");return{defs:n,shortcuts:t,scanRE:c,replaceRE:s}}(t.utils.assign({},{defs:{},shortcuts:{},enabled:[]},n||{}));t.renderer.rules.emoji=e,t.core.ruler.after("linkify","emoji",function(e,t,n,r,o){var c=e.utils.arrayReplaceAt,s=e.utils.lib.ucmicro,i=new RegExp([s.Z.source,s.P.source,s.Cc.source].join("|"));function u(e,r,c){var s,u=0,l=[];return e.replace(o,(function(r,o,f){var a;if(n.hasOwnProperty(r)){if(a=n[r],o>0&&!i.test(f[o-1]))return;if(o+r.length<f.length&&!i.test(f[o+r.length]))return}else a=r.slice(1,-1);o>u&&((s=new c("text","",0)).content=e.slice(u,o),l.push(s)),(s=new c("emoji","",0)).markup=a,s.content=t[a],l.push(s),u=o+r.length})),u<e.length&&((s=new c("text","",0)).content=e.slice(u),l.push(s)),l}return function(e){var t,n,o,s,i,l=e.tokens,f=0;for(n=0,o=l.length;n<o;n++)if("inline"===l[n].type)for(t=(s=l[n].children).length-1;t>=0;t--)"link_open"!==(i=s[t]).type&&"link_close"!==i.type||"auto"===i.info&&(f-=i.nesting),"text"===i.type&&0===f&&r.test(i.content)&&(l[n].children=s=c(s,t,u(i.content,i.level,e.Token)))}}(t,r.defs,r.shortcuts,r.scanRE,r.replaceRE))}}));