|
39 | 39 | * |
40 | 40 | * @typedef Options |
41 | 41 | * Configuration. |
42 | | - * @property {Space | null | undefined} [space='html'] |
43 | | - * When an `<svg>` element is found in the HTML space, this package already |
44 | | - * automatically switches to and from the SVG space when entering and exiting |
45 | | - * it. |
46 | | - * |
47 | | - * > 👉 **Note**: hast is not XML. |
48 | | - * > It supports SVG as embedded in HTML. |
49 | | - * > It does not support the features available in XML. |
50 | | - * > Passing SVG might break but fragments of modern SVG should be fine. |
51 | | - * > Use [`xast`][xast] if you need to support SVG as XML. |
52 | | - * @property {CharacterReferences | null | undefined} [entities] |
53 | | - * Deprecated: please use `characterReferences`. |
54 | | - * @property {CharacterReferences | null | undefined} [characterReferences] |
55 | | - * Configure how to serialize character references. |
56 | | - * @property {ReadonlyArray<string> | null | undefined} [voids] |
57 | | - * Tag names of elements to serialize without closing tag. |
| 42 | + * @property {boolean | null | undefined} [allowDangerousCharacters=false] |
| 43 | + * Do not encode some characters which cause XSS vulnerabilities in older |
| 44 | + * browsers. |
58 | 45 | * |
59 | | - * Not used in the SVG space. |
| 46 | + * > ⚠️ **Danger**: only set this if you completely trust the content. |
| 47 | + * @property {boolean | null | undefined} [allowDangerousHtml=false] |
| 48 | + * Allow `raw` nodes and insert them as raw HTML. |
60 | 49 | * |
61 | | - * > 👉 **Note**: It’s highly unlikely that you want to pass this, because |
62 | | - * > hast is not for XML, and HTML will not add more void elements. |
63 | | - * @property {boolean | null | undefined} [upperDoctype=false] |
64 | | - * Use a `<!DOCTYPE…` instead of `<!doctype…`. |
| 50 | + * When `false`, `Raw` nodes are encoded. |
65 | 51 | * |
66 | | - * Useless except for XHTML. |
67 | | - * @property {Quote | null | undefined} [quote='"'] |
68 | | - * Preferred quote to use. |
69 | | - * @property {boolean | null | undefined} [quoteSmart=false] |
70 | | - * Use the other quote if that results in less bytes. |
71 | | - * @property {boolean | null | undefined} [preferUnquoted=false] |
72 | | - * Leave attributes unquoted if that results in less bytes. |
| 52 | + * > ⚠️ **Danger**: only set this if you completely trust the content. |
| 53 | + * @property {boolean | null | undefined} [allowParseErrors=false] |
| 54 | + * Do not encode characters which cause parse errors (even though they work), |
| 55 | + * to save bytes. |
73 | 56 | * |
74 | 57 | * Not used in the SVG space. |
75 | | - * @property {boolean | null | undefined} [omitOptionalTags=false] |
76 | | - * Omit optional opening and closing tags. |
77 | 58 | * |
78 | | - * For example, in `<ol><li>one</li><li>two</li></ol>`, both `</li>` closing |
79 | | - * tags can be omitted. |
80 | | - * The first because it’s followed by another `li`, the last because it’s |
81 | | - * followed by nothing. |
| 59 | + * > 👉 **Note**: intentionally creates parse errors in markup (how parse |
| 60 | + * > errors are handled is well defined, so this works but isn’t pretty). |
| 61 | + * @property {boolean | null | undefined} [bogusComments=false] |
| 62 | + * Use “bogus comments” instead of comments to save byes: `<?charlie>` |
| 63 | + * instead of `<!--charlie-->`. |
82 | 64 | * |
83 | | - * Not used in the SVG space. |
84 | | - * @property {boolean | null | undefined} [collapseEmptyAttributes=false] |
85 | | - * Collapse empty attributes: get `class` instead of `class=""`. |
| 65 | + * > 👉 **Note**: intentionally creates parse errors in markup (how parse |
| 66 | + * > errors are handled is well defined, so this works but isn’t pretty). |
| 67 | + * @property {CharacterReferences | null | undefined} [characterReferences] |
| 68 | + * Configure how to serialize character references. |
| 69 | + * @property {boolean | null | undefined} [closeEmptyElements=false] |
| 70 | + * Close SVG elements without any content with slash (`/`) on the opening tag |
| 71 | + * instead of an end tag: `<circle />` instead of `<circle></circle>`. |
86 | 72 | * |
87 | | - * Not used in the SVG space. |
| 73 | + * See `tightSelfClosing` to control whether a space is used before the |
| 74 | + * slash. |
88 | 75 | * |
89 | | - * > 👉 **Note**: boolean attributes (such as `hidden`) are always collapsed. |
| 76 | + * Not used in the HTML space. |
90 | 77 | * @property {boolean | null | undefined} [closeSelfClosing=false] |
91 | 78 | * Close self-closing nodes with an extra slash (`/`): `<img />` instead of |
92 | 79 | * `<img>`. |
|
95 | 82 | * slash. |
96 | 83 | * |
97 | 84 | * Not used in the SVG space. |
98 | | - * @property {boolean | null | undefined} [closeEmptyElements=false] |
99 | | - * Close SVG elements without any content with slash (`/`) on the opening tag |
100 | | - * instead of an end tag: `<circle />` instead of `<circle></circle>`. |
| 85 | + * @property {boolean | null | undefined} [collapseEmptyAttributes=false] |
| 86 | + * Collapse empty attributes: get `class` instead of `class=""`. |
101 | 87 | * |
102 | | - * See `tightSelfClosing` to control whether a space is used before the |
103 | | - * slash. |
| 88 | + * Not used in the SVG space. |
104 | 89 | * |
105 | | - * Not used in the HTML space. |
106 | | - * @property {boolean | null | undefined} [tightSelfClosing=false] |
107 | | - * Do not use an extra space when closing self-closing elements: `<img/>` |
108 | | - * instead of `<img />`. |
| 90 | + * > 👉 **Note**: boolean attributes (such as `hidden`) are always collapsed. |
| 91 | + * @property {CharacterReferences | null | undefined} [entities] |
| 92 | + * Deprecated: please use `characterReferences`. |
| 93 | + * @property {boolean | null | undefined} [omitOptionalTags=false] |
| 94 | + * Omit optional opening and closing tags. |
109 | 95 | * |
110 | | - * > 👉 **Note**: only used if `closeSelfClosing: true` or |
111 | | - * > `closeEmptyElements: true`. |
112 | | - * @property {boolean | null | undefined} [tightCommaSeparatedLists=false] |
113 | | - * Join known comma-separated attribute values with just a comma (`,`), |
114 | | - * instead of padding them on the right as well (`,␠`, where `␠` represents a |
115 | | - * space). |
| 96 | + * For example, in `<ol><li>one</li><li>two</li></ol>`, both `</li>` closing |
| 97 | + * tags can be omitted. |
| 98 | + * The first because it’s followed by another `li`, the last because it’s |
| 99 | + * followed by nothing. |
| 100 | + * |
| 101 | + * Not used in the SVG space. |
| 102 | + * @property {boolean | null | undefined} [preferUnquoted=false] |
| 103 | + * Leave attributes unquoted if that results in less bytes. |
| 104 | + * |
| 105 | + * Not used in the SVG space. |
| 106 | + * @property {Quote | null | undefined} [quote='"'] |
| 107 | + * Preferred quote to use. |
| 108 | + * @property {boolean | null | undefined} [quoteSmart=false] |
| 109 | + * Use the other quote if that results in less bytes. |
| 110 | + * @property {Space | null | undefined} [space='html'] |
| 111 | + * When an `<svg>` element is found in the HTML space, this package already |
| 112 | + * automatically switches to and from the SVG space when entering and exiting |
| 113 | + * it. |
| 114 | + * |
| 115 | + * > 👉 **Note**: hast is not XML. |
| 116 | + * > It supports SVG as embedded in HTML. |
| 117 | + * > It does not support the features available in XML. |
| 118 | + * > Passing SVG might break but fragments of modern SVG should be fine. |
| 119 | + * > Use [`xast`][xast] if you need to support SVG as XML. |
116 | 120 | * @property {boolean | null | undefined} [tightAttributes=false] |
117 | 121 | * Join attributes together, without whitespace, if possible: get |
118 | 122 | * `class="a b"title="c d"` instead of `class="a b" title="c d"` to save |
|
122 | 126 | * |
123 | 127 | * > 👉 **Note**: intentionally creates parse errors in markup (how parse |
124 | 128 | * > errors are handled is well defined, so this works but isn’t pretty). |
| 129 | + * @property {boolean | null | undefined} [tightCommaSeparatedLists=false] |
| 130 | + * Join known comma-separated attribute values with just a comma (`,`), |
| 131 | + * instead of padding them on the right as well (`,␠`, where `␠` represents a |
| 132 | + * space). |
125 | 133 | * @property {boolean | null | undefined} [tightDoctype=false] |
126 | 134 | * Drop unneeded spaces in doctypes: `<!doctypehtml>` instead of |
127 | 135 | * `<!doctype html>` to save bytes. |
128 | 136 | * |
129 | 137 | * > 👉 **Note**: intentionally creates parse errors in markup (how parse |
130 | 138 | * > errors are handled is well defined, so this works but isn’t pretty). |
131 | | - * @property {boolean | null | undefined} [bogusComments=false] |
132 | | - * Use “bogus comments” instead of comments to save byes: `<?charlie>` |
133 | | - * instead of `<!--charlie-->`. |
134 | | - * |
135 | | - * > 👉 **Note**: intentionally creates parse errors in markup (how parse |
136 | | - * > errors are handled is well defined, so this works but isn’t pretty). |
137 | | - * @property {boolean | null | undefined} [allowParseErrors=false] |
138 | | - * Do not encode characters which cause parse errors (even though they work), |
139 | | - * to save bytes. |
140 | | - * |
141 | | - * Not used in the SVG space. |
| 139 | + * @property {boolean | null | undefined} [tightSelfClosing=false] |
| 140 | + * Do not use an extra space when closing self-closing elements: `<img/>` |
| 141 | + * instead of `<img />`. |
142 | 142 | * |
143 | | - * > 👉 **Note**: intentionally creates parse errors in markup (how parse |
144 | | - * > errors are handled is well defined, so this works but isn’t pretty). |
145 | | - * @property {boolean | null | undefined} [allowDangerousCharacters=false] |
146 | | - * Do not encode some characters which cause XSS vulnerabilities in older |
147 | | - * browsers. |
| 143 | + * > 👉 **Note**: only used if `closeSelfClosing: true` or |
| 144 | + * > `closeEmptyElements: true`. |
| 145 | + * @property {boolean | null | undefined} [upperDoctype=false] |
| 146 | + * Use a `<!DOCTYPE…` instead of `<!doctype…`. |
148 | 147 | * |
149 | | - * > ⚠️ **Danger**: only set this if you completely trust the content. |
150 | | - * @property {boolean | null | undefined} [allowDangerousHtml=false] |
151 | | - * Allow `raw` nodes and insert them as raw HTML. |
| 148 | + * Useless except for XHTML. |
| 149 | + * @property {ReadonlyArray<string> | null | undefined} [voids] |
| 150 | + * Tag names of elements to serialize without closing tag. |
152 | 151 | * |
153 | | - * When `false`, `Raw` nodes are encoded. |
| 152 | + * Not used in the SVG space. |
154 | 153 | * |
155 | | - * > ⚠️ **Danger**: only set this if you completely trust the content. |
| 154 | + * > 👉 **Note**: It’s highly unlikely that you want to pass this, because |
| 155 | + * > hast is not for XML, and HTML will not add more void elements. |
156 | 156 | * |
157 | 157 | * @typedef {Omit<Required<{[key in keyof Options]: Exclude<Options[key], null | undefined>}>, 'quote' | 'entities' | 'space'>} Settings |
158 | 158 | * |
|
0 commit comments