🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

7
node_modules/rehype-parse/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,7 @@
// This wrapper exists because JS in TS cant export a `@type` of a function.
import type {Options, ErrorCode, ErrorSeverity} from './lib/index.js'
import type {Root} from 'hast'
import type {Plugin} from 'unified'
declare const rehypeParse: Plugin<[Options?] | Array<void>, string, Root>
export default rehypeParse
export type {Options, ErrorCode, ErrorSeverity}

1
node_modules/rehype-parse/index.js generated vendored Normal file
View file

@ -0,0 +1 @@
export {default} from './lib/index.js'

381
node_modules/rehype-parse/lib/errors.d.ts generated vendored Normal file
View file

@ -0,0 +1,381 @@
export namespace errors {
namespace abandonedHeadElementChild {
const reason: string
const description: string
const url: boolean
}
namespace abruptClosingOfEmptyComment {
const reason_1: string
export {reason_1 as reason}
const description_1: string
export {description_1 as description}
}
namespace abruptDoctypePublicIdentifier {
const reason_2: string
export {reason_2 as reason}
const description_2: string
export {description_2 as description}
}
namespace abruptDoctypeSystemIdentifier {
const reason_3: string
export {reason_3 as reason}
const description_3: string
export {description_3 as description}
}
namespace absenceOfDigitsInNumericCharacterReference {
const reason_4: string
export {reason_4 as reason}
const description_4: string
export {description_4 as description}
}
namespace cdataInHtmlContent {
const reason_5: string
export {reason_5 as reason}
const description_5: string
export {description_5 as description}
}
namespace characterReferenceOutsideUnicodeRange {
const reason_6: string
export {reason_6 as reason}
const description_6: string
export {description_6 as description}
}
namespace closingOfElementWithOpenChildElements {
const reason_7: string
export {reason_7 as reason}
const description_7: string
export {description_7 as description}
const url_1: boolean
export {url_1 as url}
}
namespace controlCharacterInInputStream {
const reason_8: string
export {reason_8 as reason}
const description_8: string
export {description_8 as description}
}
namespace controlCharacterReference {
const reason_9: string
export {reason_9 as reason}
const description_9: string
export {description_9 as description}
}
namespace disallowedContentInNoscriptInHead {
const reason_10: string
export {reason_10 as reason}
const description_10: string
export {description_10 as description}
const url_2: boolean
export {url_2 as url}
}
namespace duplicateAttribute {
const reason_11: string
export {reason_11 as reason}
const description_11: string
export {description_11 as description}
}
namespace endTagWithAttributes {
const reason_12: string
export {reason_12 as reason}
const description_12: string
export {description_12 as description}
}
namespace endTagWithTrailingSolidus {
const reason_13: string
export {reason_13 as reason}
const description_13: string
export {description_13 as description}
}
namespace endTagWithoutMatchingOpenElement {
const reason_14: string
export {reason_14 as reason}
const description_14: string
export {description_14 as description}
const url_3: boolean
export {url_3 as url}
}
namespace eofBeforeTagName {
const reason_15: string
export {reason_15 as reason}
const description_15: string
export {description_15 as description}
}
namespace eofInCdata {
const reason_16: string
export {reason_16 as reason}
const description_16: string
export {description_16 as description}
}
namespace eofInComment {
const reason_17: string
export {reason_17 as reason}
const description_17: string
export {description_17 as description}
}
namespace eofInDoctype {
const reason_18: string
export {reason_18 as reason}
const description_18: string
export {description_18 as description}
}
namespace eofInElementThatCanContainOnlyText {
const reason_19: string
export {reason_19 as reason}
const description_19: string
export {description_19 as description}
const url_4: boolean
export {url_4 as url}
}
namespace eofInScriptHtmlCommentLikeText {
const reason_20: string
export {reason_20 as reason}
const description_20: string
export {description_20 as description}
}
namespace eofInTag {
const reason_21: string
export {reason_21 as reason}
const description_21: string
export {description_21 as description}
}
namespace incorrectlyClosedComment {
const reason_22: string
export {reason_22 as reason}
const description_22: string
export {description_22 as description}
}
namespace incorrectlyOpenedComment {
const reason_23: string
export {reason_23 as reason}
const description_23: string
export {description_23 as description}
}
namespace invalidCharacterSequenceAfterDoctypeName {
const reason_24: string
export {reason_24 as reason}
const description_24: string
export {description_24 as description}
}
namespace invalidFirstCharacterOfTagName {
const reason_25: string
export {reason_25 as reason}
const description_25: string
export {description_25 as description}
}
namespace misplacedDoctype {
const reason_26: string
export {reason_26 as reason}
const description_26: string
export {description_26 as description}
const url_5: boolean
export {url_5 as url}
}
namespace misplacedStartTagForHeadElement {
const reason_27: string
export {reason_27 as reason}
const description_27: string
export {description_27 as description}
const url_6: boolean
export {url_6 as url}
}
namespace missingAttributeValue {
const reason_28: string
export {reason_28 as reason}
const description_28: string
export {description_28 as description}
}
namespace missingDoctype {
const reason_29: string
export {reason_29 as reason}
const description_29: string
export {description_29 as description}
const url_7: boolean
export {url_7 as url}
}
namespace missingDoctypeName {
const reason_30: string
export {reason_30 as reason}
const description_30: string
export {description_30 as description}
}
namespace missingDoctypePublicIdentifier {
const reason_31: string
export {reason_31 as reason}
const description_31: string
export {description_31 as description}
}
namespace missingDoctypeSystemIdentifier {
const reason_32: string
export {reason_32 as reason}
const description_32: string
export {description_32 as description}
}
namespace missingEndTagName {
const reason_33: string
export {reason_33 as reason}
const description_33: string
export {description_33 as description}
}
namespace missingQuoteBeforeDoctypePublicIdentifier {
const reason_34: string
export {reason_34 as reason}
const description_34: string
export {description_34 as description}
}
namespace missingQuoteBeforeDoctypeSystemIdentifier {
const reason_35: string
export {reason_35 as reason}
const description_35: string
export {description_35 as description}
}
namespace missingSemicolonAfterCharacterReference {
const reason_36: string
export {reason_36 as reason}
const description_36: string
export {description_36 as description}
}
namespace missingWhitespaceAfterDoctypePublicKeyword {
const reason_37: string
export {reason_37 as reason}
const description_37: string
export {description_37 as description}
}
namespace missingWhitespaceAfterDoctypeSystemKeyword {
const reason_38: string
export {reason_38 as reason}
const description_38: string
export {description_38 as description}
}
namespace missingWhitespaceBeforeDoctypeName {
const reason_39: string
export {reason_39 as reason}
const description_39: string
export {description_39 as description}
}
namespace missingWhitespaceBetweenAttributes {
const reason_40: string
export {reason_40 as reason}
const description_40: string
export {description_40 as description}
}
namespace missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers {
const reason_41: string
export {reason_41 as reason}
const description_41: string
export {description_41 as description}
}
namespace nestedComment {
const reason_42: string
export {reason_42 as reason}
const description_42: string
export {description_42 as description}
}
namespace nestedNoscriptInHead {
const reason_43: string
export {reason_43 as reason}
const description_43: string
export {description_43 as description}
const url_8: boolean
export {url_8 as url}
}
namespace nonConformingDoctype {
const reason_44: string
export {reason_44 as reason}
const description_44: string
export {description_44 as description}
const url_9: boolean
export {url_9 as url}
}
namespace nonVoidHtmlElementStartTagWithTrailingSolidus {
const reason_45: string
export {reason_45 as reason}
const description_45: string
export {description_45 as description}
}
namespace noncharacterCharacterReference {
const reason_46: string
export {reason_46 as reason}
const description_46: string
export {description_46 as description}
}
namespace noncharacterInInputStream {
const reason_47: string
export {reason_47 as reason}
const description_47: string
export {description_47 as description}
}
namespace nullCharacterReference {
const reason_48: string
export {reason_48 as reason}
const description_48: string
export {description_48 as description}
}
namespace openElementsLeftAfterEof {
const reason_49: string
export {reason_49 as reason}
const description_49: string
export {description_49 as description}
const url_10: boolean
export {url_10 as url}
}
namespace surrogateCharacterReference {
const reason_50: string
export {reason_50 as reason}
const description_50: string
export {description_50 as description}
}
namespace surrogateInInputStream {
const reason_51: string
export {reason_51 as reason}
const description_51: string
export {description_51 as description}
}
namespace unexpectedCharacterAfterDoctypeSystemIdentifier {
const reason_52: string
export {reason_52 as reason}
const description_52: string
export {description_52 as description}
}
namespace unexpectedCharacterInAttributeName {
const reason_53: string
export {reason_53 as reason}
const description_53: string
export {description_53 as description}
}
namespace unexpectedCharacterInUnquotedAttributeValue {
const reason_54: string
export {reason_54 as reason}
const description_54: string
export {description_54 as description}
}
namespace unexpectedEqualsSignBeforeAttributeName {
const reason_55: string
export {reason_55 as reason}
const description_55: string
export {description_55 as description}
}
namespace unexpectedNullCharacter {
const reason_56: string
export {reason_56 as reason}
const description_56: string
export {description_56 as description}
}
namespace unexpectedQuestionMarkInsteadOfTagName {
const reason_57: string
export {reason_57 as reason}
const description_57: string
export {description_57 as description}
}
namespace unexpectedSolidusInTag {
const reason_58: string
export {reason_58 as reason}
const description_58: string
export {description_58 as description}
}
namespace unknownNamedCharacterReference {
const reason_59: string
export {reason_59 as reason}
const description_59: string
export {description_59 as description}
}
}

