UNPKG

1.71 kBTypeScriptView Raw
1import { NodeText, NodeTag } from 'posthtml-parser';
2
3declare enum quoteStyleEnum {
4 Smart = 0,
5 Single = 1,
6 Double = 2
7}
8declare enum closingSingleTagOptionEnum {
9 tag = "tag",
10 slash = "slash",
11 default = "default",
12 closeAs = "closeAs"
13}
14declare enum closingSingleTagTypeEnum {
15 tag = "tag",
16 slash = "slash",
17 default = "default"
18}
19declare type Node = NodeText | NodeTag & {
20 closeAs?: closingSingleTagTypeEnum;
21};
22declare type Options = {
23 /**
24 * Custom single tags (selfClosing).
25 *
26 * @default []
27 */
28 singleTags?: Array<string | RegExp>;
29 /**
30 * Closing format for single tag.
31 *
32 * Formats:
33 *
34 * tag: `<br></br>`, slash: `<br />`, default: `<br>`
35 *
36 */
37 closingSingleTag?: closingSingleTagOptionEnum;
38 /**
39 * If all attributes should be quoted.
40 * Otherwise attributes will be unquoted when allowed.
41 *
42 * @default true
43 */
44 quoteAllAttributes?: boolean;
45 /**
46 * Replaces quotes in attribute values with `&quote;`.
47 *
48 * @default true
49 */
50 replaceQuote?: boolean;
51 /**
52 * Quote style
53 *
54 * 0 - Smart quotes
55 * <img src="https://example.com/example.png" onload='testFunc("test")'>
56 * 1 - Single quotes
57 * <img src='https://example.com/example.png' onload='testFunc("test")'>
58 * 2 - double quotes
59 * <img src="https://example.com/example.png" onload="testFunc("test")">
60 *
61 * @default 2
62 */
63 quoteStyle?: quoteStyleEnum;
64};
65declare function render(tree?: Node | Node[], options?: Options): string;
66
67export { Node, Options, closingSingleTagOptionEnum, closingSingleTagTypeEnum, quoteStyleEnum, render };