react-htmlcontent
Advanced tools
Comparing version 1.2.6 to 1.2.8
@@ -12,4 +12,4 @@ "use strict"; | ||
var containsHtmlPatt = /([^<]*)(<[A-z]*[^>]*>)(.*?)(<\/[A-z]+>)([^<]*)?/g; | ||
var replaceHtmlContentPatt = /^([^<]{0,})(<([A-z])+[^>]*>)(.*)(<\/\3>)([^<]{0,})$/gi; | ||
var containsHtmlPatt = /([^<]*)(<[A-z]*[^>]*>)(.*)(<\/[A-z]+>)([^<]*)?/gi; | ||
var replaceHtmlContentPatt = /([^<]+\s*)?(<([A-z])+[^>]*\/?>)([^<]+\s*)(<\/\3>)(\s?[^<]+)?/gi; | ||
@@ -20,3 +20,3 @@ function handleNbspBeforeTag(str) { | ||
if (arr.length >= 2) { | ||
return arr[arr.length - 1] === '' && arr[arr.length - 2].length === 1 ? ' ' : ' '; | ||
return arr[arr.length - 1] === '' && arr[arr.length - 2].length === 1 || arr[0] === '' && arr[1].length === 1 ? ' ' : ' '; | ||
} else { | ||
@@ -33,8 +33,10 @@ return ''; | ||
if (containsHtmlPatt.test(data)) { | ||
return data.replace(replaceHtmlContentPatt, function (_, beforeTag, startTag, tagName, body, endTag, afterTag) { | ||
// console.log('-----------------------') | ||
// console.log('str: ' + data) | ||
// console.log('beforeTag: ' + beforeTag) | ||
// console.log('body: ' + body) | ||
// console.log('afterTag: ' + afterTag) | ||
return data.replace(replaceHtmlContentPatt, function (_) { | ||
var beforeTag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var startTag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
var tagName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ''; | ||
var body = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : ''; | ||
var endTag = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : ''; | ||
var afterTag = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : ''; | ||
if (containsHtmlPatt.test(body)) { | ||
@@ -47,3 +49,5 @@ return enhanceTypo(body, locale, config); | ||
} else { | ||
return (0, _typography.default)(data, locale, config); | ||
var before = data.replace(/^(\s*).+/, '$1'); | ||
var after = data.replace(/^.+(\s*)$/, '$1'); | ||
return "".concat(before).concat((0, _typography.default)(data, locale, config)).concat(after); | ||
} | ||
@@ -61,5 +65,2 @@ } | ||
var r = enhanceTypo.apply(void 0, [str].concat(rest)); | ||
r = r.replace(/(\s|>)([A-z])\s<*/gi, '$1$2 <'); | ||
console.log(r); | ||
console.log(r.replace(/(\s|>)([A-z])\s<*/gi, '$1$2 <')); | ||
return r; | ||
@@ -66,0 +67,0 @@ }; |
{ | ||
"name": "react-htmlcontent", | ||
"version": "1.2.6", | ||
"version": "1.2.8", | ||
"description": "React HTMLContent Component", | ||
@@ -27,2 +27,3 @@ "repository": { | ||
"@babel/preset-env": "^7.5.4", | ||
"@babel/preset-flow": "^7.0.0", | ||
"@babel/preset-react": "^7.0.0", | ||
@@ -35,2 +36,3 @@ "@babel/preset-stage-0": "^7.0.0", | ||
"chai": "^4.2.0", | ||
"core-js": "3.1.4", | ||
"enzyme": "^3.10.0", | ||
@@ -46,5 +48,3 @@ "eslint": "^6.0.1", | ||
"react-dom": "^16.8.6", | ||
"sinon": "^7.3.2", | ||
"@babel/preset-flow": "^7.0.0", | ||
"core-js": "3.1.4" | ||
"sinon": "^7.3.2" | ||
}, | ||
@@ -54,3 +54,5 @@ "peerDependencies": { | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"sanitize-html": "^1.20.1" | ||
}, | ||
"main": "dist/index.js", | ||
@@ -57,0 +59,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
655582
70
2919
2
+ Addedsanitize-html@^1.20.1
+ Addeddom-serializer@1.4.1(transitive)
+ Addeddomelementtype@2.3.0(transitive)
+ Addeddomhandler@3.3.04.3.1(transitive)
+ Addeddomutils@2.8.0(transitive)
+ Addedentities@2.2.0(transitive)
+ Addedhtmlparser2@4.1.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedparse-srcset@1.0.2(transitive)
+ Addedpicocolors@0.2.1(transitive)
+ Addedpostcss@7.0.39(transitive)
+ Addedsanitize-html@1.27.5(transitive)
+ Addedsource-map@0.6.1(transitive)