Skip to content

Update html-parse-stringify.d.ts #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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;
}