posthtml-parser
Version:
Parse HTML/XML to PostHTMLTree
25 lines (24 loc) • 809 B
TypeScript
import type { ParserOptions } from "htmlparser2" with { "resolution-mode": "import" };
import { SourceLocation } from "./location-tracker";
export type Directive = {
name: string | RegExp;
start: string;
end: string;
};
export type Options = {
directives?: Directive[];
sourceLocations?: boolean;
recognizeNoValueAttribute?: boolean;
} & ParserOptions;
export type Tag = string | boolean;
export type Attributes = Record<string, string | number | boolean>;
export type Content = NodeText | Array<Node | Node[]>;
export type NodeText = string | number;
export type NodeTag = {
tag?: Tag;
attrs?: Attributes;
content?: Content;
location?: SourceLocation;
};
export type Node = NodeText | NodeTag;
export declare const parser: (html: string, options?: Options) => Node[];