278
node_modules/rehype-parse/lib/errors.js generated vendored Normal file
View file

@ -0,0 +1,278 @@
export const errors = {
abandonedHeadElementChild: {
reason: 'Unexpected metadata element after head',
description:
'Unexpected element after head. Expected the element before `</head>`',
url: false
},
abruptClosingOfEmptyComment: {
reason: 'Unexpected abruptly closed empty comment',
description: 'Unexpected `>` or `->`. Expected `-->` to close comments'
},
abruptDoctypePublicIdentifier: {
reason: 'Unexpected abruptly closed public identifier',
description:
'Unexpected `>`. Expected a closing `"` or `\'` after the public identifier'
},
abruptDoctypeSystemIdentifier: {
reason: 'Unexpected abruptly closed system identifier',
description:
'Unexpected `>`. Expected a closing `"` or `\'` after the identifier identifier'
},
absenceOfDigitsInNumericCharacterReference: {
reason: 'Unexpected non-digit at start of numeric character reference',
description:
'Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references'
},
cdataInHtmlContent: {
reason: 'Unexpected CDATA section in HTML',
description:
'Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead'
},
characterReferenceOutsideUnicodeRange: {
reason: 'Unexpected too big numeric character reference',
description:
'Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)'
},
closingOfElementWithOpenChildElements: {
reason: 'Unexpected closing tag with open child elements',
description:
'Unexpectedly closing tag. Expected other tags to be closed first',
url: false
},
controlCharacterInInputStream: {
reason: 'Unexpected control character',
description:
'Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace'
},
controlCharacterReference: {
reason: 'Unexpected control character reference',
description:
'Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace'
},
disallowedContentInNoscriptInHead: {
reason: 'Disallowed content inside `<noscript>` in `<head>`',
description:
'Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`',
url: false
},
duplicateAttribute: {
reason: 'Unexpected duplicate attribute',
description:
'Unexpectedly double attribute. Expected attributes to occur only once'
},
endTagWithAttributes: {
reason: 'Unexpected attribute on closing tag',
description: 'Unexpected attribute. Expected `>` instead'
},
endTagWithTrailingSolidus: {
reason: 'Unexpected slash at end of closing tag',
description: 'Unexpected `%c-1`. Expected `>` instead'
},
endTagWithoutMatchingOpenElement: {
reason: 'Unexpected unopened end tag',
description: 'Unexpected end tag. Expected no end tag or another end tag',
url: false
},
eofBeforeTagName: {
reason: 'Unexpected end of file',
description: 'Unexpected end of file. Expected tag name instead'
},
eofInCdata: {
reason: 'Unexpected end of file in CDATA',
description: 'Unexpected end of file. Expected `]]>` to close the CDATA'
},
eofInComment: {
reason: 'Unexpected end of file in comment',
description: 'Unexpected end of file. Expected `-->` to close the comment'
},
eofInDoctype: {
reason: 'Unexpected end of file in doctype',
description:
'Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)'
},
eofInElementThatCanContainOnlyText: {
reason: 'Unexpected end of file in element that can only contain text',
description: 'Unexpected end of file. Expected text or a closing tag',
url: false
},
eofInScriptHtmlCommentLikeText: {
reason: 'Unexpected end of file in comment inside script',
description: 'Unexpected end of file. Expected `-->` to close the comment'
},
eofInTag: {
reason: 'Unexpected end of file in tag',
description: 'Unexpected end of file. Expected `>` to close the tag'
},
incorrectlyClosedComment: {
reason: 'Incorrectly closed comment',
description: 'Unexpected `%c-1`. Expected `-->` to close the comment'
},
incorrectlyOpenedComment: {
reason: 'Incorrectly opened comment',
description: 'Unexpected `%c`. Expected `<!--` to open the comment'
},
invalidCharacterSequenceAfterDoctypeName: {
reason: 'Invalid sequence after doctype name',
description: 'Unexpected sequence at `%c`. Expected `public` or `system`'
},
invalidFirstCharacterOfTagName: {
reason: 'Invalid first character in tag name',
description: 'Unexpected `%c`. Expected an ASCII letter instead'
},
misplacedDoctype: {
reason: 'Misplaced doctype',
description: 'Unexpected doctype. Expected doctype before head',
url: false
},
misplacedStartTagForHeadElement: {
reason: 'Misplaced `<head>` start tag',
description:
'Unexpected start tag `<head>`. Expected `<head>` directly after doctype',
url: false
},
missingAttributeValue: {
reason: 'Missing attribute value',
description:
'Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead'
},
missingDoctype: {
reason: 'Missing doctype before other content',
description: 'Expected a `<!doctype html>` before anything else',
url: false
},
missingDoctypeName: {
reason: 'Missing doctype name',
description: 'Unexpected doctype end at `%c`. Expected `html` instead'
},
missingDoctypePublicIdentifier: {
reason: 'Missing public identifier in doctype',
description: 'Unexpected `%c`. Expected identifier for `public` instead'
},
missingDoctypeSystemIdentifier: {
reason: 'Missing system identifier in doctype',
description:
'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)'
},
missingEndTagName: {
reason: 'Missing name in end tag',
description: 'Unexpected `%c`. Expected an ASCII letter instead'
},
missingQuoteBeforeDoctypePublicIdentifier: {
reason: 'Missing quote before public identifier in doctype',
description: 'Unexpected `%c`. Expected `"` or `\'` instead'
},
missingQuoteBeforeDoctypeSystemIdentifier: {
reason: 'Missing quote before system identifier in doctype',
description: 'Unexpected `%c`. Expected `"` or `\'` instead'
},
missingSemicolonAfterCharacterReference: {
reason: 'Missing semicolon after character reference',
description: 'Unexpected `%c`. Expected `;` instead'
},
missingWhitespaceAfterDoctypePublicKeyword: {
reason: 'Missing whitespace after public identifier in doctype',
description: 'Unexpected `%c`. Expected ASCII whitespace instead'
},
missingWhitespaceAfterDoctypeSystemKeyword: {
reason: 'Missing whitespace after system identifier in doctype',
description: 'Unexpected `%c`. Expected ASCII whitespace instead'
},
missingWhitespaceBeforeDoctypeName: {
reason: 'Missing whitespace before doctype name',
description: 'Unexpected `%c`. Expected ASCII whitespace instead'
},
missingWhitespaceBetweenAttributes: {
reason: 'Missing whitespace between attributes',
description: 'Unexpected `%c`. Expected ASCII whitespace instead'
},
missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers: {
reason:
'Missing whitespace between public and system identifiers in doctype',
description: 'Unexpected `%c`. Expected ASCII whitespace instead'
},
nestedComment: {
reason: 'Unexpected nested comment',
description: 'Unexpected `<!--`. Expected `-->`'
},
nestedNoscriptInHead: {
reason: 'Unexpected nested `<noscript>` in `<head>`',
description:
'Unexpected `<noscript>`. Expected a closing tag or a meta element',
url: false
},
nonConformingDoctype: {
reason: 'Unexpected non-conforming doctype declaration',
description:
'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`',
url: false
},
nonVoidHtmlElementStartTagWithTrailingSolidus: {
reason: 'Unexpected trailing slash on start tag of non-void element',
description: 'Unexpected `/`. Expected `>` instead'
},
noncharacterCharacterReference: {
reason:
'Unexpected noncharacter code point referenced by character reference',
description: 'Unexpected code point. Do not use noncharacters in HTML'
},
noncharacterInInputStream: {
reason: 'Unexpected noncharacter character',
description: 'Unexpected code point `%x`. Do not use noncharacters in HTML'
},
nullCharacterReference: {
reason: 'Unexpected NULL character referenced by character reference',
description: 'Unexpected code point. Do not use NULL characters in HTML'
},
openElementsLeftAfterEof: {
reason: 'Unexpected end of file',
description: 'Unexpected end of file. Expected closing tag instead',
url: false
},
surrogateCharacterReference: {
reason: 'Unexpected surrogate character referenced by character reference',
description:
'Unexpected code point. Do not use lone surrogate characters in HTML'
},
surrogateInInputStream: {
reason: 'Unexpected surrogate character',
description:
'Unexpected code point `%x`. Do not use lone surrogate characters in HTML'
},
unexpectedCharacterAfterDoctypeSystemIdentifier: {
reason: 'Invalid character after system identifier in doctype',
description: 'Unexpected character at `%c`. Expected `>`'
},
unexpectedCharacterInAttributeName: {
reason: 'Unexpected character in attribute name',
description:
'Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter'
},
unexpectedCharacterInUnquotedAttributeValue: {
reason: 'Unexpected character in unquoted attribute value',
description: 'Unexpected `%c`. Quote the attribute value to include it'
},
unexpectedEqualsSignBeforeAttributeName: {
reason: 'Unexpected equals sign before attribute name',
description: 'Unexpected `%c`. Add an attribute name before it'
},
unexpectedNullCharacter: {
reason: 'Unexpected NULL character',
description:
'Unexpected code point `%x`. Do not use NULL characters in HTML'
},
unexpectedQuestionMarkInsteadOfTagName: {
reason: 'Unexpected question mark instead of tag name',
description: 'Unexpected `%c`. Expected an ASCII letter instead'
},
unexpectedSolidusInTag: {
reason: 'Unexpected slash in tag',
description:
'Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value'
},
unknownNamedCharacterReference: {
reason: 'Unexpected unknown named character reference',
description:
'Unexpected character reference. Expected known named character references'
}
}

