How to use the domhandler.DomHandler function in domhandler

To help you get started, we’ve selected a few domhandler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ng-alain / delon / packages / schematics / ng-update / dom / dom.service.ts View on Github external
replace(html: string, rules: ConvertAction[], callback: (dom: VDom[], count: number) => void) {
    this.rules = rules;
    this.count = 0;
    const handler = new DomHandler((error, dom) => {
      if (error) {
        callback(null!, 0);
        return;
      }

      this.dom = dom;
      this.parseRule();

      callback(this.dom, this.count);
    });

    const parser = new htmlparser2.Parser(handler, {
      lowerCaseTags: false,
      lowerCaseAttributeNames: false,
      // tslint:disable-next-line: deprecation
    } as htmlparser2.ParserOptions);
github DefinitelyTyped / DefinitelyTyped / types / domhandler / domhandler-tests.ts View on Github external
import { DomHandler, DomHandlerOptions, Node, DomElement } from "domhandler";

const handler = new DomHandler((error: Error, dom: DomElement[]) => {
    if (error)
    	console.error('There has been an error...');
    else
        console.log(dom);
});
handler.ontext = (data: string) => { console.log(data); };
handler.onreset = () => { console.log('We have a reset.'); };
handler.onerror = (error: Error) => { console.error(error); };
handler.onopentag = (name: string, attribs: { [s: string]: string }) => { console.log(name, attribs); };

const dho: DomHandlerOptions = { normalizeWhitespace: true, withDomLvl1: true, withEndIndices: true, withStartIndices: true };
github AndriySvyryd / UnicornHack / src / UnicornHack.Web / ClientApp / src / components / MetadataDisplay.tsx View on Github external
export function parseMetadata(input: string): React.ReactNode[] {
    const handler = new DomHandler(null as any);
    new Parser(handler).end(input);

    return processNodes((handler as any).dom);
}

domhandler

Handler for htmlparser2 that turns pages into a dom

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

78 / 100
Full package analysis