@types/html-parse-stringify 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
@@ -0,0 +1,111 @@
1
+ # Installation
2
+ > `npm install --save @types/html-parse-stringify`
3
+
4
+ # Summary
5
+ This package contains type definitions for html-parse-stringify (https://github.com/henrikjoreteg/html-parse-stringify).
6
+
7
+ # Details
8
+ Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/html-parse-stringify.
9
+ ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/html-parse-stringify/index.d.ts)
10
+ ````ts
11
+ /**
12
+ * Attributes object for a tag node.
13
+ */
14
+ export interface Attributes {
15
+ [key: string]: string;
16
+ }
17
+
18
+ /**
19
+ * A tag node in the AST.
20
+ */
21
+ export interface TagNode {
22
+ type: "tag";
23
+ name: string;
24
+ attrs: Attributes;
25
+ voidElement: boolean;
26
+ children: ASTNode[];
27
+ }
28
+
29
+ /**
30
+ * A text node in the AST.
31
+ */
32
+ export interface TextNode {
33
+ type: "text";
34
+ content: string;
35
+ }
36
+
37
+ /**
38
+ * A comment node in the AST.
39
+ */
40
+ export interface CommentNode {
41
+ type: "comment";
42
+ comment: string;
43
+ }
44
+
45
+ /**
46
+ * A component node in the AST.
47
+ * Similar to tag but children are ignored during parsing.
48
+ */
49
+ export interface ComponentNode {
50
+ type: "component";
51
+ name: string;
52
+ attrs: Attributes;
53
+ voidElement: boolean;
54
+ children: ASTNode[];
55
+ }
56
+
57
+ /**
58
+ * Any AST node type.
59
+ */
60
+ export type ASTNode = TagNode | TextNode | CommentNode | ComponentNode;
61
+
62
+ /**
63
+ * Options for parsing HTML.
64
+ */
65
+ export interface ParseOptions {
66
+ /**
67
+ * Object of registered component names whose children will be ignored
68
+ * when generating the AST.
69
+ */
70
+ components?: {
71
+ [componentName: string]: boolean | object;
72
+ };
73
+ }
74
+
75
+ /**
76
+ * Parses a string of HTML into an AST.
77
+ *
78
+ * @param html - The HTML string to parse
79
+ * @param options - Parse options
80
+ * @returns An array of AST nodes
81
+ *
82
+ * @example
83
+ * ```javascript
84
+ * var HTML = require('html-parse-stringify');
85
+ * var ast = HTML.parse('<div class="oh"><p>hi</p></div>');
86
+ * ```
87
+ */
88
+ export function parse(html: string, options?: ParseOptions): ASTNode[];
89
+
90
+ /**
91
+ * Stringifies an AST back to HTML.
92
+ *
93
+ * @param ast - The AST to stringify
94
+ * @returns The HTML string
95
+ *
96
+ * @example
97
+ * ```javascript
98
+ * var HTML = require('html-parse-stringify');
99
+ * var html = HTML.stringify(ast);
100
+ * ```
101
+ */
102
+ export function stringify(ast: ASTNode[]): string;
103
+
104
+ ````
105
+
106
+ ### Additional Details
107
+ * Last updated: Thu, 05 Feb 2026 08:45:22 GMT
108
+ * Dependencies: none
109
+
110
+ # Credits
111
+ These definitions were written by [gaspard](https://github.com/gasp).
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Attributes object for a tag node.
3
+ */
4
+ export interface Attributes {
5
+ [key: string]: string;
6
+ }
7
+
8
+ /**
9
+ * A tag node in the AST.
10
+ */
11
+ export interface TagNode {
12
+ type: "tag";
13
+ name: string;
14
+ attrs: Attributes;
15
+ voidElement: boolean;
16
+ children: ASTNode[];
17
+ }
18
+
19
+ /**
20
+ * A text node in the AST.
21
+ */
22
+ export interface TextNode {
23
+ type: "text";
24
+ content: string;
25
+ }
26
+
27
+ /**
28
+ * A comment node in the AST.
29
+ */
30
+ export interface CommentNode {
31
+ type: "comment";
32
+ comment: string;
33
+ }
34
+
35
+ /**
36
+ * A component node in the AST.
37
+ * Similar to tag but children are ignored during parsing.
38
+ */
39
+ export interface ComponentNode {
40
+ type: "component";
41
+ name: string;
42
+ attrs: Attributes;
43
+ voidElement: boolean;
44
+ children: ASTNode[];
45
+ }
46
+
47
+ /**
48
+ * Any AST node type.
49
+ */
50
+ export type ASTNode = TagNode | TextNode | CommentNode | ComponentNode;
51
+
52
+ /**
53
+ * Options for parsing HTML.
54
+ */
55
+ export interface ParseOptions {
56
+ /**
57
+ * Object of registered component names whose children will be ignored
58
+ * when generating the AST.
59
+ */
60
+ components?: {
61
+ [componentName: string]: boolean | object;
62
+ };
63
+ }
64
+
65
+ /**
66
+ * Parses a string of HTML into an AST.
67
+ *
68
+ * @param html - The HTML string to parse
69
+ * @param options - Parse options
70
+ * @returns An array of AST nodes
71
+ *
72
+ * @example
73
+ * ```javascript
74
+ * var HTML = require('html-parse-stringify');
75
+ * var ast = HTML.parse('<div class="oh"><p>hi</p></div>');
76
+ * ```
77
+ */
78
+ export function parse(html: string, options?: ParseOptions): ASTNode[];
79
+
80
+ /**
81
+ * Stringifies an AST back to HTML.
82
+ *
83
+ * @param ast - The AST to stringify
84
+ * @returns The HTML string
85
+ *
86
+ * @example
87
+ * ```javascript
88
+ * var HTML = require('html-parse-stringify');
89
+ * var html = HTML.stringify(ast);
90
+ * ```
91
+ */
92
+ export function stringify(ast: ASTNode[]): string;
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@types/html-parse-stringify",
3
+ "version": "3.0.0",
4
+ "description": "TypeScript definitions for html-parse-stringify",
5
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/html-parse-stringify",
6
+ "license": "MIT",
7
+ "contributors": [
8
+ {
9
+ "name": "gaspard",
10
+ "githubUsername": "gasp",
11
+ "url": "https://github.com/gasp"
12
+ }
13
+ ],
14
+ "main": "",
15
+ "types": "index.d.ts",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
19
+ "directory": "types/html-parse-stringify"
20
+ },
21
+ "scripts": {},
22
+ "dependencies": {},
23
+ "peerDependencies": {},
24
+ "typesPublisherContentHash": "28fecef6d8048dd92b6d3c353b4d16722b543f20737285d66f083c2888940b8a",
25
+ "typeScriptVersion": "5.2"
26
+ }