UNPKG

jr-util

Version:

这是MJR的JS工具库。定期更新

2 lines (1 loc) 641 B
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=r=>{if(typeof r!="string")return r;try{let e=r.replace(/<img[^>]*>/gi,function(t,g){return t=t.replace(/width="[^"]+"/gi,"").replace(/width='[^']+'/gi,""),t=t.replace(/height="[^"]+"/gi,"").replace(/height='[^']+'/gi,""),t});return e=e.replace(/<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/gi,'<p style="margin-bottom:12px"'),e=e.replace(/<br[^>]*\/>/gi,""),e=e.replace(/\<img/gi,'<img style="max-width:100%;width:auto;height:auto;display:block;margin-top:10px;margin-bottom:10px;"'),e}catch{return r}};exports.formatRichText=i;