UNPKG

6.71 kBTypeScriptView Raw
1/** @type {import('unified').Plugin<[Options?] | void[], string, Root>} */
2export default function rehypeParse(options: void | Options | undefined): void
3export type Root = import('hast').Root
4export type FromParse5Options = Pick<
5 import('hast-util-from-parse5').Options,
6 'space' | 'verbose'
7>
8export type ErrorCode = keyof {
9 abandonedHeadElementChild: {
10 reason: string
11 description: string
12 url: boolean
13 }
14 abruptClosingOfEmptyComment: {
15 reason: string
16 description: string
17 }
18 abruptDoctypePublicIdentifier: {
19 reason: string
20 description: string
21 }
22 abruptDoctypeSystemIdentifier: {
23 reason: string
24 description: string
25 }
26 absenceOfDigitsInNumericCharacterReference: {
27 reason: string
28 description: string
29 }
30 cdataInHtmlContent: {
31 reason: string
32 description: string
33 }
34 characterReferenceOutsideUnicodeRange: {
35 reason: string
36 description: string
37 }
38 closingOfElementWithOpenChildElements: {
39 reason: string
40 description: string
41 url: boolean
42 }
43 controlCharacterInInputStream: {
44 reason: string
45 description: string
46 }
47 controlCharacterReference: {
48 reason: string
49 description: string
50 }
51 disallowedContentInNoscriptInHead: {
52 reason: string
53 description: string
54 url: boolean
55 }
56 duplicateAttribute: {
57 reason: string
58 /**
59 * @param {{code: string, startLine: number, startCol: number, startOffset: number, endLine: number, endCol: number, endOffset: number}} error
60 */
61 description: string
62 }
63 endTagWithAttributes: {
64 reason: string
65 description: string
66 }
67 endTagWithTrailingSolidus: {
68 reason: string
69 description: string
70 }
71 endTagWithoutMatchingOpenElement: {
72 reason: string
73 description: string
74 url: boolean
75 }
76 eofBeforeTagName: {
77 reason: string
78 description: string
79 }
80 eofInCdata: {
81 reason: string
82 description: string
83 }
84 eofInComment: {
85 reason: string
86 description: string
87 }
88 eofInDoctype: {
89 reason: string
90 description: string
91 }
92 eofInElementThatCanContainOnlyText: {
93 reason: string
94 description: string
95 url: boolean
96 }
97 eofInScriptHtmlCommentLikeText: {
98 reason: string
99 description: string
100 }
101 eofInTag: {
102 reason: string
103 description: string
104 }
105 /**
106 * @param {string} value
107 * @returns {ErrorCode}
108 */
109 incorrectlyClosedComment: {
110 reason: string
111 description: string
112 }
113 incorrectlyOpenedComment: {
114 reason: string
115 description: string
116 }
117 invalidCharacterSequenceAfterDoctypeName: {
118 reason: string
119 description: string
120 }
121 invalidFirstCharacterOfTagName: {
122 reason: string
123 description: string
124 }
125 misplacedDoctype: {
126 reason: string
127 description: string
128 url: boolean
129 }
130 misplacedStartTagForHeadElement: {
131 reason: string
132 description: string
133 url: boolean
134 }
135 missingAttributeValue: {
136 reason: string
137 description: string
138 }
139 missingDoctype: {
140 reason: string
141 description: string
142 url: boolean
143 }
144 missingDoctypeName: {
145 reason: string
146 description: string
147 }
148 missingDoctypePublicIdentifier: {
149 reason: string
150 description: string
151 }
152 missingDoctypeSystemIdentifier: {
153 reason: string
154 description: string
155 }
156 missingEndTagName: {
157 reason: string
158 description: string
159 }
160 missingQuoteBeforeDoctypePublicIdentifier: {
161 reason: string
162 description: string
163 }
164 missingQuoteBeforeDoctypeSystemIdentifier: {
165 reason: string
166 description: string
167 }
168 missingSemicolonAfterCharacterReference: {
169 reason: string
170 description: string
171 }
172 missingWhitespaceAfterDoctypePublicKeyword: {
173 reason: string
174 description: string
175 }
176 missingWhitespaceAfterDoctypeSystemKeyword: {
177 reason: string
178 description: string
179 }
180 missingWhitespaceBeforeDoctypeName: {
181 reason: string
182 description: string
183 }
184 missingWhitespaceBetweenAttributes: {
185 reason: string
186 description: string
187 }
188 missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers: {
189 reason: string
190 description: string
191 }
192 nestedComment: {
193 reason: string
194 description: string
195 }
196 nestedNoscriptInHead: {
197 reason: string
198 description: string
199 url: boolean
200 }
201 nonConformingDoctype: {
202 reason: string
203 description: string
204 url: boolean
205 }
206 nonVoidHtmlElementStartTagWithTrailingSolidus: {
207 reason: string
208 description: string
209 }
210 noncharacterCharacterReference: {
211 reason: string
212 description: string
213 }
214 noncharacterInInputStream: {
215 reason: string
216 description: string
217 }
218 nullCharacterReference: {
219 reason: string
220 description: string
221 }
222 openElementsLeftAfterEof: {
223 reason: string
224 description: string
225 url: boolean
226 }
227 surrogateCharacterReference: {
228 reason: string
229 description: string
230 }
231 surrogateInInputStream: {
232 reason: string
233 description: string
234 }
235 unexpectedCharacterAfterDoctypeSystemIdentifier: {
236 reason: string
237 description: string
238 }
239 unexpectedCharacterInAttributeName: {
240 reason: string
241 description: string
242 }
243 unexpectedCharacterInUnquotedAttributeValue: {
244 reason: string
245 description: string
246 }
247 unexpectedEqualsSignBeforeAttributeName: {
248 reason: string
249 description: string
250 }
251 unexpectedNullCharacter: {
252 reason: string
253 description: string
254 }
255 unexpectedQuestionMarkInsteadOfTagName: {
256 reason: string
257 description: string
258 }
259 unexpectedSolidusInTag: {
260 reason: string
261 description: string
262 }
263 unknownNamedCharacterReference: {
264 reason: string
265 description: string
266 }
267}
268export type ErrorSeverity = 0 | 1 | 2 | boolean | null | undefined
269export type ErrorFields = Partial<Record<ErrorCode, ErrorSeverity>>
270export type ParseFields = {
271 /**
272 * Specify whether to parse a fragment, instead of a complete document.
273 * In document mode, unopened `html`, `head`, and `body` elements are opened
274 * in just the right places.
275 */
276 fragment?: boolean | undefined
277 /**
278 * > ⚠️ Parse errors are currently being added to HTML.
279 * > Not all errors emitted by parse5 (or rehype-parse) are specced yet.
280 * > Some documentation may still be missing.
281 *
282 * Emit parse errors while parsing on the vfile.
283 * Setting this to `true` starts emitting HTML parse errors.
284 *
285 * Specific rules can be turned off by setting them to `false` (or `0`).
286 * The default, when `emitParseErrors: true`, is `true` (or `1`), and means
287 * that rules emit as warnings.
288 * Rules can also be configured with `2`, to turn them into fatal errors.
289 */
290 emitParseErrors?: boolean | undefined
291}
292export type Options = FromParse5Options & ParseFields & ErrorFields