%PDF- %PDF-
Direktori : /var/www/html/node_modules/html-react-parser/ |
Current File : //var/www/html/node_modules/html-react-parser/index.js |
var domToReact = require('./lib/dom-to-react'); var attributesToProps = require('./lib/attributes-to-props'); var htmlToDOM = require('html-dom-parser'); // support backwards compatibility for ES Module htmlToDOM = /* istanbul ignore next */ typeof htmlToDOM.default === 'function' ? htmlToDOM.default : htmlToDOM; var domParserOptions = { lowerCaseAttributeNames: false }; /** * Converts HTML string to React elements. * * @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. * @returns {JSX.Element|JSX.Element[]|string} - React element(s), empty array, or string. */ function HTMLReactParser(html, options) { if (typeof html !== 'string') { throw new TypeError('First argument must be a string'); } if (html === '') { return []; } options = options || {}; return domToReact( htmlToDOM(html, options.htmlparser2 || domParserOptions), options ); } HTMLReactParser.domToReact = domToReact; HTMLReactParser.htmlToDOM = htmlToDOM; HTMLReactParser.attributesToProps = attributesToProps; HTMLReactParser.Element = require('domhandler').Element; // support CommonJS and ES Modules module.exports = HTMLReactParser; module.exports.default = HTMLReactParser;