286
node_modules/rehype-parse/lib/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,286 @@
/** @type {import('unified').Plugin<[Options?] | Array<void>, string, Root>} */
export default function rehypeParse(options: void | Options | undefined): void
export type Root = import('hast').Root
export type FromParse5Options = Pick<
import('hast-util-from-parse5').Options,
'space' | 'verbose'
>
export type ErrorCode = keyof {
abandonedHeadElementChild: {
reason: string
description: string
url: boolean
}
abruptClosingOfEmptyComment: {
reason: string
description: string
}
abruptDoctypePublicIdentifier: {
reason: string
description: string
}
abruptDoctypeSystemIdentifier: {
reason: string
description: string
}
absenceOfDigitsInNumericCharacterReference: {
reason: string
description: string
}
cdataInHtmlContent: {
reason: string
description: string
}
characterReferenceOutsideUnicodeRange: {
reason: string
description: string
}
closingOfElementWithOpenChildElements: {
reason: string
description: string
url: boolean
}
/** @type {Options} */
controlCharacterInInputStream: {
reason: string
description: string
}
controlCharacterReference: {
reason: string
description: string
}
disallowedContentInNoscriptInHead: {
reason: string
description: string
url: boolean
}
duplicateAttribute: {
reason: string
description: string
}
endTagWithAttributes: {
reason: string
description: string
}
endTagWithTrailingSolidus: {
reason: string
description: string
}
endTagWithoutMatchingOpenElement: {
reason: string
description: string
url: boolean
}
eofBeforeTagName: {
reason: string
description: string
}
eofInCdata: {
reason: string
description: string
}
eofInComment: {
reason: string
description: string
}
eofInDoctype: {
reason: string
description: string
}
eofInElementThatCanContainOnlyText: {
reason: string
description: string
url: boolean
}
eofInScriptHtmlCommentLikeText: {
reason: string
description: string
}
eofInTag: {
reason: string
description: string
}
incorrectlyClosedComment: {
reason: string
description: string
}
incorrectlyOpenedComment: {
reason: string
description: string
}
invalidCharacterSequenceAfterDoctypeName: {
reason: string
description: string
}
invalidFirstCharacterOfTagName: {
reason: string
description: string
}
misplacedDoctype: {
reason: string
description: string
url: boolean
}
misplacedStartTagForHeadElement: {
reason: string
description: string
url: boolean
}
missingAttributeValue: {
reason: string
description: string
}
missingDoctype: {
reason: string
description: string
url: boolean
}
missingDoctypeName: {
reason: string
description: string
}
missingDoctypePublicIdentifier: {
reason: string
description: string
}
missingDoctypeSystemIdentifier: {
reason: string
description: string
}
missingEndTagName: {
reason: string
description: string
}
missingQuoteBeforeDoctypePublicIdentifier: {
reason: string
description: string
}
missingQuoteBeforeDoctypeSystemIdentifier: {
reason: string
description: string
}
missingSemicolonAfterCharacterReference: {
reason: string
description: string
}
missingWhitespaceAfterDoctypePublicKeyword: {
reason: string
description: string
}
missingWhitespaceAfterDoctypeSystemKeyword: {
reason: string
description: string
}
missingWhitespaceBeforeDoctypeName: {
reason: string
description: string
}
missingWhitespaceBetweenAttributes: {
reason: string
description: string
}
missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers: {
reason: string
description: string
}
nestedComment: {
reason: string
description: string
}
nestedNoscriptInHead: {
reason: string
description: string
url: boolean
}
nonConformingDoctype: {
reason: string
description: string
url: boolean
}
nonVoidHtmlElementStartTagWithTrailingSolidus: {
reason: string
description: string
}
noncharacterCharacterReference: {
reason: string
description: string
}
noncharacterInInputStream: {
reason: string
description: string
}
nullCharacterReference: {
reason: string
description: string
}
openElementsLeftAfterEof: {
reason: string
description: string
url: boolean
}
surrogateCharacterReference: {
reason: string
description: string
}
surrogateInInputStream: {
reason: string
description: string
}
unexpectedCharacterAfterDoctypeSystemIdentifier: {
reason: string
description: string
}
unexpectedCharacterInAttributeName: {
reason: string
description: string
}
unexpectedCharacterInUnquotedAttributeValue: {
reason: string
description: string
}
unexpectedEqualsSignBeforeAttributeName: {
reason: string
description: string
}
unexpectedNullCharacter: {
reason: string
description: string
}
unexpectedQuestionMarkInsteadOfTagName: {
reason: string
description: string
}
unexpectedSolidusInTag: {
reason: string
description: string
}
unknownNamedCharacterReference: {
reason: string
description: string
}
}
export type ErrorSeverity = 0 | 1 | 2 | boolean | null | undefined
export type ErrorFields = Partial<Record<ErrorCode, ErrorSeverity>>
export type ParseFields = {
/**
* Specify whether to parse a fragment, instead of a complete document.
* In document mode, unopened `html`, `head`, and `body` elements are opened
* in just the right places.
*/
fragment?: boolean | undefined
/**
* > Parse errors are currently being added to HTML.
* > Not all errors emitted by parse5 (or rehype-parse) are specced yet.
* > Some documentation may still be missing.
*
* Emit parse errors while parsing on the vfile.
* Setting this to `true` starts emitting HTML parse errors.
*
* Specific rules can be turned off by setting them to `false` (or `0`).
* The default, when `emitParseErrors: true`, is `true` (or `1`), and means
* that rules emit as warnings.
* Rules can also be configured with `2`, to turn them into fatal errors.
*/
emitParseErrors?: boolean | undefined
}
export type Options = FromParse5Options & ParseFields & ErrorFields

