mini-program-parser
Advanced tools
@@ -26,3 +26,2 @@ Component({ | ||
| } | ||
| console.log(parserData); | ||
| this.setData({ | ||
@@ -29,0 +28,0 @@ parserData, |
+1
-1
@@ -1,1 +0,1 @@ | ||
| const t={containerWidth:0},e="area,base,canvas,embed,frame,head,iframe,input,link,map,meta,param,rp,script,source,style,textarea,title,track,wbr".split(","),s="area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr".split(","),n="address,article,aside,blockquote,dd,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ol,p,pre,section,table,ul".split(","),i=/^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,r=/^<\/([-A-Za-z0-9_]+)[^>]*>/,o=/^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/)>/,l=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g,a=[[/<\?xml.*\?>\n/,""],[/<.*!doctype.*\>\n/,""],[/<.*!DOCTYPE.*\>\n/,""],[/<!--.*?-->/gi,""],[/\/\*.*?\*\//gi,""]],c=/(\d*\.?\d*)(.*)/,u={lt:"<",gt:">",quot:'"',apos:"'",ensp:" ",emsp:" ",nbsp:" ",semi:";",ndash:"–",mdash:"—",middot:"·",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",bull:"•",hellip:"…",amp:"&"};class h{config;extraData;isPureText;constructor({html:e,config:s,extraData:n}){return this.config=s||{},this.extraData=n||t,e?this.steps(e):[]}steps(t){const e=this.cleanHtml(t);this.isPureText=!/<\s*img/g.test(e);const s=this.htmlToJson(e);return this.jsonToSkeleton(s)}cleanHtml(t){return a.forEach((e=>{const[s,n]=e;t=t.replace(s,n)})),t}decodeHtml(t){if(!t)return"";let e=t.indexOf("&");for(;-1!==e;){const s=t.indexOf(";",e+3);let n;if(-1===s)break;"#"===t[e+1]?(n=parseInt(("x"===t[e+2]?"0":"")+t.substring(e+2,s)),isNaN(n)||(t=t.substr(0,e)+String.fromCharCode(n)+t.substr(s+1))):(n=t.substring(e+1,s),u[n]&&(t=t.substr(0,e)+(u[n]||"&")+t.substr(s+1))),e=t.indexOf("&",e+1)}return t}isInvalidElement(t){const{ignoredElement:s=e}=this.config;return s.includes(t)}isSelfClosingElement(t,e){return o.test(t)||s.includes(e)}attributeProcessor(t,e){const{format:s={}}=this.config;if(s[e]){const n=s[e];Object.keys(n).forEach((e=>{const s=n[e];t[e]="function"==typeof s?s(t[e],t):s}))}return t}styleProcessor(t){const e=t.split(";"),s={},{adaptive:n=!0}=this.config,{containerWidth:i}=this.extraData;let r=0;e.forEach((t=>{if(!t)return;const[e,o=""]=t.split(":");if(e){const t=e.trim(),l=o.trim();if(n&&i){let e="";l.replace(c,(function(s,n,o){return n&&!isNaN(n)&&"px"===o&&("width"===t&&+n>i?(r=i/+n,e=`${i}${o}`):"height"===t&&r>0&&(e=`${n*r}${o}`)),""})),s[t]=e||l}else s[t]=l}}));return{styleStr:Object.keys(s).map((t=>`${t}:${s[t]}`)).join(";"),styleObj:s}}formatAttributes(t,e){if(!t)return{};const s=this;let n={};return t.replace(l,(function(t,e,i){const r=Array.prototype.slice.call(arguments);if(r.length>=3){const t=i?s.decodeHtml(i).replace(/(^|[^\\])"/g,'$1\\"'):"",{styleObj:r,styleStr:o}=s.styleProcessor(t);"style"===e?(n.styleObj=r,n[e]=o):n[e]=t}return""})),this.attributeProcessor(n,e)}updateHtmlStr(t,e){return t.substring(e.length)}htmlToJson(t){const e=[];for(;t;){if(0===t.indexOf("</")){const n=t.match(r);if(!n)continue;const[i,o]=n,l=this.updateHtmlStr(t,i);if(this.isInvalidElement(o)){t=l;continue}t=l;const a=s.includes(o);e.push({type:a?"selfClosing":"end",name:o});continue}if(0===t.indexOf("<")){const s=t.match(i);if(!s)continue;const[r,o,l=""]=s,a=this.updateHtmlStr(t,r);if(this.isInvalidElement(o)){t=a;continue}t=a;const c=this.isSelfClosingElement(r,o),u=this.formatAttributes(l.replace(/ /g,""),o);let h=n.includes(o)?"block":"inline";const d=u.styleObj;if(d){const{display:t}=d;t&&(h=t)}e.push({type:c?"selfClosing":"start",name:o,attrs:u,display:h});continue}const o=t.indexOf("<"),l=o<0;let a=l?t:t.substring(0,o);a=this.decodeHtml(a),t=l?"":t.substring(o),e.push({type:"text",name:"text",display:"inline",attrs:this.attributeProcessor({content:a},"text")})}return e}transToBlock(t){const{name:e,display:s,attrs:n,children:i=[]}=t;if("img"===e)return!0;if(i.length<=0)return!1;const r=!!i.find((t=>this.transToBlock(t)));return r&&"block"!==s&&(t.display="block",n&&n.styleObj&&n.styleObj.display&&(n.styleObj.display="block",n.style+=";display:block")),r}autoFixer(t){this.isPureText||t.forEach((t=>{this.transToBlock(t)}))}skeletonGenerator(t,e=0){if(t.length<=0)return[];const{autoFix:s=!0}=this.config;let n=0;const i=[];for(;n<t.length;){const{genKey:s,type:r,...o}=t[n],{name:l}=o,a=`${e}_${n}_${l}`,c=["start","end"].includes(r)?"default":r;if("start"===r){const e=t.findIndex((({type:t,genKey:e})=>"end"===t&&e===s));if(-1===e)break;i.push({id:a,...o,type:c,children:this.skeletonGenerator(t.slice(n+1,e),n)}),n=e+1}else i.push({id:a,...o,type:c}),n++}return s&&this.autoFixer(i),i}jsonToSkeleton(t){const e=[];return t.forEach(((t,s)=>{const{type:n}=t;switch(n){case"start":t.genKey=s,e.push(s);break;case"end":const n=e.splice(e.length-1,1)[0];t.genKey=n}})),this.skeletonGenerator(t)}}export{h as MiniParser,e as defaultIgnoreElements}; | ||
| const t={containerWidth:0},e="area,base,canvas,embed,frame,head,iframe,input,link,map,meta,param,rp,script,source,style,textarea,title,track,wbr".split(","),s="area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr".split(","),n="address,article,aside,blockquote,dd,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ol,p,pre,section,table,ul".split(","),i=/^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,r=/^<\/([-A-Za-z0-9_]+)[^>]*>/,o=/^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/)>/,l=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g,a=[[/<\?xml.*\?>\n/,""],[/<.*!doctype.*\>\n/,""],[/<.*!DOCTYPE.*\>\n/,""],[/<!--.*?-->/gi,""],[/\/\*.*?\*\//gi,""]],c=/(\d*\.?\d*)(.*)/,u={lt:"<",gt:">",quot:'"',apos:"'",ensp:" ",emsp:" ",nbsp:" ",semi:";",ndash:"–",mdash:"—",middot:"·",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",bull:"•",hellip:"…",amp:"&"};class h{config;extraData;isPureText;constructor({html:e,config:s,extraData:n}){return this.config=s||{},this.extraData=n||t,e?this.steps(e):[]}steps(t){const e=this.cleanHtml(t);this.isPureText=!/<\s*img/g.test(e);const s=this.htmlToJson(e);return this.jsonToSkeleton(s)}cleanHtml(t){return a.forEach((e=>{const[s,n]=e;t=t.replace(s,n)})),t}decodeHtml(t){if(!t)return"";let e=t.indexOf("&");for(;-1!==e;){const s=t.indexOf(";",e+3);let n;if(-1===s)break;"#"===t[e+1]?(n=parseInt(("x"===t[e+2]?"0":"")+t.substring(e+2,s)),isNaN(n)||(t=t.substr(0,e)+String.fromCharCode(n)+t.substr(s+1))):(n=t.substring(e+1,s),u[n]&&(t=t.substr(0,e)+(u[n]||"&")+t.substr(s+1))),e=t.indexOf("&",e+1)}return t}isInvalidElement(t){const{ignoredElement:s=e}=this.config;return s.includes(t)}isSelfClosingElement(t,e){return o.test(t)||s.includes(e)}attributeProcessor(t,e){const{format:s={}}=this.config;if(s[e]){const n=s[e];Object.keys(n).forEach((e=>{const s=n[e];t[e]="function"==typeof s?s(t[e],t):s}))}return t}styleProcessor(t){const e=t.split(";"),s={},{adaptive:n=!0}=this.config,{containerWidth:i}=this.extraData;let r=0;e.forEach((t=>{if(!t)return;const[e,o=""]=t.split(":");if(e){const t=e.trim(),l=o.trim();if(n&&i){let e="";l.replace(c,(function(s,n,o){return n&&!isNaN(n)&&"px"===o&&("width"===t&&+n>i?(r=i/+n,e=`${i}${o}`):"height"===t&&r>0&&(e=`${n*r}${o}`)),""})),s[t]=e||l}else s[t]=l}}));return{styleStr:Object.keys(s).map((t=>`${t}:${s[t]}`)).join(";"),styleObj:s}}formatAttributes(t,e){if(!t)return{};const s=this;let n={};return t.replace(l,(function(t,e,i){const r=Array.prototype.slice.call(arguments);if(r.length>=3){const t=i?s.decodeHtml(i).replace(/(^|[^\\])"/g,'$1\\"'):"",{styleObj:r,styleStr:o}=s.styleProcessor(t);"style"===e?(n.styleObj=r,n[e]=o):n[e]=t}return""})),this.attributeProcessor(n,e)}updateHtmlStr(t,e){return t.substring(e.length)}htmlToJson(t){const e=[];for(;t;){if(0===t.indexOf("</")){const n=t.match(r);if(!n)continue;const[i,o]=n,l=this.updateHtmlStr(t,i);if(this.isInvalidElement(o)){t=l;continue}t=l;const a=s.includes(o);e.push({type:a?"selfClosing":"end",name:o});continue}if(0===t.indexOf("<")){const s=t.match(i);if(!s)continue;const[r,o,l=""]=s,a=this.updateHtmlStr(t,r);if(this.isInvalidElement(o)){t=a;continue}t=a;const c=this.isSelfClosingElement(r,o),u=this.formatAttributes(l.replace(/ /g,""),o);let h=n.includes(o)?"block":"inline";const d=u.styleObj;if(d){const{display:t}=d;t&&(h=t)}e.push({type:c?"selfClosing":"start",name:o,attrs:u,display:h});continue}const o=t.indexOf("<"),l=o<0;let a=l?t:t.substring(0,o);a=this.decodeHtml(a),t=l?"":t.substring(o),e.push({type:"text",name:"text",display:"inline",attrs:this.attributeProcessor({content:a},"text")})}return e}transToBlock(t){const{name:e,display:s,attrs:n,children:i=[]}=t;if("img"===e)return!0;if(i.length<=0)return!1;const r=!!i.find((t=>this.transToBlock(t)));return r&&"block"!==s&&n&&n.styleObj&&!("width"in n.styleObj)&&(t.display="block",n.styleObj.display="block",n.style+=";display:block"),r}autoFixer(t){this.isPureText||t.forEach((t=>{this.transToBlock(t)}))}skeletonGenerator(t,e=0){if(t.length<=0)return[];const{autoFix:s=!0}=this.config;let n=0;const i=[];for(;n<t.length;){const{genKey:s,type:r,...o}=t[n],{name:l}=o,a=`${e}_${n}_${l}`,c=["start","end"].includes(r)?"default":r;if("start"===r){const e=t.findIndex((({type:t,genKey:e})=>"end"===t&&e===s));if(-1===e)break;i.push({id:a,...o,type:c,children:this.skeletonGenerator(t.slice(n+1,e),n)}),n=e+1}else i.push({id:a,...o,type:c}),n++}return s&&this.autoFixer(i),i}jsonToSkeleton(t){const e=[];return t.forEach(((t,s)=>{const{type:n}=t;switch(n){case"start":t.genKey=s,e.push(s);break;case"end":const n=e.splice(e.length-1,1)[0];t.genKey=n}})),this.skeletonGenerator(t)}}export{h as MiniParser,e as defaultIgnoreElements}; |
+1
-1
| { | ||
| "name": "mini-program-parser", | ||
| "version": "0.3.8", | ||
| "version": "0.3.9", | ||
| "scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "rollup -c ./rollup.dev.config.js --watch", |
+1
-1
| import { MiniParser } from "./main"; | ||
| const html = `<section powered-by="xiumi.us" style="text-align: center; margin: 0px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; width: 601px; height: auto; box-sizing: border-box;"><img class="raw-image" data-ratio="0.6701571" data-w="955" _width="100%" src="https://img1.dxycdn.com/2021/0702/676/8105647457378410943-68.jpg" style="vertical-align: middle; width: 601px; box-sizing: border-box;"/></section></section><p></p><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">湿湿湿湿湿……</div><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">「梅雨季」,大概是南方朋友才会有深刻感触的一个倒霉时节。</div><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">每到这段时间,连续阴雨 + 高温,把人搞得是又闷又热提不起劲儿,家里各处是湿湿嗒嗒罩着一层水汽,墙壁、地板「狂冒小汗珠」,给你整个小水帘洞。</div><br style="box-sizing: border-box;"/><p style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">这鬼天气,搞得大家的眼眶和整个世界都湿了!😿</p><p style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><br/></p></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><p style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="0.6671803" data-w="649" src="https://img1.dxycdn.com/2021/0702/991/8994647457378410943-68.jpg" style="color: rgb(84, 84, 84); letter-spacing: 0.4px; white-space: normal; vertical-align: middle; box-sizing: border-box;"/></p></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><p style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><br/></p></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><div style="text-align: center; white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><span style="letter-spacing: 0.4px; font-size: 12px; color: rgb(208, 208, 208); box-sizing: border-box;">图片来源:网络</span></div><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">而梅雨天最担心的还是家里物品的安危。</div><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">房间门一打开霉味扑面而来,要是置之不理,久而久之你会发现,墙壁、瓷砖缝隙、洗衣机硅胶圈……家里各处小地方真的很容易发霉!</div><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">且,能被你看到「发霉」,意味着那可能已经是大面积霉菌森林了!</div></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="1" data-w="1080" src="https://img1.dxycdn.com/2021/0702/174/5005647457378410943-68.jpg" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><div style="text-align: center; white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><span style="letter-spacing: 0.4px; font-size: 12px; color: rgb(208, 208, 208); box-sizing: border-box;">图片来源:站酷海洛</span><br style="box-sizing: border-box;"/></div><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">霉菌不光难看,长期吸入和接触霉菌,还有可能引发呼吸道疾病和一些过敏的问题,比如诱发过敏性鼻炎、哮喘等,危害人体健康。</div><br/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">除霉防霉,迫在眉睫!</div></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="1" data-w="640" src="https://img1.dxycdn.com/2021/0702/284/5804717457378410943-68.jpg" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><div style="text-align: center; white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><span style="letter-spacing: 0.4px; font-size: 12px; color: rgb(208, 208, 208); box-sizing: border-box;">图片来源:网络</span></div></section><section powered-by="xiumi.us" style="text-align: right; font-size: 12px; color: rgb(208, 208, 208); box-sizing: border-box;"><div style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">-广告-</div></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></section><section powered-by="xiumi.us" style="margin: 0px 0px 5px; text-align: center; position: static; box-sizing: border-box;"><section style="display: inline-block; vertical-align: top; box-sizing: border-box;"><section style="margin-bottom: -6px; line-height: 1; padding: 0px 5px; font-size: 18px; letter-spacing: 1px; text-align: right; box-sizing: border-box;"><div style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">净狮 CLEALION 除霉防霉啫喱</strong></div></section><section style="width: 274.008px; height: 10px; background-color: rgba(161, 142, 214, 0.5); box-sizing: border-box;"><section><svg viewbox="0 0 1 1" style="float:left;line-height:0;width:0;vertical-align:top;"></svg></section></section></section></section><section powered-by="xiumi.us" style="margin: 0px 0px 5px; text-align: center; position: static; box-sizing: border-box;"><section style="display: inline-block; vertical-align: top; box-sizing: border-box;"><section style="margin-bottom: -6px; line-height: 1; padding: 0px 5px; font-size: 18px; letter-spacing: 1px; text-align: right; box-sizing: border-box;"><div style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><strong style="box-sizing: border-box;">除霉防霉,不是难题</strong></div></section><section style="width: 181px; height: 10px; background-color: rgba(161, 142, 214, 0.5); box-sizing: border-box;"><section><svg viewbox="0 0 1 1" style="float:left;line-height:0;width:0;vertical-align:top;"></svg></section></section></section></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">对付霉菌,除了日常注意通风、保持干燥外,快速防霉除霉好物少不了。</div><br/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">挑选除霉好物,我有三个硬指标:</div><br style="box-sizing: border-box;"/></section><section powered-by="xiumi.us" style="margin: 10px 0px 8px; text-align: center; position: static; box-sizing: border-box;"><section style="display: inline-block; width: 601px; vertical-align: top; border-left: 3px solid rgba(161, 142, 214, 0.5); border-bottom-left-radius: 0px; padding: 0px 0px 0px 8px; height: auto; box-sizing: border-box;"><section powered-by="xiumi.us" style="text-align: justify; color: rgb(160, 160, 160); line-height: 1.6; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">1. 必须有效:针对不同位置除霉清洁,效果显著。</div><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">2. 必须简单:操作过程省时省力,懒人也能放心用。</div><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">3. 必须安全:成分安全无危害,可定期使用预防。</div></section></section></section><section powered-by="xiumi.us" style="margin: 0px; position: static; box-sizing: border-box;"><section style="line-height: 1.8; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">净狮除霉防霉啫喱,<span style="color: rgb(116, 97, 255); box-sizing: border-box;">来自日本浓缩配方,可以快速渗透除霉,</span>完美匹配。</div><br style="box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="0.6666667" data-w="1080" src="https://img1.dxycdn.com/2021/0702/069/6704717457378410943-68.jpg" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="margin: 0px; position: static; box-sizing: border-box;"><section style="line-height: 1.8; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><br/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">配方温和,闻着就像游泳池消毒水的味道,使用过程无压力。</div><br/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">来,实际感受下这款除霉啫喱的强大。</div><br/></section></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="1.1523342" data-w="407" src="https://img1.dxycdn.com/2021/0702/539/0014717457378410943-68.png" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="margin: 0px; position: static; box-sizing: border-box;"><section style="line-height: 1.8; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><div style="text-align: center; white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><span style="letter-spacing: 0.4px; font-size: 12px; color: rgb(208, 208, 208); box-sizing: border-box;">马桶粘胶处发霉</span></div><br/></section></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="1.0771812" data-w="596" src="https://img1.dxycdn.com/2021/0702/920/6205647457378410943-68.png" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="margin: 0px; position: static; box-sizing: border-box;"><section style="line-height: 1.8; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><div style="text-align: center; white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><span style="letter-spacing: 0.4px; font-size: 12px; color: rgb(208, 208, 208); box-sizing: border-box;">厨房瓷砖</span></div></section></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="1.3948919" data-w="509" src="https://img1.dxycdn.com/2021/0702/714/0405647457378410943-68.png" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="margin: 0px; position: static; box-sizing: border-box;"><section style="line-height: 1.8; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><div style="text-align: center; white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;"><span style="letter-spacing: 0.4px; font-size: 12px; color: rgb(208, 208, 208); box-sizing: border-box;">洗衣机硅胶圈</span><br style="box-sizing: border-box;"/></div><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">操作同样简单,只需要把它均匀涂抹在发霉处<span style="color: rgb(154, 154, 154); box-sizing: border-box;">(厚度 3 mm 左右)</span>。</div><br/></section></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="0.5625" data-w="480" src="https://img1.dxycdn.com/2021/0702/474/9687564969378410943-68.gif" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="margin: 0px; position: static; box-sizing: border-box;"><section style="line-height: 1.8; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">然后静待 3~5 小时,用湿抹布擦去即可。<span style="color: rgb(154, 154, 154); box-sizing: border-box;">(若霉菌严重,可以延长等待时间或重复使用。)</span></div><br/></section></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="0.5625" data-w="480" src="https://img1.dxycdn.com/2021/0702/496/9097564969378410943-68.gif" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="margin: 0px; position: static; box-sizing: border-box;"><section style="line-height: 1.8; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><br/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">家里冰箱、洗衣机、瓷砖、水槽等多种发霉地方都可以使用。</div></section></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="0.9413093" data-w="443" src="https://img1.dxycdn.com/2021/0702/186/1278494969378410943-68.png" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="margin: 0px; position: static; box-sizing: border-box;"><section style="line-height: 1.8; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><br style="box-sizing: border-box;"/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">除霉效果好的同时,还对大肠埃希氏菌和金黄色葡萄球菌的抑菌率超过 99% ;</div><br/><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">且添加了防霉成分,对巴西曲霉、绳状青霉、出芽短梗霉、球毛壳绿色木霉有 28 天的抑菌效果。</div></section></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="0.4472222" data-w="1080" src="https://img1.dxycdn.com/2021/0702/457/5287564969378410943-68.jpg" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="margin: 0px; position: static; box-sizing: border-box;"><section style="line-height: 1.8; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><span style="letter-spacing: 0.4px; box-sizing: border-box;"> </span><div style="white-space: normal; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box;">对瓷砖、黄铜、不锈钢等常见材料 0 腐蚀。</div></section></section><section powered-by="xiumi.us" style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></section><section powered-by="xiumi.us" style="text-align: center; margin-top: 10px; margin-bottom: 10px; position: static; box-sizing: border-box;"><section style="max-width: 100%; vertical-align: middle; display: inline-block; line-height: 0; box-sizing: border-box;"><img class="raw-image" data-ratio="0.7993019" data-w="573" src="https://img1.dxycdn.com/2021/0702/119/0678494969378410943-68.png" style="vertical-align: middle; box-sizing: border-box;"/></section></section><section powered-by="xiumi.us" style="margin: 0px; position: static; box-sizing: border-box;"><section style="line-height: 1.8; letter-spacing: 0.4px; padding: 0px; box-sizing: border-box;"><span style="letter-spacing: 0.4px; box-sizing: border-box;"> </span><span style="letter-spacing: 0.4px; box-sizing: border-box;"> </span><div style="margin-top: 0px; margin-bottom: 0px; white-space: normal; padding: 0px; box-sizing: border-box;">饱受家中发霉困扰的朋友请速速拿下,记得回来反馈使用效果哦~</div><div style="margin-top: 0px; margin-bottom: 0px; white-space: normal; padding: 0px; box-sizing: border-box;"><br style="color: rgb(84, 84, 84); letter-spacing: 0.4px; text-align: justify;"/></div></section></section><p></p><p><br/></p>`; | ||
| const html = `<p></p>`; | ||
| const data = new MiniParser({ html }); | ||
| console.log(data); |
+10
-6
@@ -297,9 +297,13 @@ import { | ||
| const hasImage = !!children.find((item) => this.transToBlock(item)); | ||
| // 如果存在子元素且当前元素非块级元素时 | ||
| if (hasImage && display !== "block") { | ||
| // 如果存在子元素且当前元素非块级元素,且不存在宽度时 | ||
| if ( | ||
| hasImage && | ||
| display !== "block" && | ||
| attrs && | ||
| attrs.styleObj && | ||
| !("width" in attrs.styleObj) | ||
| ) { | ||
| skeleton.display = "block"; | ||
| if (attrs && attrs.styleObj && attrs.styleObj.display) { | ||
| attrs.styleObj.display = "block"; | ||
| attrs.style += ";display:block"; | ||
| } | ||
| attrs.styleObj.display = "block"; | ||
| attrs.style += ";display:block"; | ||
| } | ||
@@ -306,0 +310,0 @@ return hasImage; |
+1
-1
@@ -131,3 +131,3 @@ exports.elementType = { | ||
| attrs: {}, | ||
| display: "block", | ||
| display: "inline", | ||
| type: "default", | ||
@@ -134,0 +134,0 @@ children: [ |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
3
-25%2
-33.33%57462
-26.05%1092
-6.1%