Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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 };
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);
}