123
node_modules/rehype-parse/lib/index.js generated vendored Normal file
View file

@ -0,0 +1,123 @@
/**
* @typedef {import('hast').Root} Root
* @typedef {Pick<import('hast-util-from-parse5').Options, 'space' | 'verbose'>} FromParse5Options
*
* @typedef {keyof errors} ErrorCode
* @typedef {0|1|2|boolean|null|undefined} ErrorSeverity
* @typedef {Partial<Record<ErrorCode, ErrorSeverity>>} ErrorFields
*
* @typedef ParseFields
* @property {boolean|undefined} [fragment=false]
* Specify whether to parse a fragment, instead of a complete document.
* In document mode, unopened `html`, `head`, and `body` elements are opened
* in just the right places.
* @property {boolean|undefined} [emitParseErrors=false]
* > Parse errors are currently being added to HTML.
* > Not all errors emitted by parse5 (or rehype-parse) are specced yet.
* > Some documentation may still be missing.
*
* Emit parse errors while parsing on the vfile.
* Setting this to `true` starts emitting HTML parse errors.
*
* Specific rules can be turned off by setting them to `false` (or `0`).
* The default, when `emitParseErrors: true`, is `true` (or `1`), and means
* that rules emit as warnings.
* Rules can also be configured with `2`, to turn them into fatal errors.
*
* @typedef {FromParse5Options & ParseFields & ErrorFields} Options
*/
// @ts-expect-error: remove when typed
import Parser5 from 'parse5/lib/parser/index.js'
import {fromParse5} from 'hast-util-from-parse5'
import {errors} from './errors.js'
const base = 'https://html.spec.whatwg.org/multipage/parsing.html#parse-error-'
const fatalities = {2: true, 1: false, 0: null}
/** @type {import('unified').Plugin<[Options?] | Array<void>, string, Root>} */
export default function rehypeParse(options) {
const processorSettings = /** @type {Options} */ (this.data('settings'))
const settings = Object.assign({}, processorSettings, options)
Object.assign(this, {Parser: parser})
/** @type {import('unified').ParserFunction<Root>} */
function parser(doc, file) {
const fn = settings.fragment ? 'parseFragment' : 'parse'
const onParseError = settings.emitParseErrors ? onerror : null
const parse5 = new Parser5({
sourceCodeLocationInfo: true,
onParseError,
scriptingEnabled: false
})
// @ts-expect-error: `parse5` returns document or fragment, which are always
// mapped to roots.
return fromParse5(parse5[fn](doc), {
space: settings.space,
file,
verbose: settings.verbose
})
/**
* @param {{code: string, startLine: number, startCol: number, startOffset: number, endLine: number, endCol: number, endOffset: number}} error
*/
function onerror(error) {
const code = error.code
const name = camelcase(code)
const setting = settings[name]
const config = setting === undefined || setting === null ? true : setting
const level = typeof config === 'number' ? config : config ? 1 : 0
const start = {
line: error.startLine,
column: error.startCol,
offset: error.startOffset
}
const end = {
line: error.endLine,
column: error.endCol,
offset: error.endOffset
}
if (level) {
/* c8 ignore next */
const info = errors[name] || {reason: '', description: '', url: ''}
const message = file.message(format(info.reason), {start, end})
message.source = 'parse-error'
message.ruleId = code
message.fatal = fatalities[level]
message.note = format(info.description)
message.url = 'url' in info && info.url === false ? null : base + code
}
/**
* @param {string} value
* @returns {string}
*/
function format(value) {
return value
.replace(/%c(?:-(\d+))?/g, (_, /** @type {string} */ $1) => {
const offset = $1 ? -Number.parseInt($1, 10) : 0
const char = doc.charAt(error.startOffset + offset)
return char === '`' ? '` ` `' : char
})
.replace(
/%x/g,
() =>
'0x' +
doc.charCodeAt(error.startOffset).toString(16).toUpperCase()
)
}
}
}
}
/**
* @param {string} value
* @returns {ErrorCode}
*/
function camelcase(value) {
// @ts-expect-error: this returns a valid error code.
return value.replace(/-[a-z]/g, ($0) => $0.charAt(1).toUpperCase())
}

