diff --git a/CHANGELOG.md b/CHANGELOG.md
index 32bbf214..33d27a41 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+### [1.1.1](https://github.com/remarkablemark/html-react-parser/compare/v1.1.0...v1.1.1) (2020-12-27)
+
+
+### Bug Fixes
+
+* escape tags inside of `
', {
});
```
-For TypeScript projects, check that `domNode` is an instance of domhandler's `Element`:
+For TypeScript projects, you may need to check that `domNode` is an instance of domhandler's `Element`:
```tsx
-import parse, { Element } from 'html-react-parser';
+import { HTMLReactParserOptions } from 'html-react-parser';
+import { Element } from 'domhandler/lib/node';
-parse('
text
', {
+const options: HTMLReactParserOptions = {
replace: domNode => {
- if (domNode instanceof Element && domNode.attribs.id === 'replace') {
- return replaced;
+ if (domNode instanceof Element && domNode.attribs) {
+ // ...
}
}
-});
+};
```
The following [example](https://repl.it/@remarkablemark/html-react-parser-replace-example) modifies the element along with its children:
@@ -313,23 +314,21 @@ parse(' ', {
### htmlparser2
-The default [htmlparser2 options](https://github.com/fb55/htmlparser2/wiki/Parser-options) are:
+Along with the default [htmlparser2 options](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-xmlmode), the parser also sets:
-```js
+```json
{
- decodeEntities: true,
- lowerCaseAttributeNames: false
+ "lowerCaseAttributeNames": false
}
```
Since [v0.12.0](https://github.com/remarkablemark/html-react-parser/tree/v0.12.0), the htmlparser2 options can be overridden.
-The following example enables [`decodeEntities`](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-decodeentities) and [`xmlMode`](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-xmlmode):
+The following example enables [`xmlMode`](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-xmlmode) but disables [`lowerCaseAttributeNames`](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-lowercaseattributenames):
```js
parse('', {
htmlparser2: {
- decodeEntities: true,
xmlMode: true
}
});
@@ -367,12 +366,12 @@ parse('
', { trim: true }); // React.createElement('p')
### v1.0.0
-TypeScript projects will need to check the types in [v1.0.0](https://github.com/remarkablemark/html-react-parser/releases/tag/v1.0.0).
+TypeScript projects will need to update the types in [v1.0.0](https://github.com/remarkablemark/html-react-parser/releases/tag/v1.0.0).
-For `replace` option:
+For the `replace` option, you may need to do the following:
```tsx
-import parse, { Element } from 'html-react-parser';
+import { Element } from 'domhandler/lib/node';
parse(' ', {
replace: domNode => {
@@ -446,7 +445,7 @@ See [#62](https://github.com/remarkablemark/html-react-parser/issues/62) and [ex
### TS Error: Property 'attribs' does not exist on type 'DOMNode'
-The TypeScript error happens because `DOMNode` needs be an instance of domhandler's `Element`. See [migration](#migration) or [#199](https://github.com/remarkablemark/html-react-parser/issues/199).
+The TypeScript error occurs because `DOMNode` needs be an instance of domhandler's `Element`. See [migration](#migration) or [#199](https://github.com/remarkablemark/html-react-parser/issues/199).
## Performance
diff --git a/index.js b/index.js
index c66fbbdf..3929d5a5 100644
--- a/index.js
+++ b/index.js
@@ -2,8 +2,7 @@ var domToReact = require('./lib/dom-to-react');
var attributesToProps = require('./lib/attributes-to-props');
var htmlToDOM = require('html-dom-parser');
-// decode HTML entities by default for `htmlparser2`
-var domParserOptions = { decodeEntities: true, lowerCaseAttributeNames: false };
+var domParserOptions = { lowerCaseAttributeNames: false };
/**
* Converts HTML string to React elements.
diff --git a/package.json b/package.json
index 78608284..2cd1b8a5 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "html-react-parser",
- "version": "1.1.0",
+ "version": "1.1.1",
"description": "HTML to React parser.",
"author": "Mark ",
"main": "index.js",
@@ -32,7 +32,7 @@
"dom"
],
"dependencies": {
- "html-dom-parser": "0.5.0",
+ "html-dom-parser": "1.0.0",
"react-property": "1.0.1",
"style-to-js": "1.1.0"
},
diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap
index 658946d3..772788cd 100644
--- a/test/__snapshots__/index.test.js.snap
+++ b/test/__snapshots__/index.test.js.snap
@@ -1,5 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`HTMLReactParser escapes tags inside of 1`] = `
+
+ <em>text</em>
+
+`;
+
exports[`HTMLReactParser parses SVG 1`] = `
',
comment: '',
doctype: '',
+ title: 'text',
customElement:
''
};
diff --git a/test/index.test.js b/test/index.test.js
index 59f0ba5f..4ceb844c 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -75,6 +75,10 @@ describe('HTMLReactParser', () => {
const reactElement = parse('' + encodedEntities + '');
expect(reactElement.props.children).toBe(decodedEntities);
});
+
+ it('escapes tags inside of ', () => {
+ expect(parse(html.title)).toMatchSnapshot();
+ });
});
describe('replace option', () => {