parse5
- Version 7.2.1
- Published
- 695 kB
- 1 dependency
- MIT license
Install
npm i parse5
yarn add parse5
pnpm add parse5
Overview
HTML parser and serializer.
Index
Variables
Functions
Classes
Tokenizer
- active
- consumedAfterSnapshot
- currentAttr
- currentCharacterToken
- currentLocation
- currentToken
- emitCurrentComment()
- emitCurrentDoctype()
- emitCurrentTagToken()
- entityDecoder
- entityStartPos
- getCurrentLocation()
- handler
- handleSpecialEndTag()
- inForeignNode
- inLoop
- insertHtmlAtCurrentPos()
- lastStartTagName
- options
- pause()
- paused
- prepareToken()
- preprocessor
- resume()
- returnState
- state
- write()
Interfaces
TreeAdapter
- adoptAttributes()
- appendChild()
- createCommentNode()
- createDocument()
- createDocumentFragment()
- createElement()
- createTextNode()
- detachNode()
- getAttrList()
- getChildNodes()
- getCommentNodeContent()
- getDocumentMode()
- getDocumentTypeNodeName()
- getDocumentTypeNodePublicId()
- getDocumentTypeNodeSystemId()
- getFirstChild()
- getNamespaceURI()
- getNodeSourceCodeLocation()
- getParentNode()
- getTagName()
- getTemplateContent()
- getTextNodeContent()
- insertBefore()
- insertText()
- insertTextBefore()
- isCommentNode()
- isDocumentTypeNode()
- isElementNode()
- isTextNode()
- onItemPop
- onItemPush
- setDocumentMode()
- setDocumentType()
- setNodeSourceCodeLocation()
- setTemplateContent()
- updateNodeSourceCodeLocation()
Enums
ErrorCodes
- abandonedHeadElementChild
- abruptClosingOfEmptyComment
- abruptDoctypePublicIdentifier
- abruptDoctypeSystemIdentifier
- absenceOfDigitsInNumericCharacterReference
- cdataInHtmlContent
- characterReferenceOutsideUnicodeRange
- closingOfElementWithOpenChildElements
- controlCharacterInInputStream
- controlCharacterReference
- disallowedContentInNoscriptInHead
- duplicateAttribute
- endTagWithAttributes
- endTagWithoutMatchingOpenElement
- endTagWithTrailingSolidus
- eofBeforeTagName
- eofInCdata
- eofInComment
- eofInDoctype
- eofInElementThatCanContainOnlyText
- eofInScriptHtmlCommentLikeText
- eofInTag
- incorrectlyClosedComment
- incorrectlyOpenedComment
- invalidCharacterSequenceAfterDoctypeName
- invalidFirstCharacterOfTagName
- misplacedDoctype
- misplacedStartTagForHeadElement
- missingAttributeValue
- missingDoctype
- missingDoctypeName
- missingDoctypePublicIdentifier
- missingDoctypeSystemIdentifier
- missingEndTagName
- missingQuoteBeforeDoctypePublicIdentifier
- missingQuoteBeforeDoctypeSystemIdentifier
- missingSemicolonAfterCharacterReference
- missingWhitespaceAfterDoctypePublicKeyword
- missingWhitespaceAfterDoctypeSystemKeyword
- missingWhitespaceBeforeDoctypeName
- missingWhitespaceBetweenAttributes
- missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers
- nestedComment
- nestedNoscriptInHead
- noncharacterCharacterReference
- noncharacterInInputStream
- nonConformingDoctype
- nonVoidHtmlElementStartTagWithTrailingSolidus
- nullCharacterReference
- openElementsLeftAfterEof
- surrogateCharacterReference
- surrogateInInputStream
- unexpectedCharacterAfterDoctypeSystemIdentifier
- unexpectedCharacterInAttributeName
- unexpectedCharacterInUnquotedAttributeValue
- unexpectedEqualsSignBeforeAttributeName
- unexpectedNullCharacter
- unexpectedQuestionMarkInsteadOfTagName
- unexpectedSolidusInTag
- unknownNamedCharacterReference
Type Aliases
Namespaces
Variables
variable defaultTreeAdapter
const defaultTreeAdapter: TreeAdapter<DefaultTreeAdapterMap>;
variable TokenizerMode
const TokenizerMode: { readonly DATA: State.DATA; readonly RCDATA: State.RCDATA; readonly RAWTEXT: State.RAWTEXT; readonly SCRIPT_DATA: State.SCRIPT_DATA; readonly PLAINTEXT: State.PLAINTEXT; readonly CDATA_SECTION: State.CDATA_SECTION;};
Functions
function parse
parse: < T extends TreeAdapterTypeMap< unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown > = DefaultTreeAdapterMap>( html: string, options?: ParserOptions<T>) => T['document'];
Parses an HTML string.
Parameter html
Input HTML string.
Parameter options
Parsing options.
Returns
Document
Example 1
const parse5 = require('parse5');const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');console.log(document.childNodes[1].tagName); //> 'html'
function parseFragment
parseFragment: { < T extends TreeAdapterTypeMap< unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown > = DefaultTreeAdapterMap >( fragmentContext: T['parentNode'] | null, html: string, options: ParserOptions<T> ): T['documentFragment']; < T extends TreeAdapterTypeMap< unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown > = DefaultTreeAdapterMap >( html: string, options?: ParserOptions<T> ): T['documentFragment'];};
Parses an HTML fragment.
Parameter fragmentContext
Parsing context element. If specified, given fragment will be parsed as if it was set to the context element's
innerHTML
property.Parameter html
Input HTML fragment string.
Parameter options
Parsing options.
Returns
DocumentFragment
Example 1
const parse5 = require('parse5');const documentFragment = parse5.parseFragment('<table></table>');console.log(documentFragment.childNodes[0].tagName); //> 'table'// Parses the html fragment in the context of the parsed <table> element.const trFragment = parse5.parseFragment(documentFragment.childNodes[0], '<tr><td>Shake it, baby</td></tr>');console.log(trFragment.childNodes[0].childNodes[0].tagName); //> 'td'
function serialize
serialize: < T extends TreeAdapterTypeMap< unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown > = DefaultTreeAdapterMap>( node: T['parentNode'], options?: SerializerOptions<T>) => string;
Serializes an AST node to an HTML string.
Parameter node
Node to serialize.
Parameter options
Serialization options.
Example 1
const parse5 = require('parse5');const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');// Serializes a document.const html = parse5.serialize(document);// Serializes the <html> element content.const str = parse5.serialize(document.childNodes[1]);console.log(str); //> '<head></head><body>Hi there!</body>'
function serializeOuter
serializeOuter: < T extends TreeAdapterTypeMap< unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown > = DefaultTreeAdapterMap>( node: T['node'], options?: SerializerOptions<T>) => string;
Serializes an AST element node to an HTML string, including the element node.
Parameter node
Node to serialize.
Parameter options
Serialization options.
Example 1
const parse5 = require('parse5');const document = parse5.parseFragment('<div>Hello, <b>world</b>!</div>');// Serializes the <div> element.const str = parse5.serializeOuter(document.childNodes[0]);console.log(str); //> '<div>Hello, <b>world</b>!</div>'
Classes
class Parser
class Parser<T extends TreeAdapterTypeMap> implements TokenHandler, StackHandler<T> {}
constructor
constructor( options?: ParserOptions<T>, document?: {}, fragmentContext?: {}, scriptHandler?: (pendingScript: T['element']) => void);
property currentNotInHTML
protected currentNotInHTML: boolean;
Indicates that the current node is not an element in the HTML namespace
property currentToken
protected currentToken: Token;
property document
document: {};
property options
options: Required<ParserOptions<T>>;
property stopped
stopped: boolean;
property tokenizer
tokenizer: Tokenizer;
property treeAdapter
treeAdapter: TreeAdapter<T>;
method getFragment
getFragment: () => T['documentFragment'];
method getFragmentParser
static getFragmentParser: < T extends TreeAdapterTypeMap< unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown >>( fragmentContext?: T['parentNode'] | null, options?: ParserOptions<T>) => Parser<T>;
method parse
static parse: < T extends TreeAdapterTypeMap< unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown >>( html: string, options?: ParserOptions<T>) => T['document'];
method shouldProcessStartTagTokenInForeignContent
protected shouldProcessStartTagTokenInForeignContent: ( token: TagToken) => boolean;
method switchToPlaintextParsing
switchToPlaintextParsing: () => void;
class Tokenizer
class Tokenizer {}
constructor
constructor(options: TokenizerOptions, handler: TokenHandler);
property active
active: boolean;
property consumedAfterSnapshot
protected consumedAfterSnapshot: number;
property currentAttr
protected currentAttr: Attribute;
property currentCharacterToken
protected currentCharacterToken: CharacterToken;
property currentLocation
protected currentLocation: Location;
property currentToken
protected currentToken: Token;
property entityDecoder
protected entityDecoder: EntityDecoder;
We use
entities
'EntityDecoder
to parse character references.All of the following states are handled by the
EntityDecoder
:- Named character reference state - Numeric character reference state - Hexademical character reference start state - Hexademical character reference state - Decimal character reference state - Numeric character reference end state
property entityStartPos
protected entityStartPos: number;
property handler
protected handler: TokenHandler;
property inForeignNode
inForeignNode: boolean;
Indicates that the current adjusted node exists, is not an element in the HTML namespace, and that it is not an integration point for either MathML or HTML.
See Also
property inLoop
protected inLoop: boolean;
Ensures that the parsing loop isn't run multiple times at once.
property lastStartTagName
lastStartTagName: string;
property options
protected options: TokenizerOptions;
property paused
protected paused: boolean;
property preprocessor
preprocessor: Preprocessor;
property returnState
protected returnState: State;
property state
state: State;
method emitCurrentComment
protected emitCurrentComment: (ct: CommentToken) => void;
method emitCurrentDoctype
protected emitCurrentDoctype: (ct: DoctypeToken) => void;
method emitCurrentTagToken
protected emitCurrentTagToken: () => void;
method getCurrentLocation
protected getCurrentLocation: (offset: number) => Location | null;
method handleSpecialEndTag
protected handleSpecialEndTag: (_cp: number) => boolean;
method insertHtmlAtCurrentPos
insertHtmlAtCurrentPos: (chunk: string) => void;
method pause
pause: () => void;
method prepareToken
protected prepareToken: (ct: Token) => void;
method resume
resume: (writeCallback?: () => void) => void;
method write
write: (chunk: string, isLastChunk: boolean, writeCallback?: () => void) => void;
Interfaces
interface ParserError
interface ParserError extends Location {}
property code
code: ERR;
interface ParserOptions
interface ParserOptions<T extends TreeAdapterTypeMap> {}
property onParseError
onParseError?: ParserErrorHandler | null;
Callback for parse errors.
null
property scriptingEnabled
scriptingEnabled?: boolean;
The [scripting flag](https://html.spec.whatwg.org/multipage/parsing.html#scripting-flag). If set to
true
,noscript
element content will be parsed as text.true
property sourceCodeLocationInfo
sourceCodeLocationInfo?: boolean;
Enables source code location information. When enabled, each node (except the root node) will have a
sourceCodeLocation
property. If the node is not an empty element,sourceCodeLocation
will be a ElementLocation object, otherwise it will be Location. If the element was implicitly created by the parser (as part of [tree correction](https://html.spec.whatwg.org/multipage/syntax.html#an-introduction-to-error-handling-and-strange-cases-in-the-parser)), itssourceCodeLocation
property will beundefined
.false
property treeAdapter
treeAdapter?: TreeAdapter<T>;
Specifies the resulting tree format.
treeAdapters.default
interface SerializerOptions
interface SerializerOptions<T extends TreeAdapterTypeMap> {}
property scriptingEnabled
scriptingEnabled?: boolean;
The [scripting flag](https://html.spec.whatwg.org/multipage/parsing.html#scripting-flag). If set to
true
,noscript
element content will not be escaped.true
property treeAdapter
treeAdapter?: TreeAdapter<T>;
Specifies input tree format.
treeAdapters.default
interface TokenHandler
interface TokenHandler {}
property onParseError
onParseError?: ParserErrorHandler | null;
method onCharacter
onCharacter: (token: CharacterToken) => void;
method onComment
onComment: (token: CommentToken) => void;
method onDoctype
onDoctype: (token: DoctypeToken) => void;
method onEndTag
onEndTag: (token: TagToken) => void;
method onEof
onEof: (token: EOFToken) => void;
method onNullCharacter
onNullCharacter: (token: CharacterToken) => void;
method onStartTag
onStartTag: (token: TagToken) => void;
method onWhitespaceCharacter
onWhitespaceCharacter: (token: CharacterToken) => void;
interface TokenizerOptions
interface TokenizerOptions {}
property sourceCodeLocationInfo
sourceCodeLocationInfo?: boolean;
interface TreeAdapter
interface TreeAdapter<T extends TreeAdapterTypeMap = TreeAdapterTypeMap> {}
Tree adapter is a set of utility functions that provides minimal required abstraction layer beetween parser and a specific AST format. Note that
TreeAdapter
is not designed to be a general purpose AST manipulation library. You can build such library on top of existingTreeAdapter
or use one of the existing libraries from npm.See Also
Have a look at the default tree adapter for reference.
property onItemPop
onItemPop?: (item: T['element'], newTop: T['parentNode']) => void;
Optional callback for elements being popped from the stack of open elements.
Parameter item
The element being popped.
property onItemPush
onItemPush?: (item: T['element']) => void;
Optional callback for elements being pushed to the stack of open elements.
Parameter element
The element being pushed to the stack of open elements.
method adoptAttributes
adoptAttributes: (recipient: T['element'], attrs: Attribute[]) => void;
Copies attributes to the given element. Only attributes that are not yet present in the element are copied.
Parameter recipient
Element to copy attributes into.
Parameter attrs
Attributes to copy.
method appendChild
appendChild: (parentNode: T['parentNode'], newNode: T['childNode']) => void;
Appends a child node to the given parent node.
Parameter parentNode
Parent node.
Parameter newNode
Child node.
method createCommentNode
createCommentNode: (data: string) => T['commentNode'];
Creates a comment node.
Parameter data
Comment text.
method createDocument
createDocument: () => T['document'];
Creates a document node.
method createDocumentFragment
createDocumentFragment: () => T['documentFragment'];
Creates a document fragment node.
method createElement
createElement: ( tagName: string, namespaceURI: NS, attrs: Attribute[]) => T['element'];
Creates an element node.
Parameter tagName
Tag name of the element.
Parameter namespaceURI
Namespace of the element.
Parameter attrs
Attribute name-value pair array. Foreign attributes may contain
namespace
andprefix
fields as well.
method createTextNode
createTextNode: (value: string) => T['textNode'];
Creates a text node.
Parameter value
Text.
method detachNode
detachNode: (node: T['childNode']) => void;
Removes a node from its parent.
Parameter node
Node to remove.
method getAttrList
getAttrList: (element: T['element']) => Attribute[];
Returns the given element's attributes in an array, in the form of name-value pairs. Foreign attributes may contain
namespace
andprefix
fields as well.Parameter element
Element.
method getChildNodes
getChildNodes: (node: T['parentNode']) => T['childNode'][];
Returns the given node's children in an array.
Parameter node
Node.
method getCommentNodeContent
getCommentNodeContent: (commentNode: T['commentNode']) => string;
Returns the given comment node's content.
Parameter commentNode
Comment node.
method getDocumentMode
getDocumentMode: (document: T['document']) => DOCUMENT_MODE;
Returns [document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks).
Parameter document
Document node.
method getDocumentTypeNodeName
getDocumentTypeNodeName: (doctypeNode: T['documentType']) => string;
Returns the given document type node's name.
Parameter doctypeNode
Document type node.
method getDocumentTypeNodePublicId
getDocumentTypeNodePublicId: (doctypeNode: T['documentType']) => string;
Returns the given document type node's public identifier.
Parameter doctypeNode
Document type node.
method getDocumentTypeNodeSystemId
getDocumentTypeNodeSystemId: (doctypeNode: T['documentType']) => string;
Returns the given document type node's system identifier.
Parameter doctypeNode
Document type node.
method getFirstChild
getFirstChild: (node: T['parentNode']) => T['childNode'] | null;
Returns the first child of the given node.
Parameter node
Node.
method getNamespaceURI
getNamespaceURI: (element: T['element']) => NS;
Returns the given element's namespace.
Parameter element
Element.
method getNodeSourceCodeLocation
getNodeSourceCodeLocation: ( node: T['node']) => ElementLocation | undefined | null;
Returns the given node's source code location information.
Parameter node
Node.
method getParentNode
getParentNode: (node: T['node']) => T['parentNode'] | null;
Returns the given node's parent.
Parameter node
Node.
method getTagName
getTagName: (element: T['element']) => string;
Returns the given element's tag name.
Parameter element
Element.
method getTemplateContent
getTemplateContent: (templateElement: T['template']) => T['documentFragment'];
Returns the
<template>
element content element.Parameter templateElement
<template>
element.
method getTextNodeContent
getTextNodeContent: (textNode: T['textNode']) => string;
Returns the given text node's content.
Parameter textNode
Text node.
method insertBefore
insertBefore: ( parentNode: T['parentNode'], newNode: T['childNode'], referenceNode: T['childNode']) => void;
Inserts a child node to the given parent node before the given reference node.
Parameter parentNode
Parent node.
Parameter newNode
Child node.
Parameter referenceNode
Reference node.
method insertText
insertText: (parentNode: T['parentNode'], text: string) => void;
Inserts text into a node. If the last child of the node is a text node, the provided text will be appended to the text node content. Otherwise, inserts a new text node with the given text.
Parameter parentNode
Node to insert text into.
Parameter text
Text to insert.
method insertTextBefore
insertTextBefore: ( parentNode: T['parentNode'], text: string, referenceNode: T['childNode']) => void;
Inserts text into a sibling node that goes before the reference node. If this sibling node is the text node, the provided text will be appended to the text node content. Otherwise, inserts a new sibling text node with the given text before the reference node.
Parameter parentNode
Node to insert text into.
Parameter text
Text to insert.
Parameter referenceNode
Node to insert text before.
method isCommentNode
isCommentNode: (node: T['node']) => node is T['commentNode'];
Determines if the given node is a comment node.
Parameter node
Node.
method isDocumentTypeNode
isDocumentTypeNode: (node: T['node']) => node is T['documentType'];
Determines if the given node is a document type node.
Parameter node
Node.
method isElementNode
isElementNode: (node: T['node']) => node is T['element'];
Determines if the given node is an element.
Parameter node
Node.
method isTextNode
isTextNode: (node: T['node']) => node is T['textNode'];
Determines if the given node is a text node.
Parameter node
Node.
method setDocumentMode
setDocumentMode: (document: T['document'], mode: DOCUMENT_MODE) => void;
Sets the [document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks).
Parameter document
Document node.
Parameter mode
Document mode.
method setDocumentType
setDocumentType: ( document: T['document'], name: string, publicId: string, systemId: string) => void;
Sets the document type. If the
document
already contains a document type node, thename
,publicId
andsystemId
properties of this node will be updated with the provided values. Otherwise, creates a new document type node with the given properties and inserts it into thedocument
.Parameter document
Document node.
Parameter name
Document type name.
Parameter publicId
Document type public identifier.
Parameter systemId
Document type system identifier.
method setNodeSourceCodeLocation
setNodeSourceCodeLocation: ( node: T['node'], location: ElementLocation | null) => void;
Attaches source code location information to the node.
Parameter node
Node.
method setTemplateContent
setTemplateContent: ( templateElement: T['template'], contentElement: T['documentFragment']) => void;
Sets the
<template>
element content element.Parameter templateElement
<template>
element.Parameter contentElement
Content element.
method updateNodeSourceCodeLocation
updateNodeSourceCodeLocation: ( node: T['node'], location: Partial<ElementLocation>) => void;
Updates the source code location information of the node.
Parameter node
Node.
interface TreeAdapterTypeMap
interface TreeAdapterTypeMap< Node = unknown, ParentNode = unknown, ChildNode = unknown, Document = unknown, DocumentFragment = unknown, Element = unknown, CommentNode = unknown, TextNode = unknown, Template = unknown, DocumentType = unknown> {}
property childNode
childNode: ChildNode;
property commentNode
commentNode: CommentNode;
property document
document: Document;
property documentFragment
documentFragment: DocumentFragment;
property documentType
documentType: DocumentType;
property element
element: Element;
property node
node: Node;
property parentNode
parentNode: ParentNode;
property template
template: Template;
property textNode
textNode: TextNode;
Enums
enum ErrorCodes
enum ErrorCodes { controlCharacterInInputStream = 'control-character-in-input-stream', noncharacterInInputStream = 'noncharacter-in-input-stream', surrogateInInputStream = 'surrogate-in-input-stream', nonVoidHtmlElementStartTagWithTrailingSolidus = 'non-void-html-element-start-tag-with-trailing-solidus', endTagWithAttributes = 'end-tag-with-attributes', endTagWithTrailingSolidus = 'end-tag-with-trailing-solidus', unexpectedSolidusInTag = 'unexpected-solidus-in-tag', unexpectedNullCharacter = 'unexpected-null-character', unexpectedQuestionMarkInsteadOfTagName = 'unexpected-question-mark-instead-of-tag-name', invalidFirstCharacterOfTagName = 'invalid-first-character-of-tag-name', unexpectedEqualsSignBeforeAttributeName = 'unexpected-equals-sign-before-attribute-name', missingEndTagName = 'missing-end-tag-name', unexpectedCharacterInAttributeName = 'unexpected-character-in-attribute-name', unknownNamedCharacterReference = 'unknown-named-character-reference', missingSemicolonAfterCharacterReference = 'missing-semicolon-after-character-reference', unexpectedCharacterAfterDoctypeSystemIdentifier = 'unexpected-character-after-doctype-system-identifier', unexpectedCharacterInUnquotedAttributeValue = 'unexpected-character-in-unquoted-attribute-value', eofBeforeTagName = 'eof-before-tag-name', eofInTag = 'eof-in-tag', missingAttributeValue = 'missing-attribute-value', missingWhitespaceBetweenAttributes = 'missing-whitespace-between-attributes', missingWhitespaceAfterDoctypePublicKeyword = 'missing-whitespace-after-doctype-public-keyword', missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers = 'missing-whitespace-between-doctype-public-and-system-identifiers', missingWhitespaceAfterDoctypeSystemKeyword = 'missing-whitespace-after-doctype-system-keyword', missingQuoteBeforeDoctypePublicIdentifier = 'missing-quote-before-doctype-public-identifier', missingQuoteBeforeDoctypeSystemIdentifier = 'missing-quote-before-doctype-system-identifier', missingDoctypePublicIdentifier = 'missing-doctype-public-identifier', missingDoctypeSystemIdentifier = 'missing-doctype-system-identifier', abruptDoctypePublicIdentifier = 'abrupt-doctype-public-identifier', abruptDoctypeSystemIdentifier = 'abrupt-doctype-system-identifier', cdataInHtmlContent = 'cdata-in-html-content', incorrectlyOpenedComment = 'incorrectly-opened-comment', eofInScriptHtmlCommentLikeText = 'eof-in-script-html-comment-like-text', eofInDoctype = 'eof-in-doctype', nestedComment = 'nested-comment', abruptClosingOfEmptyComment = 'abrupt-closing-of-empty-comment', eofInComment = 'eof-in-comment', incorrectlyClosedComment = 'incorrectly-closed-comment', eofInCdata = 'eof-in-cdata', absenceOfDigitsInNumericCharacterReference = 'absence-of-digits-in-numeric-character-reference', nullCharacterReference = 'null-character-reference', surrogateCharacterReference = 'surrogate-character-reference', characterReferenceOutsideUnicodeRange = 'character-reference-outside-unicode-range', controlCharacterReference = 'control-character-reference', noncharacterCharacterReference = 'noncharacter-character-reference', missingWhitespaceBeforeDoctypeName = 'missing-whitespace-before-doctype-name', missingDoctypeName = 'missing-doctype-name', invalidCharacterSequenceAfterDoctypeName = 'invalid-character-sequence-after-doctype-name', duplicateAttribute = 'duplicate-attribute', nonConformingDoctype = 'non-conforming-doctype', missingDoctype = 'missing-doctype', misplacedDoctype = 'misplaced-doctype', endTagWithoutMatchingOpenElement = 'end-tag-without-matching-open-element', closingOfElementWithOpenChildElements = 'closing-of-element-with-open-child-elements', disallowedContentInNoscriptInHead = 'disallowed-content-in-noscript-in-head', openElementsLeftAfterEof = 'open-elements-left-after-eof', abandonedHeadElementChild = 'abandoned-head-element-child', misplacedStartTagForHeadElement = 'misplaced-start-tag-for-head-element', nestedNoscriptInHead = 'nested-noscript-in-head', eofInElementThatCanContainOnlyText = 'eof-in-element-that-can-contain-only-text',}
member abandonedHeadElementChild
abandonedHeadElementChild = 'abandoned-head-element-child'
member abruptClosingOfEmptyComment
abruptClosingOfEmptyComment = 'abrupt-closing-of-empty-comment'
member abruptDoctypePublicIdentifier
abruptDoctypePublicIdentifier = 'abrupt-doctype-public-identifier'
member abruptDoctypeSystemIdentifier
abruptDoctypeSystemIdentifier = 'abrupt-doctype-system-identifier'
member absenceOfDigitsInNumericCharacterReference
absenceOfDigitsInNumericCharacterReference = 'absence-of-digits-in-numeric-character-reference'
member cdataInHtmlContent
cdataInHtmlContent = 'cdata-in-html-content'
member characterReferenceOutsideUnicodeRange
characterReferenceOutsideUnicodeRange = 'character-reference-outside-unicode-range'
member closingOfElementWithOpenChildElements
closingOfElementWithOpenChildElements = 'closing-of-element-with-open-child-elements'
member controlCharacterInInputStream
controlCharacterInInputStream = 'control-character-in-input-stream'
member controlCharacterReference
controlCharacterReference = 'control-character-reference'
member disallowedContentInNoscriptInHead
disallowedContentInNoscriptInHead = 'disallowed-content-in-noscript-in-head'
member duplicateAttribute
duplicateAttribute = 'duplicate-attribute'
member endTagWithAttributes
endTagWithAttributes = 'end-tag-with-attributes'
member endTagWithoutMatchingOpenElement
endTagWithoutMatchingOpenElement = 'end-tag-without-matching-open-element'
member endTagWithTrailingSolidus
endTagWithTrailingSolidus = 'end-tag-with-trailing-solidus'
member eofBeforeTagName
eofBeforeTagName = 'eof-before-tag-name'
member eofInCdata
eofInCdata = 'eof-in-cdata'
member eofInComment
eofInComment = 'eof-in-comment'
member eofInDoctype
eofInDoctype = 'eof-in-doctype'
member eofInElementThatCanContainOnlyText
eofInElementThatCanContainOnlyText = 'eof-in-element-that-can-contain-only-text'
member eofInScriptHtmlCommentLikeText
eofInScriptHtmlCommentLikeText = 'eof-in-script-html-comment-like-text'
member eofInTag
eofInTag = 'eof-in-tag'
member incorrectlyClosedComment
incorrectlyClosedComment = 'incorrectly-closed-comment'
member incorrectlyOpenedComment
incorrectlyOpenedComment = 'incorrectly-opened-comment'
member invalidCharacterSequenceAfterDoctypeName
invalidCharacterSequenceAfterDoctypeName = 'invalid-character-sequence-after-doctype-name'
member invalidFirstCharacterOfTagName
invalidFirstCharacterOfTagName = 'invalid-first-character-of-tag-name'
member misplacedDoctype
misplacedDoctype = 'misplaced-doctype'
member misplacedStartTagForHeadElement
misplacedStartTagForHeadElement = 'misplaced-start-tag-for-head-element'
member missingAttributeValue
missingAttributeValue = 'missing-attribute-value'
member missingDoctype
missingDoctype = 'missing-doctype'
member missingDoctypeName
missingDoctypeName = 'missing-doctype-name'
member missingDoctypePublicIdentifier
missingDoctypePublicIdentifier = 'missing-doctype-public-identifier'
member missingDoctypeSystemIdentifier
missingDoctypeSystemIdentifier = 'missing-doctype-system-identifier'
member missingEndTagName
missingEndTagName = 'missing-end-tag-name'
member missingQuoteBeforeDoctypePublicIdentifier
missingQuoteBeforeDoctypePublicIdentifier = 'missing-quote-before-doctype-public-identifier'
member missingQuoteBeforeDoctypeSystemIdentifier
missingQuoteBeforeDoctypeSystemIdentifier = 'missing-quote-before-doctype-system-identifier'
member missingSemicolonAfterCharacterReference
missingSemicolonAfterCharacterReference = 'missing-semicolon-after-character-reference'
member missingWhitespaceAfterDoctypePublicKeyword
missingWhitespaceAfterDoctypePublicKeyword = 'missing-whitespace-after-doctype-public-keyword'
member missingWhitespaceAfterDoctypeSystemKeyword
missingWhitespaceAfterDoctypeSystemKeyword = 'missing-whitespace-after-doctype-system-keyword'
member missingWhitespaceBeforeDoctypeName
missingWhitespaceBeforeDoctypeName = 'missing-whitespace-before-doctype-name'
member missingWhitespaceBetweenAttributes
missingWhitespaceBetweenAttributes = 'missing-whitespace-between-attributes'
member missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers
missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers = 'missing-whitespace-between-doctype-public-and-system-identifiers'
member nestedComment
nestedComment = 'nested-comment'
member nestedNoscriptInHead
nestedNoscriptInHead = 'nested-noscript-in-head'
member noncharacterCharacterReference
noncharacterCharacterReference = 'noncharacter-character-reference'
member noncharacterInInputStream
noncharacterInInputStream = 'noncharacter-in-input-stream'
member nonConformingDoctype
nonConformingDoctype = 'non-conforming-doctype'
member nonVoidHtmlElementStartTagWithTrailingSolidus
nonVoidHtmlElementStartTagWithTrailingSolidus = 'non-void-html-element-start-tag-with-trailing-solidus'
member nullCharacterReference
nullCharacterReference = 'null-character-reference'
member openElementsLeftAfterEof
openElementsLeftAfterEof = 'open-elements-left-after-eof'
member surrogateCharacterReference
surrogateCharacterReference = 'surrogate-character-reference'
member surrogateInInputStream
surrogateInInputStream = 'surrogate-in-input-stream'
member unexpectedCharacterAfterDoctypeSystemIdentifier
unexpectedCharacterAfterDoctypeSystemIdentifier = 'unexpected-character-after-doctype-system-identifier'
member unexpectedCharacterInAttributeName
unexpectedCharacterInAttributeName = 'unexpected-character-in-attribute-name'
member unexpectedCharacterInUnquotedAttributeValue
unexpectedCharacterInUnquotedAttributeValue = 'unexpected-character-in-unquoted-attribute-value'
member unexpectedEqualsSignBeforeAttributeName
unexpectedEqualsSignBeforeAttributeName = 'unexpected-equals-sign-before-attribute-name'
member unexpectedNullCharacter
unexpectedNullCharacter = 'unexpected-null-character'
member unexpectedQuestionMarkInsteadOfTagName
unexpectedQuestionMarkInsteadOfTagName = 'unexpected-question-mark-instead-of-tag-name'
member unexpectedSolidusInTag
unexpectedSolidusInTag = 'unexpected-solidus-in-tag'
member unknownNamedCharacterReference
unknownNamedCharacterReference = 'unknown-named-character-reference'
Type Aliases
type DefaultTreeAdapterMap
type DefaultTreeAdapterMap = TreeAdapterTypeMap< Node, ParentNode, ChildNode, Document, DocumentFragment, Element, CommentNode, TextNode, Template, DocumentType>;
type ParserErrorHandler
type ParserErrorHandler = (error: ParserError) => void;
Namespaces
namespace DefaultTreeAdapterTypes
namespace DefaultTreeAdapterTypes {}
type ChildNode
type ChildNode = DefaultTreeAdapter.ChildNode;
type CommentNode
type CommentNode = DefaultTreeAdapter.CommentNode;
type DefaultTreeAdapterMap
type DefaultTreeAdapterMap = DefaultTreeAdapter.DefaultTreeAdapterMap;
type Document
type Document = DefaultTreeAdapter.Document;
type DocumentFragment
type DocumentFragment = DefaultTreeAdapter.DocumentFragment;
type DocumentType
type DocumentType = DefaultTreeAdapter.DocumentType;
type Element
type Element = DefaultTreeAdapter.Element;
type Node
type Node = DefaultTreeAdapter.Node;
type ParentNode
type ParentNode = DefaultTreeAdapter.ParentNode;
type Template
type Template = DefaultTreeAdapter.Template;
type TextNode
type TextNode = DefaultTreeAdapter.TextNode;
namespace foreignContent
module 'dist/common/foreign-content.d.ts' {}
variable SVG_TAG_NAMES_ADJUSTMENT_MAP
const SVG_TAG_NAMES_ADJUSTMENT_MAP: Map<string, string>;
function adjustTokenMathMLAttrs
adjustTokenMathMLAttrs: (token: TagToken) => void;
function adjustTokenSVGAttrs
adjustTokenSVGAttrs: (token: TagToken) => void;
function adjustTokenSVGTagName
adjustTokenSVGTagName: (token: TagToken) => void;
function adjustTokenXMLAttrs
adjustTokenXMLAttrs: (token: TagToken) => void;
function causesExit
causesExit: (startTagToken: TagToken) => boolean;
function isIntegrationPoint
isIntegrationPoint: ( tn: $, ns: NS, attrs: Attribute[], foreignNS?: NS) => boolean;
namespace html
module 'dist/common/html.d.ts' {}
All valid namespaces in HTML.
variable NUMBERED_HEADERS
const NUMBERED_HEADERS: Set<TAG_ID>;
variable SPECIAL_ELEMENTS
const SPECIAL_ELEMENTS: Record<NS, Set<TAG_ID>>;
function getTagID
getTagID: (tagName: string) => TAG_ID;
function hasUnescapedText
hasUnescapedText: (tn: string, scriptingEnabled: boolean) => boolean;
enum ATTRS
enum ATTRS { TYPE = 'type', ACTION = 'action', ENCODING = 'encoding', PROMPT = 'prompt', NAME = 'name', COLOR = 'color', FACE = 'face', SIZE = 'size',}
enum DOCUMENT_MODE
enum DOCUMENT_MODE { NO_QUIRKS = 'no-quirks', QUIRKS = 'quirks', LIMITED_QUIRKS = 'limited-quirks',}
The mode of the document.
See Also
member LIMITED_QUIRKS
LIMITED_QUIRKS = 'limited-quirks'
member NO_QUIRKS
NO_QUIRKS = 'no-quirks'
member QUIRKS
QUIRKS = 'quirks'
enum NS
enum NS { HTML = 'http://www.w3.org/1999/xhtml', MATHML = 'http://www.w3.org/1998/Math/MathML', SVG = 'http://www.w3.org/2000/svg', XLINK = 'http://www.w3.org/1999/xlink', XML = 'http://www.w3.org/XML/1998/namespace', XMLNS = 'http://www.w3.org/2000/xmlns/',}
All valid namespaces in HTML.
member HTML
HTML = 'http://www.w3.org/1999/xhtml'
member MATHML
MATHML = 'http://www.w3.org/1998/Math/MathML'
member SVG
SVG = 'http://www.w3.org/2000/svg'
member XLINK
XLINK = 'http://www.w3.org/1999/xlink'
member XML
XML = 'http://www.w3.org/XML/1998/namespace'
member XMLNS
XMLNS = 'http://www.w3.org/2000/xmlns/'
enum TAG_ID
enum TAG_ID { UNKNOWN = 0, A = 1, ADDRESS = 2, ANNOTATION_XML = 3, APPLET = 4, AREA = 5, ARTICLE = 6, ASIDE = 7, B = 8, BASE = 9, BASEFONT = 10, BGSOUND = 11, BIG = 12, BLOCKQUOTE = 13, BODY = 14, BR = 15, BUTTON = 16, CAPTION = 17, CENTER = 18, CODE = 19, COL = 20, COLGROUP = 21, DD = 22, DESC = 23, DETAILS = 24, DIALOG = 25, DIR = 26, DIV = 27, DL = 28, DT = 29, EM = 30, EMBED = 31, FIELDSET = 32, FIGCAPTION = 33, FIGURE = 34, FONT = 35, FOOTER = 36, FOREIGN_OBJECT = 37, FORM = 38, FRAME = 39, FRAMESET = 40, H1 = 41, H2 = 42, H3 = 43, H4 = 44, H5 = 45, H6 = 46, HEAD = 47, HEADER = 48, HGROUP = 49, HR = 50, HTML = 51, I = 52, IMG = 53, IMAGE = 54, INPUT = 55, IFRAME = 56, KEYGEN = 57, LABEL = 58, LI = 59, LINK = 60, LISTING = 61, MAIN = 62, MALIGNMARK = 63, MARQUEE = 64, MATH = 65, MENU = 66, META = 67, MGLYPH = 68, MI = 69, MO = 70, MN = 71, MS = 72, MTEXT = 73, NAV = 74, NOBR = 75, NOFRAMES = 76, NOEMBED = 77, NOSCRIPT = 78, OBJECT = 79, OL = 80, OPTGROUP = 81, OPTION = 82, P = 83, PARAM = 84, PLAINTEXT = 85, PRE = 86, RB = 87, RP = 88, RT = 89, RTC = 90, RUBY = 91, S = 92, SCRIPT = 93, SEARCH = 94, SECTION = 95, SELECT = 96, SOURCE = 97, SMALL = 98, SPAN = 99, STRIKE = 100, STRONG = 101, STYLE = 102, SUB = 103, SUMMARY = 104, SUP = 105, TABLE = 106, TBODY = 107, TEMPLATE = 108, TEXTAREA = 109, TFOOT = 110, TD = 111, TH = 112, THEAD = 113, TITLE = 114, TR = 115, TRACK = 116, TT = 117, U = 118, UL = 119, SVG = 120, VAR = 121, WBR = 122, XMP = 123,}
Tag IDs are numeric IDs for known tag names.
We use tag IDs to improve the performance of tag name comparisons.
member A
A = 1
member ADDRESS
ADDRESS = 2
member ANNOTATION_XML
ANNOTATION_XML = 3
member APPLET
APPLET = 4
member AREA
AREA = 5
member ARTICLE
ARTICLE = 6
member ASIDE
ASIDE = 7
member B
B = 8
member BASE
BASE = 9
member BASEFONT
BASEFONT = 10
member BGSOUND
BGSOUND = 11
member BIG
BIG = 12
member BLOCKQUOTE
BLOCKQUOTE = 13
member BODY
BODY = 14
member BR
BR = 15
member BUTTON
BUTTON = 16
member CAPTION
CAPTION = 17
member CENTER
CENTER = 18
member CODE
CODE = 19
member COL
COL = 20
member COLGROUP
COLGROUP = 21
member DD
DD = 22
member DESC
DESC = 23
member DETAILS
DETAILS = 24
member DIALOG
DIALOG = 25
member DIR
DIR = 26
member DIV
DIV = 27
member DL
DL = 28
member DT
DT = 29
member EM
EM = 30
member EMBED
EMBED = 31
member FIELDSET
FIELDSET = 32
member FIGCAPTION
FIGCAPTION = 33
member FIGURE
FIGURE = 34
member FONT
FONT = 35
member FOOTER
FOOTER = 36
member FOREIGN_OBJECT
FOREIGN_OBJECT = 37
member FORM
FORM = 38
member FRAME
FRAME = 39
member FRAMESET
FRAMESET = 40
member H1
H1 = 41
member H2
H2 = 42
member H3
H3 = 43
member H4
H4 = 44
member H5
H5 = 45
member H6
H6 = 46
member HEAD
HEAD = 47
member HEADER
HEADER = 48
member HGROUP
HGROUP = 49
member HR
HR = 50
member HTML
HTML = 51
member I
I = 52
member IFRAME
IFRAME = 56
member IMAGE
IMAGE = 54
member IMG
IMG = 53
member INPUT
INPUT = 55
member KEYGEN
KEYGEN = 57
member LABEL
LABEL = 58
member LI
LI = 59
member LINK
LINK = 60
member LISTING
LISTING = 61
member MAIN
MAIN = 62
member MALIGNMARK
MALIGNMARK = 63
member MARQUEE
MARQUEE = 64
member MATH
MATH = 65
member MENU
MENU = 66
member META
META = 67
member MGLYPH
MGLYPH = 68
member MI
MI = 69
member MN
MN = 71
member MO
MO = 70
member MS
MS = 72
member MTEXT
MTEXT = 73
member NAV
NAV = 74
member NOBR
NOBR = 75
member NOEMBED
NOEMBED = 77
member NOFRAMES
NOFRAMES = 76
member NOSCRIPT
NOSCRIPT = 78
member OBJECT
OBJECT = 79
member OL
OL = 80
member OPTGROUP
OPTGROUP = 81
member OPTION
OPTION = 82
member P
P = 83
member PARAM
PARAM = 84
member PLAINTEXT
PLAINTEXT = 85
member PRE
PRE = 86
member RB
RB = 87
member RP
RP = 88
member RT
RT = 89
member RTC
RTC = 90
member RUBY
RUBY = 91
member S
S = 92
member SCRIPT
SCRIPT = 93
member SEARCH
SEARCH = 94
member SECTION
SECTION = 95
member SELECT
SELECT = 96
member SMALL
SMALL = 98
member SOURCE
SOURCE = 97
member SPAN
SPAN = 99
member STRIKE
STRIKE = 100
member STRONG
STRONG = 101
member STYLE
STYLE = 102
member SUB
SUB = 103
member SUMMARY
SUMMARY = 104
member SUP
SUP = 105
member SVG
SVG = 120
member TABLE
TABLE = 106
member TBODY
TBODY = 107
member TD
TD = 111
member TEMPLATE
TEMPLATE = 108
member TEXTAREA
TEXTAREA = 109
member TFOOT
TFOOT = 110
member TH
TH = 112
member THEAD
THEAD = 113
member TITLE
TITLE = 114
member TR
TR = 115
member TRACK
TRACK = 116
member TT
TT = 117
member U
U = 118
member UL
UL = 119
member UNKNOWN
UNKNOWN = 0
member VAR
VAR = 121
member WBR
WBR = 122
member XMP
XMP = 123
enum TAG_NAMES
enum TAG_NAMES { A = 'a', ADDRESS = 'address', ANNOTATION_XML = 'annotation-xml', APPLET = 'applet', AREA = 'area', ARTICLE = 'article', ASIDE = 'aside', B = 'b', BASE = 'base', BASEFONT = 'basefont', BGSOUND = 'bgsound', BIG = 'big', BLOCKQUOTE = 'blockquote', BODY = 'body', BR = 'br', BUTTON = 'button', CAPTION = 'caption', CENTER = 'center', CODE = 'code', COL = 'col', COLGROUP = 'colgroup', DD = 'dd', DESC = 'desc', DETAILS = 'details', DIALOG = 'dialog', DIR = 'dir', DIV = 'div', DL = 'dl', DT = 'dt', EM = 'em', EMBED = 'embed', FIELDSET = 'fieldset', FIGCAPTION = 'figcaption', FIGURE = 'figure', FONT = 'font', FOOTER = 'footer', FOREIGN_OBJECT = 'foreignObject', FORM = 'form', FRAME = 'frame', FRAMESET = 'frameset', H1 = 'h1', H2 = 'h2', H3 = 'h3', H4 = 'h4', H5 = 'h5', H6 = 'h6', HEAD = 'head', HEADER = 'header', HGROUP = 'hgroup', HR = 'hr', HTML = 'html', I = 'i', IMG = 'img', IMAGE = 'image', INPUT = 'input', IFRAME = 'iframe', KEYGEN = 'keygen', LABEL = 'label', LI = 'li', LINK = 'link', LISTING = 'listing', MAIN = 'main', MALIGNMARK = 'malignmark', MARQUEE = 'marquee', MATH = 'math', MENU = 'menu', META = 'meta', MGLYPH = 'mglyph', MI = 'mi', MO = 'mo', MN = 'mn', MS = 'ms', MTEXT = 'mtext', NAV = 'nav', NOBR = 'nobr', NOFRAMES = 'noframes', NOEMBED = 'noembed', NOSCRIPT = 'noscript', OBJECT = 'object', OL = 'ol', OPTGROUP = 'optgroup', OPTION = 'option', P = 'p', PARAM = 'param', PLAINTEXT = 'plaintext', PRE = 'pre', RB = 'rb', RP = 'rp', RT = 'rt', RTC = 'rtc', RUBY = 'ruby', S = 's', SCRIPT = 'script', SEARCH = 'search', SECTION = 'section', SELECT = 'select', SOURCE = 'source', SMALL = 'small', SPAN = 'span', STRIKE = 'strike', STRONG = 'strong', STYLE = 'style', SUB = 'sub', SUMMARY = 'summary', SUP = 'sup', TABLE = 'table', TBODY = 'tbody', TEMPLATE = 'template', TEXTAREA = 'textarea', TFOOT = 'tfoot', TD = 'td', TH = 'th', THEAD = 'thead', TITLE = 'title', TR = 'tr', TRACK = 'track', TT = 'tt', U = 'u', UL = 'ul', SVG = 'svg', VAR = 'var', WBR = 'wbr', XMP = 'xmp',}
member A
A = 'a'
member ADDRESS
ADDRESS = 'address'
member ANNOTATION_XML
ANNOTATION_XML = 'annotation-xml'
member APPLET
APPLET = 'applet'
member AREA
AREA = 'area'
member ARTICLE
ARTICLE = 'article'
member ASIDE
ASIDE = 'aside'
member B
B = 'b'
member BASE
BASE = 'base'
member BASEFONT
BASEFONT = 'basefont'
member BGSOUND
BGSOUND = 'bgsound'
member BIG
BIG = 'big'
member BLOCKQUOTE
BLOCKQUOTE = 'blockquote'
member BODY
BODY = 'body'
member BR
BR = 'br'
member BUTTON
BUTTON = 'button'
member CAPTION
CAPTION = 'caption'
member CENTER
CENTER = 'center'
member CODE
CODE = 'code'
member COL
COL = 'col'
member COLGROUP
COLGROUP = 'colgroup'
member DD
DD = 'dd'
member DESC
DESC = 'desc'
member DETAILS
DETAILS = 'details'
member DIALOG
DIALOG = 'dialog'
member DIR
DIR = 'dir'
member DIV
DIV = 'div'
member DL
DL = 'dl'
member DT
DT = 'dt'
member EM
EM = 'em'
member EMBED
EMBED = 'embed'
member FIELDSET
FIELDSET = 'fieldset'
member FIGCAPTION
FIGCAPTION = 'figcaption'
member FIGURE
FIGURE = 'figure'
member FONT
FONT = 'font'
member FOOTER
FOOTER = 'footer'
member FOREIGN_OBJECT
FOREIGN_OBJECT = 'foreignObject'
member FORM
FORM = 'form'
member FRAME
FRAME = 'frame'
member FRAMESET
FRAMESET = 'frameset'
member H1
H1 = 'h1'
member H2
H2 = 'h2'
member H3
H3 = 'h3'
member H4
H4 = 'h4'
member H5
H5 = 'h5'
member H6
H6 = 'h6'
member HEAD
HEAD = 'head'
member HEADER
HEADER = 'header'
member HGROUP
HGROUP = 'hgroup'
member HR
HR = 'hr'
member HTML
HTML = 'html'
member I
I = 'i'
member IFRAME
IFRAME = 'iframe'
member IMAGE
IMAGE = 'image'
member IMG
IMG = 'img'
member INPUT
INPUT = 'input'
member KEYGEN
KEYGEN = 'keygen'
member LABEL
LABEL = 'label'
member LI
LI = 'li'
member LINK
LINK = 'link'
member LISTING
LISTING = 'listing'
member MAIN
MAIN = 'main'
member MALIGNMARK
MALIGNMARK = 'malignmark'
member MARQUEE
MARQUEE = 'marquee'
member MATH
MATH = 'math'
member MENU
MENU = 'menu'
member META
META = 'meta'
member MGLYPH
MGLYPH = 'mglyph'
member MI
MI = 'mi'
member MN
MN = 'mn'
member MO
MO = 'mo'
member MS
MS = 'ms'
member MTEXT
MTEXT = 'mtext'
member NAV
NAV = 'nav'
member NOBR
NOBR = 'nobr'
member NOEMBED
NOEMBED = 'noembed'
member NOFRAMES
NOFRAMES = 'noframes'
member NOSCRIPT
NOSCRIPT = 'noscript'
member OBJECT
OBJECT = 'object'
member OL
OL = 'ol'
member OPTGROUP
OPTGROUP = 'optgroup'
member OPTION
OPTION = 'option'
member P
P = 'p'
member PARAM
PARAM = 'param'
member PLAINTEXT
PLAINTEXT = 'plaintext'
member PRE
PRE = 'pre'
member RB
RB = 'rb'
member RP
RP = 'rp'
member RT
RT = 'rt'
member RTC
RTC = 'rtc'
member RUBY
RUBY = 'ruby'
member S
S = 's'
member SCRIPT
SCRIPT = 'script'
member SEARCH
SEARCH = 'search'
member SECTION
SECTION = 'section'
member SELECT
SELECT = 'select'
member SMALL
SMALL = 'small'
member SOURCE
SOURCE = 'source'
member SPAN
SPAN = 'span'
member STRIKE
STRIKE = 'strike'
member STRONG
STRONG = 'strong'
member STYLE
STYLE = 'style'
member SUB
SUB = 'sub'
member SUMMARY
SUMMARY = 'summary'
member SUP
SUP = 'sup'
member SVG
SVG = 'svg'
member TABLE
TABLE = 'table'
member TBODY
TBODY = 'tbody'
member TD
TD = 'td'
member TEMPLATE
TEMPLATE = 'template'
member TEXTAREA
TEXTAREA = 'textarea'
member TFOOT
TFOOT = 'tfoot'
member TH
TH = 'th'
member THEAD
THEAD = 'thead'
member TITLE
TITLE = 'title'
member TR
TR = 'tr'
member TRACK
TRACK = 'track'
member TT
TT = 'tt'
member U
U = 'u'
member UL
UL = 'ul'
member VAR
VAR = 'var'
member WBR
WBR = 'wbr'
member XMP
XMP = 'xmp'
namespace Token
module 'dist/common/token.d.ts' {}
One-based line index of the first character.
function getTokenAttr
getTokenAttr: (token: TagToken, attrName: string) => string | null;
interface Attribute
interface Attribute {}
interface CharacterToken
interface CharacterToken extends TokenBase {}
interface CommentToken
interface CommentToken extends TokenBase {}
interface DoctypeToken
interface DoctypeToken extends TokenBase {}
property forceQuirks
forceQuirks: boolean;
property name
name: string | null;
property publicId
publicId: string | null;
property systemId
systemId: string | null;
property type
readonly type: TokenType.DOCTYPE;
interface ElementLocation
interface ElementLocation extends LocationWithAttributes {}
interface Location
interface Location {}
property endCol
endCol: number;
One-based column index of the last character. Points directly *after* the last character.
property endLine
endLine: number;
One-based line index of the last character.
property endOffset
endOffset: number;
Zero-based last character index. Points directly *after* the last character.
property startCol
startCol: number;
One-based column index of the first character.
property startLine
startLine: number;
One-based line index of the first character.
property startOffset
startOffset: number;
Zero-based first character index.
interface LocationWithAttributes
interface LocationWithAttributes extends Location {}
property attrs
attrs?: Record<string, Location>;
Start tag attributes' location info.
interface TagToken
interface TagToken extends TokenBase {}
property ackSelfClosing
ackSelfClosing: boolean;
property attrs
attrs: Attribute[];
property location
location: LocationWithAttributes | null;
property selfClosing
selfClosing: boolean;
property tagID
tagID: TAG_ID;
Used to cache the ID of the tag name.
property tagName
tagName: string;
property type
readonly type: TokenType.START_TAG | TokenType.END_TAG;
enum TokenType
enum TokenType { CHARACTER = 0, NULL_CHARACTER = 1, WHITESPACE_CHARACTER = 2, START_TAG = 3, END_TAG = 4, COMMENT = 5, DOCTYPE = 6, EOF = 7, HIBERNATION = 8,}
member CHARACTER
CHARACTER = 0
member COMMENT
COMMENT = 5
member DOCTYPE
DOCTYPE = 6
member END_TAG
END_TAG = 4
member EOF
EOF = 7
member HIBERNATION
HIBERNATION = 8
member NULL_CHARACTER
NULL_CHARACTER = 1
member START_TAG
START_TAG = 3
member WHITESPACE_CHARACTER
WHITESPACE_CHARACTER = 2
type Token
type Token = DoctypeToken | TagToken | CommentToken | EOFToken | CharacterToken;
Package Files (10)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/parse5
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/parse5)
- HTML<a href="https://www.jsdocs.io/package/parse5"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 6559 ms. - Missing or incorrect documentation? Open an issue for this package.