54
node_modules/rehype-parse/package.json generated vendored Normal file
View file

@ -0,0 +1,54 @@
{
"name": "rehype-parse",
"version": "8.0.4",
"description": "rehype plugin to parse HTML",
"license": "MIT",
"keywords": [
"unified",
"rehype",
"rehype-plugin",
"plugin",
"html",
"abstract",
"syntax",
"tree",
"ast",
"parse"
],
"homepage": "https://github.com/rehypejs/rehype",
"repository": "https://github.com/rehypejs/rehype/tree/main/packages/rehype-parse",
"bugs": "https://github.com/rehypejs/rehype/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"lib/",
"index.d.ts",
"index.js"
],
"dependencies": {
"@types/hast": "^2.0.0",
"hast-util-from-parse5": "^7.0.0",
"parse5": "^6.0.0",
"unified": "^10.0.0"
},
"scripts": {
"build": "rimraf \"lib/**/*.d.ts\" && tsc && type-coverage"
},
"xo": false,
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true
}
}

562
node_modules/rehype-parse/readme.md generated vendored Normal file
View file

@ -0,0 +1,562 @@
# rehype-parse
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
**[rehype][]** plugin to add support for parsing HTML input.
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`unified().use(rehypeParse[, options])`](#unifieduserehypeparse-options)
* [Examples](#examples)
* [Example: fragment versus document](#example-fragment-versus-document)
* [Example: whitespace around and inside `<html>`](#example-whitespace-around-and-inside-html)
* [Example: parse errors](#example-parse-errors)
* [Syntax](#syntax)
* [Syntax tree](#syntax-tree)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Contribute](#contribute)
* [Sponsor](#sponsor)
* [License](#license)
## What is this?
This package is a [unified][] ([rehype][]) plugin that defines how to take HTML
as input and turn it into a syntax tree.
When its used, HTML can be parsed and other rehype plugins can be used after
it.
See [the monorepo readme][rehype] for info on what the rehype ecosystem is.
## When should I use this?
This plugin adds support to unified for parsing HTML.
You can alternatively use [`rehype`][rehype-core] instead, which combines
unified, this plugin, and [`rehype-stringify`][rehype-stringify].
When youre in a browser, trust your content, dont need positional info, and
value a smaller bundle size, you can use [`rehype-dom-parse`][rehype-dom-parse]
instead.
This plugin is built on [`parse5`][parse5] and
[`hast-util-from-parse5`][hast-util-from-parse5], which deal with HTML-compliant
tokenizing, parsing, and creating nodes.
rehype focusses on making it easier to transform content by abstracting such
internals away.
## Install
This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
```sh
npm install rehype-parse
```
In Deno with [Skypack][]:
```js
import rehypeParse from 'https://cdn.skypack.dev/rehype-parse@8?dts'
```
In browsers with [Skypack][]:
```html
<script type="module">
import rehypeParse from 'https://cdn.skypack.dev/rehype-parse@8?min'
</script>
```
## Use
Say we have the following module `example.js`:
```js
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeRemark from 'rehype-remark'
import remarkStringify from 'remark-stringify'
main()
async function main() {
const file = await unified()
.use(rehypeParse)
.use(rehypeRemark)
.use(remarkStringify)
.process('<h1>Hello, world!</h1>')
console.log(String(file))
}
```
…running that with `node example.js` yields:
```markdown
# Hello, world!
```
## API
This package exports no identifiers.
The default export is `rehypeParse`.
### `unified().use(rehypeParse[, options])`
Add support for parsing HTML input.
##### `options`
Configuration (optional).
###### `options.fragment`
Specify whether to parse as a fragment (`boolean`, default: `false`).
The default is to expect a whole document.
In document mode, unopened `html`, `head`, and `body` elements are opened.
###### `options.space`
Which space the document is in (`'svg'` or `'html'`, default: `'html'`).
When an `<svg>` element is found in the HTML space, `rehype-parse` already
automatically switches to and from the SVG space when entering and exiting it.
> 👉 **Note**: rehype is not an XML parser.
> It supports SVG as embedded in HTML.
> It does not support the features available in XML.
> Passing SVG files might break but fragments of modern SVG should be fine.
> 👉 **Note**: make sure to set `fragment: true` if `space: 'svg'`.
###### `options.emitParseErrors`
Emit [HTML parse errors][parse-errors] as warning messages
(`boolean`, default: `false`).
Specific rules can be turned off by setting their IDs in `options` to `false`
(or `0`).
The default, when `emitParseErrors: true`, is `true` (or `1`), and means that
rules emit as warnings.
Rules can also be configured with `2`, to turn them into fatal errors.
The list of parse errors:
<!-- parse-error start -->
* `abandonedHeadElementChild` — unexpected metadata element after head ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/abandoned-head-element-child/index.html))
* [`abruptClosingOfEmptyComment`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-abrupt-closing-of-empty-comment) — unexpected abruptly closed empty comment ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/abrupt-closing-of-empty-comment/index.html))
* [`abruptDoctypePublicIdentifier`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-abrupt-doctype-public-identifier) — unexpected abruptly closed public identifier ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/abrupt-doctype-public-identifier/index.html))
* [`abruptDoctypeSystemIdentifier`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-abrupt-doctype-system-identifier) — unexpected abruptly closed system identifier ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/abrupt-doctype-system-identifier/index.html))
* [`absenceOfDigitsInNumericCharacterReference`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-absence-of-digits-in-numeric-character-reference) — unexpected non-digit at start of numeric character reference ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/absence-of-digits-in-numeric-character-reference/index.html))
* [`cdataInHtmlContent`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-cdata-in-html-content) — unexpected CDATA section in HTML ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/cdata-in-html-content/index.html))
* [`characterReferenceOutsideUnicodeRange`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-character-reference-outside-unicode-range) — unexpected too big numeric character reference ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/character-reference-outside-unicode-range/index.html))
* `closingOfElementWithOpenChildElements` — unexpected closing tag with open child elements ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/closing-of-element-with-open-child-elements/index.html))
* [`controlCharacterInInputStream`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-control-character-in-input-stream) — unexpected control character ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/control-character-in-input-stream/index.html))
* [`controlCharacterReference`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-control-character-reference) — unexpected control character reference ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/control-character-reference/index.html))
* `disallowedContentInNoscriptInHead` — disallowed content inside `<noscript>` in `<head>` ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/disallowed-content-in-noscript-in-head/index.html))
* [`duplicateAttribute`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-duplicate-attribute) — unexpected duplicate attribute ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/duplicate-attribute/index.html))
* [`endTagWithAttributes`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-end-tag-with-attributes) — unexpected attribute on closing tag ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/end-tag-with-attributes/index.html))
* [`endTagWithTrailingSolidus`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-end-tag-with-trailing-solidus) — unexpected slash at end of closing tag ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/end-tag-with-trailing-solidus/index.html))
* `endTagWithoutMatchingOpenElement` — unexpected unopened end tag ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/end-tag-without-matching-open-element/index.html))
* [`eofBeforeTagName`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-eof-before-tag-name) — unexpected end of file ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/eof-before-tag-name/index.html))
* [`eofInCdata`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-eof-in-cdata) — unexpected end of file in CDATA ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/eof-in-cdata/index.html))
* [`eofInComment`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-eof-in-comment) — unexpected end of file in comment ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/eof-in-comment/index.html))
* [`eofInDoctype`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-eof-in-doctype) — unexpected end of file in doctype ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/eof-in-doctype/index.html))
* `eofInElementThatCanContainOnlyText` — unexpected end of file in element that can only contain text ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/eof-in-element-that-can-contain-only-text/index.html))
* [`eofInScriptHtmlCommentLikeText`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-eof-in-script-html-comment-like-text) — unexpected end of file in comment inside script ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/eof-in-script-html-comment-like-text/index.html))
* [`eofInTag`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-eof-in-tag) — unexpected end of file in tag ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/eof-in-tag/index.html))
* [`incorrectlyClosedComment`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-incorrectly-closed-comment) — incorrectly closed comment ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/incorrectly-closed-comment/index.html))
* [`incorrectlyOpenedComment`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-incorrectly-opened-comment) — incorrectly opened comment ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/incorrectly-opened-comment/index.html))
* [`invalidCharacterSequenceAfterDoctypeName`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-invalid-character-sequence-after-doctype-name) — invalid sequence after doctype name ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/invalid-character-sequence-after-doctype-name/index.html))
* [`invalidFirstCharacterOfTagName`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-invalid-first-character-of-tag-name) — invalid first character in tag name ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/invalid-first-character-of-tag-name/index.html))
* `misplacedDoctype` — misplaced doctype ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/misplaced-doctype/index.html))
* `misplacedStartTagForHeadElement` — misplaced `<head>` start tag ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/misplaced-start-tag-for-head-element/index.html))
* [`missingAttributeValue`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-attribute-value) — missing attribute value ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-attribute-value/index.html))
* `missingDoctype` — missing doctype before other content ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-doctype/index.html))
* [`missingDoctypeName`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-doctype-name) — missing doctype name ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-doctype-name/index.html))
* [`missingDoctypePublicIdentifier`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-doctype-public-identifier) — missing public identifier in doctype ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-doctype-public-identifier/index.html))
* [`missingDoctypeSystemIdentifier`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-doctype-system-identifier) — missing system identifier in doctype ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-doctype-system-identifier/index.html))
* [`missingEndTagName`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-end-tag-name) — missing name in end tag ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-end-tag-name/index.html))
* [`missingQuoteBeforeDoctypePublicIdentifier`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-quote-before-doctype-public-identifier) — missing quote before public identifier in doctype ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-quote-before-doctype-public-identifier/index.html))
* [`missingQuoteBeforeDoctypeSystemIdentifier`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-quote-before-doctype-system-identifier) — missing quote before system identifier in doctype ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-quote-before-doctype-system-identifier/index.html))
* [`missingSemicolonAfterCharacterReference`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-semicolon-after-character-reference) — missing semicolon after character reference ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-semicolon-after-character-reference/index.html))
* [`missingWhitespaceAfterDoctypePublicKeyword`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-whitespace-after-doctype-public-keyword) — missing whitespace after public identifier in doctype ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-whitespace-after-doctype-public-keyword/index.html))
* [`missingWhitespaceAfterDoctypeSystemKeyword`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-whitespace-after-doctype-system-keyword) — missing whitespace after system identifier in doctype ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-whitespace-after-doctype-system-keyword/index.html))
* [`missingWhitespaceBeforeDoctypeName`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-whitespace-before-doctype-name) — missing whitespace before doctype name ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-whitespace-before-doctype-name/index.html))
* [`missingWhitespaceBetweenAttributes`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-whitespace-between-attributes) — missing whitespace between attributes ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-whitespace-between-attributes/index.html))
* [`missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-missing-whitespace-between-doctype-public-and-system-identifiers) — missing whitespace between public and system identifiers in doctype ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/missing-whitespace-between-doctype-public-and-system-identifiers/index.html))
* [`nestedComment`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-nested-comment) — unexpected nested comment ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/nested-comment/index.html))
* `nestedNoscriptInHead` — unexpected nested `<noscript>` in `<head>` ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/nested-noscript-in-head/index.html))
* `nonConformingDoctype` — unexpected non-conforming doctype declaration ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/non-conforming-doctype/index.html))
* [`nonVoidHtmlElementStartTagWithTrailingSolidus`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-non-void-html-element-start-tag-with-trailing-solidus) — unexpected trailing slash on start tag of non-void element ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/non-void-html-element-start-tag-with-trailing-solidus/index.html))
* [`noncharacterCharacterReference`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-noncharacter-character-reference) — unexpected noncharacter code point referenced by character reference ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/noncharacter-character-reference/index.html))
* [`noncharacterInInputStream`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-noncharacter-in-input-stream) — unexpected noncharacter character ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/noncharacter-in-input-stream/index.html))
* [`nullCharacterReference`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-null-character-reference) — unexpected NULL character referenced by character reference ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/null-character-reference/index.html))
* `openElementsLeftAfterEof` — unexpected end of file ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/open-elements-left-after-eof/index.html))
* [`surrogateCharacterReference`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-surrogate-character-reference) — unexpected surrogate character referenced by character reference ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/surrogate-character-reference/index.html))
* [`surrogateInInputStream`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-surrogate-in-input-stream) — unexpected surrogate character
* [`unexpectedCharacterAfterDoctypeSystemIdentifier`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-unexpected-character-after-doctype-system-identifier) — invalid character after system identifier in doctype ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/unexpected-character-after-doctype-system-identifier/index.html))
* [`unexpectedCharacterInAttributeName`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-unexpected-character-in-attribute-name) — unexpected character in attribute name ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/unexpected-character-in-attribute-name/index.html))
* [`unexpectedCharacterInUnquotedAttributeValue`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-unexpected-character-in-unquoted-attribute-value) — unexpected character in unquoted attribute value ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/unexpected-character-in-unquoted-attribute-value/index.html))
* [`unexpectedEqualsSignBeforeAttributeName`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-unexpected-equals-sign-before-attribute-name) — unexpected equals sign before attribute name ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/unexpected-equals-sign-before-attribute-name/index.html))
* [`unexpectedNullCharacter`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-unexpected-null-character) — unexpected NULL character ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/unexpected-null-character/index.html))
* [`unexpectedQuestionMarkInsteadOfTagName`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-unexpected-question-mark-instead-of-tag-name) — unexpected question mark instead of tag name ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/unexpected-question-mark-instead-of-tag-name/index.html))
* [`unexpectedSolidusInTag`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-unexpected-solidus-in-tag) — unexpected slash in tag ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/unexpected-solidus-in-tag/index.html))
* [`unknownNamedCharacterReference`](https://html.spec.whatwg.org/multipage/parsing.html#parse-error-unknown-named-character-reference) — unexpected unknown named character reference ([example](https://github.com/rehypejs/rehype/blob/main/test/parse-error/unknown-named-character-reference/index.html))
<!-- parse-error end -->
###### `options.verbose`
Add extra positional info (`boolean`, default: `false`).
## Examples
### Example: fragment versus document
The following example shows the difference between parsing as a document and
parsing as a fragment:
```js
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'
main()
async function main() {
const doc = '<title>Hi!</title><h1>Hello!</h1>'
console.log(
String(
await unified()
.use(rehypeParse, {fragment: true})
.use(rehypeStringify)
.process(doc)
)
)
console.log(
String(
await unified()
.use(rehypeParse, {fragment: false})
.use(rehypeStringify)
.process(doc)
)
)
}
```
…yields:
```html
<title>Hi!</title><h1>Hello!</h1>
```
```html
<html><head><title>Hi!</title></head><body><h1>Hello!</h1></body></html>
```
> 👉 **Note**: observe that when a whole document is expected (second example),
> missing elements are opened and closed.
### Example: whitespace around and inside `<html>`
The following example shows how whitespace is handled when around and directly
inside the `<html>` element:
```js
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'
main(`<!doctype html>
<html lang=en>
<head>
<title>Hi!</title>
</head>
<body>
<h1>Hello!</h1>
</body>
</html>`)
async function main(doc) {
console.log(
String(await unified().use(rehypeParse).use(rehypeStringify).process(doc))
)
}
```
…yields (where `␠` represents a space character):
```html
<!doctype html><html lang="en"><head>
<title>Hi!</title>
</head>
<body>
<h1>Hello!</h1>
␠␠
</body></html>
```
> 👉 **Note**: observe that the line ending before `<html>` is ignored, the line
> ending and two spaces before `<head>` is moved inside it, and the line ending
> after `</body>` is moved before it.
This behavior is described by the HTML standard (see the section 13.2.6.4.1
“The initial insertion mode” and adjacent states) which rehype follows.
The changes to this meaningless whitespace should not matter, except when
formatting markup, in which case [`rehype-format`][rehype-format] can be used to
improve the source code.
### Example: parse errors
The following example shows how HTML parse errors can be enabled and configured:
```js
import {reporter} from 'vfile-reporter'
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'
main()
async function main() {
const file = await unified()
.use(rehypeParse, {
emitParseErrors: true, // Emit all.
missingWhitespaceBeforeDoctypeName: 2, // Mark one as a fatal error.
nonVoidHtmlElementStartTagWithTrailingSolidus: false // Ignore one.
})
.use(rehypeStringify)
.process(`<!doctypehtml>
<title class="a" class="b">Hello…</title>
<h1/>World!</h1>`)
console.log(reporter(file))
}
```
…yields:
```html
1:10-1:10 error Missing whitespace before doctype name missing-whitespace-before-doctype-name parse-error
2:23-2:23 warning Unexpected duplicate attribute duplicate-attribute parse-error
2 messages (✖ 1 error, ⚠ 1 warning)
```
> 🧑‍🏫 **Info**: messages in unified are warnings instead of errors.
> Other linters (such as ESLint) almost always use errors.
> Why?
> Those tools *only* check code style.
> They dont generate, transform, and format code, which is what rehype and
> unified focus on, too.
> Errors in unified mean the same as an exception in your JavaScript code: a
> crash.
> Thats why we use warnings instead, because we continue checking more HTML and
> continue running more plugins.
## Syntax
HTML is parsed according to WHATWG HTML (the living standard), which is also
followed by browsers such as Chrome and Firefox.
## Syntax tree
The syntax tree format used in rehype is [hast][].
## Types
This package is fully typed with [TypeScript][].
The extra types `Options`, `ErrorCode`, and `ErrorSeverity` are exported.
## Compatibility
Projects maintained by the unified collective are compatible with all maintained
versions of Node.js.
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
Our projects sometimes work with older versions, but this is not guaranteed.
## Security
As **rehype** works on HTML, and improper use of HTML can open you up to a
[cross-site scripting (XSS)][xss] attack, use of rehype can also be unsafe.
Use [`rehype-sanitize`][rehype-sanitize] to make the tree safe.
Use of rehype plugins could also open you up to other attacks.
Carefully assess each plugin and the risks involved in using them.
For info on how to submit a report, see our [security policy][security].
## Contribute
See [`contributing.md`][contributing] in [`rehypejs/.github`][health] for ways
to get started.
See [`support.md`][support] for ways to get help.
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
## Sponsor
Support this effort and give back by sponsoring on [OpenCollective][collective]!
<!--lint ignore no-html-->
<table>
<tr valign="middle">
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://vercel.com">Vercel</a><br><br>
<a href="https://vercel.com"><img src="https://avatars1.githubusercontent.com/u/14985020?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://motif.land">Motif</a><br><br>
<a href="https://motif.land"><img src="https://avatars1.githubusercontent.com/u/74457950?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://www.hashicorp.com">HashiCorp</a><br><br>
<a href="https://www.hashicorp.com"><img src="https://avatars1.githubusercontent.com/u/761456?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://www.gitbook.com">GitBook</a><br><br>
<a href="https://www.gitbook.com"><img src="https://avatars1.githubusercontent.com/u/7111340?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://www.gatsbyjs.org">Gatsby</a><br><br>
<a href="https://www.gatsbyjs.org"><img src="https://avatars1.githubusercontent.com/u/12551863?s=256&v=4" width="128"></a>
</td>
</tr>
<tr valign="middle">
</tr>
<tr valign="middle">
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://www.netlify.com">Netlify</a><br><br>
<!--OC has a sharper image-->
<a href="https://www.netlify.com"><img src="https://images.opencollective.com/netlify/4087de2/logo/256.png" width="128"></a>
</td>
<td width="10%" align="center">
<a href="https://www.coinbase.com">Coinbase</a><br><br>
<a href="https://www.coinbase.com"><img src="https://avatars1.githubusercontent.com/u/1885080?s=256&v=4" width="64"></a>
</td>
<td width="10%" align="center">
<a href="https://themeisle.com">ThemeIsle</a><br><br>
<a href="https://themeisle.com"><img src="https://avatars1.githubusercontent.com/u/58979018?s=128&v=4" width="64"></a>
</td>
<td width="10%" align="center">
<a href="https://expo.io">Expo</a><br><br>
<a href="https://expo.io"><img src="https://avatars1.githubusercontent.com/u/12504344?s=128&v=4" width="64"></a>
</td>
<td width="10%" align="center">
<a href="https://boostnote.io">Boost Note</a><br><br>
<a href="https://boostnote.io"><img src="https://images.opencollective.com/boosthub/6318083/logo/128.png" width="64"></a>
</td>
<td width="10%" align="center">
<a href="https://www.holloway.com">Holloway</a><br><br>
<a href="https://www.holloway.com"><img src="https://avatars1.githubusercontent.com/u/35904294?s=128&v=4" width="64"></a>
</td>
<td width="10%"></td>
<td width="10%"></td>
<td width="10%"></td>
</tr>
<tr valign="middle">
<td width="100%" align="center" colspan="8">
<br>
<a href="https://opencollective.com/unified"><strong>You?</strong></a>
<br><br>
</td>
</tr>
</table>
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[build-badge]: https://github.com/rehypejs/rehype/workflows/main/badge.svg
[build]: https://github.com/rehypejs/rehype/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype.svg
[coverage]: https://codecov.io/github/rehypejs/rehype
[downloads-badge]: https://img.shields.io/npm/dm/rehype-parse.svg
[downloads]: https://www.npmjs.com/package/rehype-parse
[size-badge]: https://img.shields.io/bundlephobia/minzip/rehype-parse.svg
[size]: https://bundlephobia.com/result?p=rehype-parse
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/rehypejs/rehype/discussions
[security]: https://github.com/rehypejs/.github/blob/main/security.md
[health]: https://github.com/rehypejs/.github
[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md
[support]: https://github.com/rehypejs/.github/blob/main/support.md
[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md
[license]: https://github.com/rehypejs/rehype/blob/main/license
[author]: https://wooorm.com
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://docs.npmjs.com/cli/install
[skypack]: https://www.skypack.dev
[unified]: https://github.com/unifiedjs/unified
[rehype]: https://github.com/rehypejs/rehype
[hast]: https://github.com/syntax-tree/hast
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[typescript]: https://www.typescriptlang.org
[rehype-stringify]: ../rehype-stringify/
[rehype-core]: ../rehype/
[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize
[hast-util-from-parse5]: https://github.com/syntax-tree/hast-util-from-parse5
[parse-errors]: https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
[rehype-dom-parse]: https://github.com/rehypejs/rehype-dom/tree/main/packages/rehype-dom-parse
[rehype-format]: https://github.com/rehypejs/rehype-format
[parse5]: https://github.com/inikulin/parse5