Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 27 additions & 19 deletions html-parse-stringify.d.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
declare var htmlParseStringify: htmlParseStringify.htmlParseStringify
declare module 'html-parse-stringify' {
export interface TagNode {
type: 'tag';
name: string;
voidElement: boolean;
attrs: Record<string, string | undefined>;
children: Node[];
}

declare module htmlParseStringify {
export interface htmlParseStringify {
new (): htmlParseStringify
parse_tag(tag: string): IDoc
parse(html: string, options: IOptions): Array<any>
stringify(doc: IDoc): string
export interface TextNode {
type: 'text';
content: string;
}

export interface IDoc {
type: string
content?: string
voidElement: boolean
name: string
attrs: {}
children: IDoc[]
export interface ComponentNode {
type: 'component';
name: string;
attrs: Record<string, string | undefined>;
voidElement: boolean;
children: [];
}

export interface IOptions {
components: string[]
export type Node = TagNode | TextNode | ComponentNode;

export interface ParseOptions {
components: Record<string, boolean>;
}
}

declare module 'html-parse-stringify' {
export = htmlParseStringify
namespace HtmlParseStringify {
function parse(html: string, options?: ParseOptions): Node[];
function stringify(doc: Node[]): string;
}

export default HtmlParseStringify;
}