CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
index.js43 linesDownload Raw Back to dist
1import { Parser } from './parser/index.js';2export { defaultTreeAdapter } from './tree-adapters/default.js';3export { /** @internal */ Parser } from './parser/index.js';4export { serialize, serializeOuter } from './serializer/index.js';5export { ERR as ErrorCodes } from './common/error-codes.js';6/** @internal */7export * as foreignContent from './common/foreign-content.js';8export * as html from './common/html.js';9export * as Token from './common/token.js';10/** @internal */11export { Tokenizer, TokenizerMode } from './tokenizer/index.js';12// Shorthands13/**14 * Parses an HTML string.15 *16 * @param html Input HTML string.17 * @param options Parsing options.18 * @returns Document19 *20 * @example21 *22 * ```js23 * const parse5 = require('parse5');24 *25 * const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');26 *27 * console.log(document.childNodes[1].tagName); //> 'html'28 *```29 */30export function parse(html, options) {31    return Parser.parse(html, options);32}33export function parseFragment(fragmentContext, html, options) {34    if (typeof fragmentContext === 'string') {35        options = html;36        html = fragmentContext;37        fragmentContext = null;38    }39    const parser = Parser.getFragmentParser(fragmentContext, options);40    parser.tokenizer.write(html, true);41    return parser.getFragment();42}43 
basant307/AI_Governance_Project · CoolFace