This commit is contained in:
253
node_modules/rehype-parse/errors.json
generated
vendored
Normal file
253
node_modules/rehype-parse/errors.json
generated
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
94
node_modules/rehype-parse/index.js
generated
vendored
Normal file
94
node_modules/rehype-parse/index.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
'use strict'
|
||||
|
||||
var fromParse5 = require('hast-util-from-parse5')
|
||||
var Parser5 = require('parse5/lib/parser')
|
||||
var xtend = require('xtend')
|
||||
var errors = require('./errors.json')
|
||||
|
||||
var base = 'https://html.spec.whatwg.org/multipage/parsing.html#parse-error-'
|
||||
|
||||
var fatalities = {2: true, 1: false, 0: null}
|
||||
|
||||
module.exports = parse
|
||||
|
||||
function parse(options) {
|
||||
var settings = xtend(options, this.data('settings'))
|
||||
var position = settings.position
|
||||
|
||||
position = typeof position === 'boolean' ? position : true
|
||||
|
||||
this.Parser = parser
|
||||
|
||||
function parser(doc, file) {
|
||||
var fn = settings.fragment ? 'parseFragment' : 'parse'
|
||||
var onParseError = settings.emitParseErrors ? onerror : null
|
||||
var parse5 = new Parser5({
|
||||
sourceCodeLocationInfo: position,
|
||||
onParseError: onParseError,
|
||||
scriptingEnabled: false
|
||||
})
|
||||
|
||||
return fromParse5(parse5[fn](doc), {
|
||||
space: settings.space,
|
||||
file: file,
|
||||
verbose: settings.verbose
|
||||
})
|
||||
|
||||
function onerror(err) {
|
||||
var code = err.code
|
||||
var name = camelcase(code)
|
||||
var setting = settings[name]
|
||||
var config = setting === undefined || setting === null ? true : setting
|
||||
var level = typeof config === 'number' ? config : config ? 1 : 0
|
||||
var start = {
|
||||
line: err.startLine,
|
||||
column: err.startCol,
|
||||
offset: err.startOffset
|
||||
}
|
||||
var end = {line: err.endLine, column: err.endCol, offset: err.endOffset}
|
||||
var info
|
||||
var message
|
||||
|
||||
if (level) {
|
||||
info = errors[name] || /* istanbul ignore next */ {
|
||||
reason: '',
|
||||
description: ''
|
||||
}
|
||||
|
||||
message = file.message(format(info.reason), {start: start, end: end})
|
||||
message.source = 'parse-error'
|
||||
message.ruleId = code
|
||||
message.fatal = fatalities[level]
|
||||
message.note = format(info.description)
|
||||
message.url = info.url === false ? null : base + code
|
||||
}
|
||||
|
||||
function format(value) {
|
||||
return value.replace(/%c(?:-(\d+))?/g, char).replace(/%x/g, encodedChar)
|
||||
}
|
||||
|
||||
function char($0, $1) {
|
||||
var offset = $1 ? -parseInt($1, 10) : 0
|
||||
var char = doc.charAt(err.startOffset + offset)
|
||||
return char === '`' ? '` ` `' : char
|
||||
}
|
||||
|
||||
function encodedChar() {
|
||||
var char = doc
|
||||
.charCodeAt(err.startOffset)
|
||||
.toString(16)
|
||||
.toUpperCase()
|
||||
|
||||
return '0x' + char
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function camelcase(value) {
|
||||
return value.replace(/-[a-z]/g, replacer)
|
||||
}
|
||||
|
||||
function replacer($0) {
|
||||
return $0.charAt(1).toUpperCase()
|
||||
}
|
||||
35
node_modules/rehype-parse/package.json
generated
vendored
Normal file
35
node_modules/rehype-parse/package.json
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "rehype-parse",
|
||||
"version": "6.0.2",
|
||||
"description": "HTML parser for rehype",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"html",
|
||||
"abstract",
|
||||
"syntax",
|
||||
"tree",
|
||||
"ast",
|
||||
"parse"
|
||||
],
|
||||
"homepage": "https://github.com/rehypejs/rehype",
|
||||
"repository": "https://github.com/rehypejs/rehype/tree/master/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)"
|
||||
],
|
||||
"files": [
|
||||
"index.js",
|
||||
"errors.json"
|
||||
],
|
||||
"dependencies": {
|
||||
"hast-util-from-parse5": "^5.0.0",
|
||||
"parse5": "^5.0.0",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"xo": false
|
||||
}
|
||||
353
node_modules/rehype-parse/readme.md
generated
vendored
Normal file
353
node_modules/rehype-parse/readme.md
generated
vendored
Normal file
@@ -0,0 +1,353 @@
|
||||
# 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**][rehype] plugin to parse HTML.
|
||||
[Parser][] for [**unified**][unified].
|
||||
Parses HTML to [**hast**][hast] syntax trees.
|
||||
Used in the [**rehype** processor][processor] but can be used on its own as
|
||||
well.
|
||||
|
||||
If you’re in a browser, trust the content, and value a smaller bundle size, use
|
||||
[`rehype-dom-parse`][rehype-dom-parse].
|
||||
|
||||
## Sponsors
|
||||
|
||||
<!--lint ignore no-html maximum-line-length-->
|
||||
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td width="20%" align="center">
|
||||
<a href="https://zeit.co"><img src="https://avatars1.githubusercontent.com/u/14985020?s=400&v=4"></a>
|
||||
<br><br>🥇
|
||||
<a href="https://zeit.co">ZEIT</a>
|
||||
</td>
|
||||
<td width="20%" align="center">
|
||||
<a href="https://www.gatsbyjs.org"><img src="https://avatars1.githubusercontent.com/u/12551863?s=400&v=4"></a>
|
||||
<br><br>🥇
|
||||
<a href="https://www.gatsbyjs.org">Gatsby</a>
|
||||
</td>
|
||||
<td width="20%" align="center">
|
||||
<a href="https://www.netlify.com"><img src="https://avatars1.githubusercontent.com/u/7892489?s=400&v=4"></a>
|
||||
<br><br>🥇
|
||||
<a href="https://www.netlify.com">Netlify</a>
|
||||
</td>
|
||||
<td width="20%" align="center">
|
||||
<a href="https://www.holloway.com"><img src="https://avatars1.githubusercontent.com/u/35904294?s=400&v=4"></a>
|
||||
<br><br>
|
||||
<a href="https://www.holloway.com">Holloway</a>
|
||||
</td>
|
||||
<td width="20%" align="center">
|
||||
<br><br><br><br>
|
||||
<a href="https://opencollective.com/unified"><strong>You?</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
[**Read more about the unified collective on Medium »**][announcement]
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install rehype-parse
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
This example shows how we can parse HTML with this module and configure it to
|
||||
emit parse errors except for duplicate attributes.
|
||||
Then we transform HTML to Markdown with [`rehype-remark`][rehype-remark] and
|
||||
finally compile that Markdown with [`remark-stringify`][remark-stringify].
|
||||
|
||||
Say we have the following file, `example.html`, with a few errors:
|
||||
|
||||
```html
|
||||
<!doctypehtml>
|
||||
<title class="a" class="b">Hello…</title>
|
||||
<h1/>World!</h1>
|
||||
```
|
||||
|
||||
…and our script, `example.js`, looks as follows:
|
||||
|
||||
```js
|
||||
var vfile = require('to-vfile')
|
||||
var report = require('vfile-reporter')
|
||||
var unified = require('unified')
|
||||
var parse = require('rehype-parse')
|
||||
var rehype2remark = require('rehype-remark')
|
||||
var stringify = require('remark-stringify')
|
||||
|
||||
unified()
|
||||
.use(parse, {emitParseErrors: true, duplicateAttribute: false})
|
||||
.use(rehype2remark)
|
||||
.use(stringify)
|
||||
.process(vfile.readSync('example.html'), function(err, file) {
|
||||
console.error(report(err || file))
|
||||
console.log(String(file))
|
||||
})
|
||||
```
|
||||
|
||||
Now, running `node example` yields:
|
||||
|
||||
```txt
|
||||
example.html
|
||||
1:10-1:10 warning Missing whitespace before doctype name missing-whitespace-before-doctype-name parse-error
|
||||
3:1-3:6 warning Unexpected trailing slash on start tag of non-void element non-void-html-element-start-tag-with-trailing-solidus parse-error
|
||||
|
||||
⚠ 2 warnings
|
||||
```
|
||||
|
||||
```markdown
|
||||
# World!
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `processor.use(parse[, options])`
|
||||
|
||||
Configure `processor` to parse HTML and create a [**hast**][hast] syntax tree.
|
||||
|
||||
##### `options`
|
||||
|
||||
###### `options.fragment`
|
||||
|
||||
Specify whether to parse a fragment (`boolean`, default: `false`), instead of a
|
||||
complete document.
|
||||
In document mode, unopened `html`, `head`, and `body` elements are opened in
|
||||
just the right places.
|
||||
|
||||
###### `options.space`
|
||||
|
||||
> ⚠️ rehype is not an XML parser.
|
||||
> It support SVG as embedded in HTML, but not the features available in the rest
|
||||
> of XML/SVG.
|
||||
> Passing SVG files could strip useful information, but fragments of modern SVG
|
||||
> should be fine.
|
||||
|
||||
Which space the document is in (`'svg'` or `'html'`, default: `'html'`).
|
||||
|
||||
If an `svg` element is found in the HTML space, `stringify` automatically
|
||||
switches to the SVG space when [**entering**][enter] the element, and switches
|
||||
back when [**exiting**][exit].
|
||||
|
||||
**Note**: make sure to set `fragment: true` if `space: 'svg'`.
|
||||
|
||||
###### `options.emitParseErrors`
|
||||
|
||||
> ⚠️ 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][] (`boolean`, default: `false`).
|
||||
|
||||
Setting this to true starts emitting [HTML parse errors][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.
|
||||
|
||||
The specific parse errors that are currently supported are detailed below:
|
||||
|
||||
<!-- parse-error start -->
|
||||
|
||||
* `abandonedHeadElementChild` — unexpected metadata element after head ([example](https://github.com/rehypejs/rehype/blob/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/test/parse-error/control-character-reference/index.html))
|
||||
* `disallowedContentInNoscriptInHead` — disallowed content inside \`<noscript>\` in \`<head>\` ([example](https://github.com/rehypejs/rehype/blob/master/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/master/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/master/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/master/test/parse-error/end-tag-with-trailing-solidus/index.html))
|
||||
* `endTagWithoutMatchingOpenElement` — unexpected unopened end tag ([example](https://github.com/rehypejs/rehype/blob/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/test/parse-error/invalid-first-character-of-tag-name/index.html))
|
||||
* `misplacedDoctype` — misplaced doctype ([example](https://github.com/rehypejs/rehype/blob/master/test/parse-error/misplaced-doctype/index.html))
|
||||
* `misplacedStartTagForHeadElement` — misplaced \`<head>\` start tag ([example](https://github.com/rehypejs/rehype/blob/master/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/master/test/parse-error/missing-attribute-value/index.html))
|
||||
* `missingDoctype` — missing doctype before other content ([example](https://github.com/rehypejs/rehype/blob/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/test/parse-error/nested-comment/index.html))
|
||||
* `nestedNoscriptInHead` — unexpected nested \`<noscript>\` in \`<head>\` ([example](https://github.com/rehypejs/rehype/blob/master/test/parse-error/nested-noscript-in-head/index.html))
|
||||
* `nonConformingDoctype` — unexpected non-conforming doctype declaration ([example](https://github.com/rehypejs/rehype/blob/master/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/master/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/master/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/master/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/master/test/parse-error/null-character-reference/index.html))
|
||||
* `openElementsLeftAfterEof` — unexpected end of file ([example](https://github.com/rehypejs/rehype/blob/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/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/master/test/parse-error/unknown-named-character-reference/index.html))
|
||||
|
||||
<!-- parse-error end -->
|
||||
|
||||
###### `options.verbose`
|
||||
|
||||
Patch extra positional information (`boolean`, default: `false`).
|
||||
If specified, the following element:
|
||||
|
||||
```html
|
||||
<img src="#" alt>
|
||||
```
|
||||
|
||||
…has the following `data`:
|
||||
|
||||
```js
|
||||
{ position:
|
||||
{ opening:
|
||||
{ start: { line: 1, column: 1, offset: 0 },
|
||||
end: { line: 1, column: 18, offset: 17 } },
|
||||
closing: null,
|
||||
properties:
|
||||
{ src:
|
||||
{ start: { line: 1, column: 6, offset: 5 },
|
||||
end: { line: 1, column: 13, offset: 12 } },
|
||||
alt:
|
||||
{ start: { line: 1, column: 14, offset: 13 },
|
||||
end: { line: 1, column: 17, offset: 16 } } } } }
|
||||
```
|
||||
|
||||
### `parse.Parser`
|
||||
|
||||
Access to the [parser][], if you need it.
|
||||
|
||||
## 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`][sanitize] to make the tree safe.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`rehypejs/.github`][health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
Ideas for new plugins and tools can be posted in [`rehypejs/ideas`][ideas].
|
||||
|
||||
A curated list of awesome rehype resources can be found in [**awesome
|
||||
rehype**][awesome].
|
||||
|
||||
This project has a [Code of Conduct][coc].
|
||||
By interacting with this repository, organisation, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/rehypejs/rehype.svg
|
||||
|
||||
[build]: https://travis-ci.org/rehypejs/rehype
|
||||
|
||||
[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/join%20the%20community-on%20spectrum-7b16ff.svg
|
||||
|
||||
[chat]: https://spectrum.chat/unified/rehype
|
||||
|
||||
[health]: https://github.com/rehypejs/.github
|
||||
|
||||
[contributing]: https://github.com/rehypejs/.github/blob/master/contributing.md
|
||||
|
||||
[support]: https://github.com/rehypejs/.github/blob/master/support.md
|
||||
|
||||
[coc]: https://github.com/rehypejs/.github/blob/master/code-of-conduct.md
|
||||
|
||||
[ideas]: https://github.com/rehypejs/ideas
|
||||
|
||||
[awesome]: https://github.com/rehypejs/awesome-rehype
|
||||
|
||||
[license]: https://github.com/rehypejs/rehype/blob/master/license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[rehype-remark]: https://github.com/rehypejs/rehype-remark
|
||||
|
||||
[remark-stringify]: https://github.com/remarkjs/remark/tree/master/packages/remark-stringify
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[vfile]: https://github.com/vfile/vfile
|
||||
|
||||
[parse-errors]: https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
|
||||
|
||||
[rehype]: https://github.com/rehypejs/rehype
|
||||
|
||||
[processor]: https://github.com/rehypejs/rehype/tree/master/packages/rehype
|
||||
|
||||
[hast]: https://github.com/syntax-tree/hast
|
||||
|
||||
[rehype-dom-parse]: https://github.com/rehypejs/rehype-dom/tree/master/packages/rehype-dom-parse
|
||||
|
||||
[parser]: https://github.com/unifiedjs/unified#processorparser
|
||||
|
||||
[announcement]: https://medium.com/unifiedjs/collectively-evolving-through-crowdsourcing-22c359ea95cc
|
||||
|
||||
[enter]: https://github.com/syntax-tree/unist#enter
|
||||
|
||||
[exit]: https://github.com/syntax-tree/unist#exit
|
||||
|
||||
[sanitize]: https://github.com/rehypejs/rehype-sanitize
|
||||
|
||||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
|
||||
Reference in New Issue
Block a user