fuc-new/doc/node_modules/markdown-it-emoji/dist/markdown-it-emoji-bare.min.js
hellcat 6adbc04d4b 1
2025-10-03 17:17:08 +08:00

3 lines
2.0 KiB
JavaScript

/*! markdown-it-emoji 3.0.0 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";function e(e,t){return e[t].content}return function(t,n){const s=function(e){let t=e.defs;e.enabled.length&&(t=Object.keys(t).reduce(((n,s)=>(e.enabled.indexOf(s)>=0&&(n[s]=t[s]),n)),{}));const n=Object.keys(e.shortcuts).reduce(((n,s)=>t[s]?Array.isArray(e.shortcuts[s])?(e.shortcuts[s].forEach((e=>{n[e]=s})),n):(n[e.shortcuts[s]]=s,n):n),{}),s=Object.keys(t);let o;o=0===s.length?"^$":s.map((e=>`:${e}:`)).concat(Object.keys(n)).sort().reverse().map((e=>e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&"))).join("|");const c=RegExp(o),r=RegExp(o,"g");return{defs:t,shortcuts:n,scanRE:c,replaceRE:r}}(t.utils.assign({},{defs:{},shortcuts:{},enabled:[]},n||{}));t.renderer.rules.emoji=e,t.core.ruler.after("linkify","emoji",function(e,t,n,s,o){const c=e.utils.arrayReplaceAt,r=e.utils.lib.ucmicro,i=e.utils.has,l=new RegExp([r.Z.source,r.P.source,r.Cc.source].join("|"));function u(e,s,c){let r=0;const u=[];if(e.replace(o,(function(s,o,f){let a;if(i(n,s)){if(a=n[s],o>0&&!l.test(f[o-1]))return;if(o+s.length<f.length&&!l.test(f[o+s.length]))return}else a=s.slice(1,-1);if(o>r){const t=new c("text","",0);t.content=e.slice(r,o),u.push(t)}const h=new c("emoji","",0);h.markup=a,h.content=t[a],u.push(h),r=o+s.length})),r<e.length){const t=new c("text","",0);t.content=e.slice(r),u.push(t)}return u}return function(e){let t;const n=e.tokens;let o=0;for(let r=0,i=n.length;r<i;r++){if("inline"!==n[r].type)continue;let i=n[r].children;for(let l=i.length-1;l>=0;l--)t=i[l],"link_open"!==t.type&&"link_close"!==t.type||"auto"===t.info&&(o-=t.nesting),"text"===t.type&&0===o&&s.test(t.content)&&(n[r].children=i=c(i,l,u(t.content,t.level,e.Token)))}}}(t,s.defs,s.shortcuts,s.scanRE,s.replaceRE))}}));