liusuyi
2023-04-24 4737f1e038743ced243c9e52423404d9034d6107
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
declare namespace render {
  type Options = {
    /**
     * Custom single tags (selfClosing).
     *
     * @default []
     */
    singleTags: string[] | RegExp[];
 
    /**
     * Closing format for single tag.
     *
     * Formats:
     *
     * tag: `<br></br>`, slash: `<br />`, default: `<br>`
     *
     */
    closingSingleTag: 'tag' | 'slash';
 
    /**
     * If all attributes should be quoted.
     * Otherwise attributes will be unquoted when allowed.
     *
     * @default true
     */
    quoteAllAttributes: boolean;
 
    /**
     * Quote style
     *
     * 0 - Smart quotes
     *   <img src="https://example.com/example.png" onload='testFunc("test")'>
     * 1 - Single quotes
     *   <img src='https://example.com/example.png' onload='testFunc("test")'>
     * 2 - double quotes
     *   <img src="https://example.com/example.png" onload="testFunc("test")">
     *
     * @default 2
     */
    quoteStyle: 0 | 1 | 2
  };
 
  // PostHTML Tree
  type Tree = Node[];
  type Node = NodeText | NodeTag;
  type NodeText = string;
  type NodeTag = {
    tag: string;
    attrs?: Attributes;
    content?: Node[];
  };
 
  type Attributes = Record<string, string>;
}
 
/**
 * Render PostHTML Tree to HTML
 * @param tree PostHTML Tree
 * @param options Render options
 * @returns HTML
 */
declare function render(
  tree: render.Tree,
  options?: Partial<render.Options>
): string;
 
export = render;