load-parse.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.load = void 0;
  7. const load_js_1 = require("./load.js");
  8. const parse_js_1 = require("./parse.js");
  9. const parse5_adapter_js_1 = require("./parsers/parse5-adapter.js");
  10. const dom_serializer_1 = __importDefault(require("dom-serializer"));
  11. const htmlparser2_1 = require("htmlparser2");
  12. const parse = (0, parse_js_1.getParse)((content, options, isDocument, context) => options._useHtmlParser2
  13. ? (0, htmlparser2_1.parseDocument)(content, options)
  14. : (0, parse5_adapter_js_1.parseWithParse5)(content, options, isDocument, context));
  15. // Duplicate docs due to https://github.com/TypeStrong/typedoc/issues/1616
  16. /**
  17. * Create a querying function, bound to a document created from the provided
  18. * markup.
  19. *
  20. * Note that similar to web browser contexts, this operation may introduce
  21. * `<html>`, `<head>`, and `<body>` elements; set `isDocument` to `false` to
  22. * switch to fragment mode and disable this.
  23. *
  24. * @category Loading
  25. * @param content - Markup to be loaded.
  26. * @param options - Options for the created instance.
  27. * @param isDocument - Allows parser to be switched to fragment mode.
  28. * @returns The loaded document.
  29. * @see {@link https://cheerio.js.org#loading} for additional usage information.
  30. */
  31. exports.load = (0, load_js_1.getLoad)(parse, (dom, options) => options._useHtmlParser2
  32. ? (0, dom_serializer_1.default)(dom, options)
  33. : (0, parse5_adapter_js_1.renderWithParse5)(dom));
  34. //# sourceMappingURL=load-parse.js.map