Skip to content

Commit

Permalink
修复某些tag不替换
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaoGongBra committed Jun 7, 2022
1 parent f126e8a commit fee8886
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion components/HtmlView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ const getNodes = (() => {
// 不支持的Style属性
const noStyleValue = ['auto']

// tag替换正则
const tagReg = /&([a-zA-Z0-9]{1,});/g

const getStyleValue = (name, value) => {
if (value?.endsWith('px')) {
return Taro.pxTransform(value.replace('px', '') * 2)
Expand Down Expand Up @@ -345,7 +348,7 @@ const getNodes = (() => {
if (text === '\n' || text === '\n\r') {
return
}
text = text.replace(/&([a-z]{1,});/g, (a, b) => tags[b] || a)
text = text.replace(tagReg, (a, b) => tags[b] || a)
if (bufArray.length === 0) {
results.child.push(text);
} else {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "taro-html-view",
"version": "1.0.2",
"version": "1.0.3",
"description": "支持渲染由富文本编辑器编辑的html文本内容,支持小程序、h5、ReactNative,复杂的内容可能并不能正确渲染",
"main": "index.js",
"author": "[email protected]",
Expand All @@ -14,6 +14,6 @@
},
"homepage": "https://github.com/ShaoGongBra/taro-html-view#readme",
"dependencies": {
"taro-tools": "^1.0.19"
"taro-tools": "^1.0.20"
}
}

0 comments on commit fee8886

Please sign in to comment.