Skip to content

Commit

Permalink
fixed 图片大小不正确
Browse files Browse the repository at this point in the history
1. \n 去掉了,但是\r 留着,整个nodes 还是很大
2. 其实图片大小不正确的最主要原因是因为当node为text 的时候,没有index,所以后面calMoreImageInfo 时设置with/height 使用index来定位会出错;如果只是trimHtml的话,当真的有text 节点,图片宽高还是会有问题
  • Loading branch information
issaTan committed Aug 15, 2017
1 parent 956eb4b commit 257b56c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion wxParse/html2json.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function removeDOCTYPE(html) {

function trimHtml(html) {
return html
.replace(/\n+/g, '')
.replace(/\r?\n+/g, '')
.replace(/<!--.*?-->/ig, '')
.replace(/\/\*.*?\*\//ig, '')
.replace(/[ ]+</ig, '<')
Expand Down Expand Up @@ -227,6 +227,8 @@ function html2json(html, bindName) {
};

if (bufArray.length === 0) {
node.index = index.toString()
index += 1
results.nodes.push(node);
} else {
var parent = bufArray[0];
Expand Down

0 comments on commit 257b56c

Please sign in to comment.