1 | export type Parent = import('hast').Parent
|
2 | export type Literal = import('hast').Literal
|
3 | export type Root = import('hast').Root
|
4 | export type Comment = import('hast').Comment
|
5 | export type Element = import('hast').Element
|
6 | export type Text = import('hast').Text
|
7 | export type Raw = Literal & {
|
8 | type: 'raw'
|
9 | }
|
10 | export type Child = Parent['children'][number]
|
11 | export type Properties = import('hast').Properties
|
12 | export type PropertyValue = Properties[string]
|
13 | export type Node = Child | Root
|
14 | export type StringifyEntitiesOptions =
|
15 | import('stringify-entities').StringifyEntitiesOptions
|
16 | export type Schema = import('property-information').Schema
|
17 | export type Handle = (
|
18 | context: Context,
|
19 | node: Node,
|
20 | index: number | null,
|
21 | parent: Parent | null
|
22 | ) => string
|
23 | export type OmitHandle = (
|
24 | node: Element,
|
25 | index: number | null,
|
26 | parent: Parent | null
|
27 | ) => boolean
|
28 | export type Omission = {
|
29 | opening?: OmitHandle
|
30 | closing?: OmitHandle
|
31 | }
|
32 | export type Space = 'html' | 'svg'
|
33 | export type Quote = '"' | "'"
|
34 | export type Options = {
|
35 | /**
|
36 | * Whether the *root* of the *tree* is in the `'html'` or `'svg'` space. If an `svg` element is found in the HTML space, `toHtml` automatically switches to the SVG space when entering the element, and switches back when exiting
|
37 | */
|
38 | space?: Space
|
39 | /**
|
40 | * Configuration for `stringify-entities`
|
41 | */
|
42 | entities?: Omit<
|
43 | StringifyEntitiesOptions,
|
44 | 'escapeOnly' | 'attribute' | 'subset'
|
45 | >
|
46 | /**
|
47 | * Tag names of *elements* to serialize without closing tag. Not used in the SVG space. Defaults to `html-void-elements`
|
48 | */
|
49 | voids?: Array<string>
|
50 | /**
|
51 | * Use a `<!DOCTYPE…` instead of `<!doctype…`. Useless except for XHTML
|
52 | */
|
53 | upperDoctype?: boolean
|
54 | /**
|
55 | * Preferred quote to use
|
56 | */
|
57 | quote?: Quote
|
58 | /**
|
59 | * Use the other quote if that results in less bytes
|
60 | */
|
61 | quoteSmart?: boolean
|
62 | /**
|
63 | * Leave attributes unquoted if that results in less bytes. Not used in the SVG space
|
64 | */
|
65 | preferUnquoted?: boolean
|
66 | /**
|
67 | * Omit optional opening and closing tags. For example, in `<ol><li>one</li><li>two</li></ol>`, both `</li>` closing tags can be omitted. The first because it’s followed by another `li`, the last because it’s followed by nothing. Not used in the SVG space
|
68 | */
|
69 | omitOptionalTags?: boolean
|
70 | /**
|
71 | * Collapse empty attributes: `class=""` is stringified as `class` instead. **Note**: boolean attributes, such as `hidden`, are always collapsed. Not used in the SVG space
|
72 | */
|
73 | collapseEmptyAttributes?: boolean
|
74 | /**
|
75 | * Close self-closing nodes with an extra slash (`/`): `<img />` instead of `<img>`. See `tightSelfClosing` to control whether a space is used before the slash. Not used in the SVG space
|
76 | */
|
77 | closeSelfClosing?: boolean
|
78 | /**
|
79 | * Close SVG elements without any content with slash (`/`) on the opening tag instead of an end tag: `<circle />` instead of `<circle></circle>`. See `tightSelfClosing` to control whether a space is used before the slash. Not used in the HTML space
|
80 | */
|
81 | closeEmptyElements?: boolean
|
82 | /**
|
83 | * Do not use an extra space when closing self-closing elements: `<img/>` instead of `<img />`. **Note**: Only used if `closeSelfClosing: true` or `closeEmptyElements: true`
|
84 | */
|
85 | tightSelfClosing?: boolean
|
86 | /**
|
87 | * Join known comma-separated attribute values with just a comma (`,`), instead of padding them on the right as well (`,·`, where `·` represents a space)
|
88 | */
|
89 | tightCommaSeparatedLists?: boolean
|
90 | /**
|
91 | * Join attributes together, without whitespace, if possible: `class="a b" title="c d"` is stringified as `class="a b"title="c d"` instead to save bytes. **Note**: creates invalid (but working) markup. Not used in the SVG space
|
92 | */
|
93 | tightAttributes?: boolean
|
94 | /**
|
95 | * Drop unneeded spaces in doctypes: `<!doctypehtml>` instead of `<!doctype html>` to save bytes. **Note**: creates invalid (but working) markup
|
96 | */
|
97 | tightDoctype?: boolean
|
98 | /**
|
99 | * Use “bogus comments” instead of comments to save byes: `<?charlie>` instead of `<!--charlie-->`. **Note**: creates invalid (but working) markup
|
100 | */
|
101 | bogusComments?: boolean
|
102 | /**
|
103 | * Do not encode characters which cause parse errors (even though they work), to save bytes. **Note**: creates invalid (but working) markup. Not used in the SVG space
|
104 | */
|
105 | allowParseErrors?: boolean
|
106 | /**
|
107 | * Do not encode some characters which cause XSS vulnerabilities in older browsers. **Note**: Only set this if you completely trust the content
|
108 | */
|
109 | allowDangerousCharacters?: boolean
|
110 | /**
|
111 | * Allow `raw` nodes and insert them as raw HTML. When falsey, encodes `raw` nodes. **Note**: Only set this if you completely trust the content
|
112 | */
|
113 | allowDangerousHtml?: boolean
|
114 | }
|
115 | export type Context = {
|
116 | valid: number
|
117 | safe: number
|
118 | schema: Schema
|
119 | omit: Omission
|
120 | quote: Quote
|
121 | alternative: Quote
|
122 | smart: boolean
|
123 | unquoted: boolean
|
124 | tight: boolean
|
125 | upperDoctype: boolean
|
126 | tightDoctype: boolean
|
127 | bogusComments: boolean
|
128 | tightLists: boolean
|
129 | tightClose: boolean
|
130 | collapseEmpty: boolean
|
131 | dangerous: boolean
|
132 | voids: Array<string>
|
133 | entities: StringifyEntitiesOptions
|
134 | close: boolean
|
135 | closeEmpty: boolean
|
136 | }
|