Skip to content

Commit

Permalink
feat(index): add options.htmlparser2
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jun 3, 2020
1 parent cfb4ec8 commit c4ecf64
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var domParserOptions = { decodeEntities: true, lowerCaseAttributeNames: false };
*
* @param {String} html - HTML string.
* @param {Object} [options] - Parser options.
* @param {Object} [options.htmlparser2] - htmlparser2 options.
* @param {Object} [options.library] - Library for React, Preact, etc.
* @param {Function} [options.replace] - Replace method.
* @return {JSX.Element|JSX.Element[]|String} - React element(s), empty array, or string.
Expand All @@ -20,7 +21,11 @@ function HTMLReactParser(html, options) {
if (html === '') {
return [];
}
return domToReact(htmlToDOM(html, domParserOptions), options);
options = options || {};
return domToReact(
htmlToDOM(html, options.htmlparser2 || domParserOptions),
options
);
}

HTMLReactParser.domToReact = domToReact;
Expand Down

0 comments on commit c4ecf64

Please sign in to comment.