From d020e06b7db47f00dbad0b7ca72b0d65efa54a22 Mon Sep 17 00:00:00 2001 From: Jiang Fengming Date: Thu, 27 May 2021 13:57:27 +0800 Subject: [PATCH 1/2] Update html-parse-stringify.d.ts --- html-parse-stringify.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html-parse-stringify.d.ts b/html-parse-stringify.d.ts index f3a6e9d..821cf5c 100644 --- a/html-parse-stringify.d.ts +++ b/html-parse-stringify.d.ts @@ -4,7 +4,7 @@ declare module htmlParseStringify { export interface htmlParseStringify { new (): htmlParseStringify parse_tag(tag: string): IDoc - parse(html: string, options: IOptions): Array + parse(html: string, options?: IOptions): Array stringify(doc: IDoc): string } @@ -13,7 +13,7 @@ declare module htmlParseStringify { content?: string voidElement: boolean name: string - attrs: {} + attrs: Record children: IDoc[] } From fc9c190b1915dab60e7c530f95d21551786ad335 Mon Sep 17 00:00:00 2001 From: "fenix.sol" Date: Tue, 18 Oct 2022 10:20:27 +0800 Subject: [PATCH 2/2] Update html-parse-stringify.d.ts --- html-parse-stringify.d.ts | 46 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/html-parse-stringify.d.ts b/html-parse-stringify.d.ts index 821cf5c..d76ccff 100644 --- a/html-parse-stringify.d.ts +++ b/html-parse-stringify.d.ts @@ -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; + children: Node[]; + } -declare module htmlParseStringify { - export interface htmlParseStringify { - new (): htmlParseStringify - parse_tag(tag: string): IDoc - parse(html: string, options?: IOptions): Array - stringify(doc: IDoc): string + export interface TextNode { + type: 'text'; + content: string; } - export interface IDoc { - type: string - content?: string - voidElement: boolean - name: string - attrs: Record - children: IDoc[] + export interface ComponentNode { + type: 'component'; + name: string; + attrs: Record; + voidElement: boolean; + children: []; } - export interface IOptions { - components: string[] + export type Node = TagNode | TextNode | ComponentNode; + + export interface ParseOptions { + components: Record; } -} -declare module 'html-parse-stringify' { - export = htmlParseStringify + namespace HtmlParseStringify { + function parse(html: string, options?: ParseOptions): Node[]; + function stringify(doc: Node[]): string; + } + + export default HtmlParseStringify; }