Spaces:
Build error
Build error
File size: 2,292 Bytes
c211499 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import { Parser } from "./Parser.js";
export { Parser } from "./Parser.js";
import { DomHandler, } from "domhandler";
export { DomHandler,
// Old name for DomHandler
DomHandler as DefaultHandler, } from "domhandler";
// Helper methods
/**
* Parses the data, returns the resulting document.
*
* @param data The data that should be parsed.
* @param options Optional options for the parser and DOM builder.
*/
export function parseDocument(data, options) {
const handler = new DomHandler(undefined, options);
new Parser(handler, options).end(data);
return handler.root;
}
/**
* Parses data, returns an array of the root nodes.
*
* Note that the root nodes still have a `Document` node as their parent.
* Use `parseDocument` to get the `Document` node instead.
*
* @param data The data that should be parsed.
* @param options Optional options for the parser and DOM builder.
* @deprecated Use `parseDocument` instead.
*/
export function parseDOM(data, options) {
return parseDocument(data, options).children;
}
/**
* Creates a parser instance, with an attached DOM handler.
*
* @param callback A callback that will be called once parsing has been completed.
* @param options Optional options for the parser and DOM builder.
* @param elementCallback An optional callback that will be called every time a tag has been completed inside of the DOM.
*/
export function createDomStream(callback, options, elementCallback) {
const handler = new DomHandler(callback, options, elementCallback);
return new Parser(handler, options);
}
export { default as Tokenizer, } from "./Tokenizer.js";
/*
* All of the following exports exist for backwards-compatibility.
* They should probably be removed eventually.
*/
export * as ElementType from "domelementtype";
import { getFeed } from "domutils";
export { getFeed } from "domutils";
const parseFeedDefaultOptions = { xmlMode: true };
/**
* Parse a feed.
*
* @param feed The feed that should be parsed, as a string.
* @param options Optionally, options for parsing. When using this, you should set `xmlMode` to `true`.
*/
export function parseFeed(feed, options = parseFeedDefaultOptions) {
return getFeed(parseDOM(feed, options));
}
export * as DomUtils from "domutils";
//# sourceMappingURL=index.js.map |