File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,8 @@ Parser('<p id="replace">text</p>', {
120
120
});
121
121
```
122
122
123
- Here's an [ example] ( https://repl.it/@remarkablemark/html-react-parser-replace-example ) that replaces but keeps the children:
124
- ``` js
123
+ Here's an [ example] ( https://repl.it/@remarkablemark/html-react-parser-replace-example ) of using ` replace ` to modify the children:
124
+ ``` jsx
125
125
// with ES6 and JSX
126
126
import domToReact from ' html-react-parser/lib/dom-to-react' ;
127
127
@@ -166,6 +166,17 @@ ReactDOMServer.renderToStaticMarkup(reactElement);
166
166
</h1 >
167
167
```
168
168
169
+ Here's an [ example] ( https://repl.it/@remarkablemark/html-react-parser-issue-56 ) of using ` replace ` to exclude an element:
170
+ ``` js
171
+ Parser (' <p><br id="remove"></p>' , {
172
+ replace : ({ attribs }) => {
173
+ if (attribs && attribs .id === ' remove' ) {
174
+ return React .createElement (React .Fragment );
175
+ }
176
+ },
177
+ });
178
+ ```
179
+
169
180
## Testing
170
181
171
182
``` sh
You can’t perform that action at this time.
0 commit comments