diff --git a/classes/parse5.Parser.html b/classes/parse5.Parser.html index dfcf4eb31..68686f064 100644 --- a/classes/parse5.Parser.html +++ b/classes/parse5.Parser.html @@ -1,4 +1,4 @@ -
Optional
options: ParserOptions<T>Optional
document: T["document"]Protected
currentProtected
currentProtected
_adoptProtected
_appendProtected
Protected
_appendProtected
_attachProtected
Protected
_closePElementProtected
_closeProtected
_endProtected
Protected
_findProtected
_findProtected
_fosterProtected
_getProtected
_initProtected
_insertProtected
Protected
_insertProtected
_insertProtected
Protected
_insertProtected
_insertProtected
Protected
_isProtected
Protected
_isProtected
_isProtected
Protected
_processOptional
options: ParserOptions<T>Optional
document: T["document"]Protected
currentIndicates that the current node is not an element in the HTML namespace
+Protected
currentProtected
_adoptProtected
_appendProtected
Protected
_appendProtected
_attachProtected
Protected
_closePElementProtected
_closeProtected
_endProtected
Protected
_findProtected
_findProtected
_fosterProtected
_getProtected
_initProtected
_insertProtected
Protected
_insertProtected
_insertProtected
Protected
_insertProtected
_insertProtected
Protected
_isProtected
Protected
_isProtected
_isProtected
Protected
_processProtected
Processes a given start tag.
onStartTag
checks if a self-closing tag was recognized. When a token
is moved inbetween multiple insertion modes, this check for self-closing
could lead to false positives. To avoid this, _processStartTag
is used
for nested calls.
The token to process.
-Protected
_processProtected
Protected
_reconstructProtected
_resetProtected
_resetProtected
_setProtected
_setProtected
Protected
_setProtected
Protected
_shouldProtected
_startProtected
Protected
_switchProtected
Protected
shouldStatic
getOptional
fragmentContext: null | T["parentNode"]Optional
options: ParserOptions<T>Static
parseOptional
options: ParserOptions<T>Generated using TypeDoc
Protected
_processProtected
Protected
_reconstructProtected
_resetProtected
_resetProtected
_setProtected
_setProtected
Protected
_setProtected
Protected
_shouldProtected
_startProtected
Protected
_switchProtected
Protected
shouldStatic
getOptional
fragmentContext: null | T["parentNode"]Optional
options: ParserOptions<T>Static
parseOptional
options: ParserOptions<T>Generated using TypeDoc
Protected
consumedProtected
currentProtected
currentProtected
currentProtected
currentProtected
entityWe use entities
' EntityDecoder
to parse character references.
Protected
consumedProtected
currentProtected
currentProtected
currentProtected
currentProtected
entityWe use entities
' EntityDecoder
to parse character references.
All of the following states are handled by the EntityDecoder
:
Protected
entityProtected
handlerIndicates that the current adjusted node exists, is not an element in the HTML namespace, +
Protected
entityProtected
handlerIndicates 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.
Protected
inEnsures that the parsing loop isn't run multiple times at once.
-Protected
optionsProtected
pausedProtected
returnProtected
_advanceProtected
_appendProtected
_callProtected
_consumeProtected
_consumeProtected
_createProtected
_createProtected
_createProtected
_createProtected
_createProtected
_createProtected
_emitProtected
_emitProtected
_emitProtected
_emitEOFTokenProtected
_ensureProtected
_errProtected
_flushProtected
_isProtected
_leaveProtected
_leaveProtected
_runProtected
_startProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
emitProtected
emitProtected
emitProtected
getProtected
handleProtected
prepareGenerated using TypeDoc
Protected
inEnsures that the parsing loop isn't run multiple times at once.
+Protected
optionsProtected
pausedProtected
returnProtected
_advanceProtected
_appendProtected
_callProtected
_consumeProtected
_consumeProtected
_createProtected
_createProtected
_createProtected
_createProtected
_createProtected
_createProtected
_emitProtected
_emitProtected
_emitProtected
_emitEOFTokenProtected
_ensureProtected
_errProtected
_flushProtected
_isProtected
_leaveProtected
_leaveProtected
_runProtected
_startProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
_stateProtected
emitProtected
emitProtected
emitProtected
getProtected
handleProtected
prepareGenerated using TypeDoc
const RewritingStream = require('parse5-html-rewriting-stream');
const http = require('http');
const fs = require('fs');
const file = fs.createWriteStream('/home/google.com.html');
const rewriter = new RewritingStream();
// Replace divs with spans
rewriter.on('startTag', startTag => {
if (startTag.tagName === 'span') {
startTag.tagName = 'div';
}
rewriter.emitStartTag(startTag);
});
rewriter.on('endTag', endTag => {
if (endTag.tagName === 'span') {
endTag.tagName = 'div';
}
rewriter.emitEndTag(endTag);
});
// Wrap all text nodes with an <i> tag
rewriter.on('text', (_, raw) => {
// Use the raw representation of text without HTML entities decoding
rewriter.emitRaw(`<i>${raw}</i>`);
});
http.get('http://google.com', res => {
// Assumes response is UTF-8.
res.setEncoding('utf8');
// `RewritingStream` is a `Transform` stream, which means you can pipe
// through it.
res.pipe(rewriter).pipe(file);
});
-Note: sourceCodeLocationInfo
is always enabled.
If false
then the stream will automatically end the writable side when the
+
If false
then the stream will automatically end the writable side when the
readable side ends. Set initially by the allowHalfOpen
constructor option,
which defaults to false
.
This can be changed manually to change the half-open behavior of an existingDuplex
stream instance, but must be changed before the 'end'
event is
@@ -129,7 +129,7 @@
Installing a listener using this symbol does not change the behavior once an
'error'
event is emitted, therefore the process will still crash if no
regular 'error'
listener is installed.
Optional
_constructProtected
_emitOptional
_writevEvent emitter +
Optional
_constructProtected
_emitOptional
_writevEvent emitter The defined events on documents including:
Optional
error: ErrorError which will be passed as payload in 'error'
event
v8.0.0
Rest
...args: any[]Emits a serialized comment token into the output stream.
-Emits a serialized document type token into the output stream.
-Emits a serialized end tag token into the output stream.
-Protected
emitEmits a serialized start tag token into the output stream.
-Emits a serialized text token into the output stream.
-Optional
cb: (() => void)Optional
cb: (() => void)Optional
encoding: BufferEncodingOptional
cb: (() => void)Returns an array listing the events for which the emitter has registered +
Emits a serialized document type token into the output stream.
+Emits a serialized end tag token into the output stream.
+Protected
emitEmits a serialized start tag token into the output stream.
+Emits a serialized text token into the output stream.
+Optional
cb: (() => void)Optional
cb: (() => void)Optional
encoding: BufferEncodingOptional
cb: (() => void)Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbol
s.
const EventEmitter = require('events');
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
@@ -177,14 +177,14 @@
Alias for emitter.removeListener()
.
Rest
...args: any[]v10.0.0
Raised when the rewriter encounters a start tag.
-Raised when rewriter encounters an end tag.
-Raised when rewriter encounters a comment.
-Raised when rewriter encounters text content.
-Raised when rewriter encounters a document type declaration.
-Base event handler.
+Raised when rewriter encounters an end tag.
+Raised when rewriter encounters a comment.
+Raised when rewriter encounters text content.
+Raised when rewriter encounters a document type declaration.
+Base event handler.
Name of the event
Event handler
-Rest
...args: any[]Rest
...args: any[]The readable.pause()
method will cause a stream in flowing mode to stop
+
Rest
...args: any[]Rest
...args: any[]The readable.pause()
method will cause a stream in flowing mode to stop
emitting 'data'
events, switching out of flowing mode. Any data that
becomes available will remain in the internal buffer.
const readable = getReadableStreamSomehow();
readable.on('data', (chunk) => {
console.log(`Received ${chunk.length} bytes of data.`);
readable.pause();
console.log('There will be no additional data for 1 second.');
setTimeout(() => {
console.log('Now data will start flowing again.');
readable.resume();
}, 1000);
});
diff --git a/classes/parse5_parser_stream.ParserStream.html b/classes/parse5_parser_stream.ParserStream.html
index 946502b8d..79d2ae9c7 100644
--- a/classes/parse5_parser_stream.ParserStream.html
+++ b/classes/parse5_parser_stream.ParserStream.html
@@ -2,7 +2,7 @@
A writable stream.
const ParserStream = require('parse5-parser-stream');
const http = require('http');
const { finished } = require('node:stream');
// Fetch the page content and obtain it's <head> node
http.get('http://inikulin.github.io/parse5/', res => {
const parser = new ParserStream();
finished(parser, () => {
console.log(parser.document.childNodes[1].childNodes[0].tagName); //> 'head'
});
res.pipe(parser);
});
-Optional
options: ParserOptions<T>Parsing options.
-Readonly
closedIs true after 'close' has been emitted.
+Readonly
closedIs true after 'close' has been emitted.
v18.0.0
Is true
after writable.destroy()
has been called.
v8.0.0
Readonly
erroredReturns error if the stream has been destroyed with an error.
v18.0.0
-Readonly
writableIs true
if it is safe to call writable.write()
, which means
+
Readonly
writableIs true
if it is safe to call writable.write()
, which means
the stream has not been destroyed, errored or ended.
v11.4.0
Readonly
writableNumber of times writable.uncork()
needs to be
@@ -92,7 +92,7 @@
'error'
event is emitted, therefore the process will still crash if no
regular 'error'
listener is installed.
The resulting document node.
-Optional
_constructOptional
_writevEvent emitter +
Optional
_constructOptional
_writevEvent emitter The defined events on documents including:
writable._destroy()
.
Optional
error: ErrorOptional, an error to emit with 'error'
event.
v8.0.0
-Rest
...args: any[]Rest
...args: any[]Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbol
s.
const EventEmitter = require('events');
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
v6.0.0
-Returns the current max listener value for the EventEmitter
which is either
set by emitter.setMaxListeners(n)
or defaults to defaultMaxListeners.
v1.0.0
Returns the number of listeners listening to the event named eventName
.
Name of the event
const ParserStream = require('parse5-parser-stream');
const http = require('http');
const parser = new ParserStream();
parser.on('script', (scriptElement, documentWrite, resume) => {
const src = scriptElement.attrs.find(({ name }) => name === 'src').value;
http.get(src, res => {
// Fetch the script content, execute it with DOM built around `parser.document` and
// `document.write` implemented using `documentWrite`.
...
// Then resume parsing.
resume();
});
});
parser.end('<script src="example.com/script.js"></script>');
-Base event handler.
+Base event handler.
Name of the event
Event handler
-Rest
...args: any[]Rest
...args: any[]Rest
...args: any[]Rest
...args: any[]Returns a copy of the array of listeners for the event named eventName
,
+
Rest
...args: any[]Rest
...args: any[]Rest
...args: any[]Rest
...args: any[]Returns a copy of the array of listeners for the event named eventName
,
including any wrappers (such as those created by .once()
).
const emitter = new EventEmitter();
emitter.once('log', () => console.log('log once'));
// Returns a new Array with a function `onceWrapper` which has a property
// `listener` which contains the original listener bound above
const listeners = emitter.rawListeners('log');
const logFnWrapper = listeners[0];
// Logs "log once" to the console and does not unbind the `once` event
logFnWrapper.listener();
// Logs "log once" to the console and removes the listener
logFnWrapper();
emitter.on('log', () => console.log('log persistently'));
// Will return a new Array with a single function bound by `.on()` above
const newListeners = emitter.rawListeners('log');
// Logs "log persistently" twice
newListeners[0]();
emitter.emit('log');
@@ -228,7 +228,7 @@
const { getEventListeners, EventEmitter } = require('events');
{
const ee = new EventEmitter();
const listener = () => console.log('Events are fun');
ee.on('foo', listener);
getEventListeners(ee, 'foo'); // [listener]
}
{
const et = new EventTarget();
const listener = () => console.log('Events are fun');
et.addEventListener('foo', listener);
getEventListeners(et, 'foo'); // [listener]
}
v15.2.0, v14.17.0
-Static
getOptional
fragmentContext: null | T["parentNode"]Optional
options: ParserOptions<T>Static
listenerStatic
getOptional
fragmentContext: null | T["parentNode"]Optional
options: ParserOptions<T>Static
listenerA class method that returns the number of listeners for the given eventName
registered on the given emitter
.
const { EventEmitter, listenerCount } = require('events');
const myEmitter = new EventEmitter();
myEmitter.on('event', () => {});
myEmitter.on('event', () => {});
console.log(listenerCount(myEmitter, 'event'));
// Prints: 2
The emitter to query
diff --git a/classes/parse5_plain_text_conversion_stream.PlainTextConversionStream.html b/classes/parse5_plain_text_conversion_stream.PlainTextConversionStream.html index 16b599c1f..9b040ce21 100644 --- a/classes/parse5_plain_text_conversion_stream.PlainTextConversionStream.html +++ b/classes/parse5_plain_text_conversion_stream.PlainTextConversionStream.html @@ -2,7 +2,7 @@ A writable stream.const PlainTextConversionStream = require('parse5-plain-text-conversion-stream');
const fs = require('fs');
const { finished } = require('node:stream');
const file = fs.createReadStream('war_and_peace.txt');
const converter = new PlainTextConversionStream();
finished(converter, () => {
console.log(converter.document.childNodes[1].childNodes[0].tagName); //> 'head'
});
file.pipe(converter);
-Optional
options: ParserOptions<T>Readonly
closedIs true after 'close' has been emitted.
+Optional
options: ParserOptions<T>Readonly
closedIs true after 'close' has been emitted.
v18.0.0
Is true
after writable.destroy()
has been called.
v8.0.0
diff --git a/classes/parse5_sax_parser.SAXParser.html b/classes/parse5_sax_parser.SAXParser.html index 5dcc8790c..871c2bf0a 100644 --- a/classes/parse5_sax_parser.SAXParser.html +++ b/classes/parse5_sax_parser.SAXParser.html @@ -2,7 +2,7 @@ A transform stream (which means you can pipe through it, see example). const SAXParser = require('parse5-sax-parser');
const http = require('http');
const fs = require('fs');
const file = fs.createWriteStream('/home/google.com.html');
const parser = new SAXParser();
parser.on('text', text => {
// Handle page text content
...
});
http.get('http://google.com', res => {
// `SAXParser` is the `Transform` stream, which means you can pipe
// through it. So, you can analyze the page content and, e.g., save it
// to the file at the same time:
res.pipe(parser).pipe(file);
});
-Parsing options.
-If false
then the stream will automatically end the writable side when the
+
If false
then the stream will automatically end the writable side when the
readable side ends. Set initially by the allowHalfOpen
constructor option,
which defaults to false
.
This can be changed manually to change the half-open behavior of an existingDuplex
stream instance, but must be changed before the 'end'
event is
@@ -92,7 +92,7 @@
v0.9.4
Readonly
closedIs true
after readable.destroy()
has been called.
v8.0.0
-Readonly
erroredProtected
optionsIs true
if it is safe to call readable.read()
, which means
+
Readonly
erroredProtected
optionsIs true
if it is safe to call readable.read()
, which means
the stream has not been destroyed or emitted 'error'
or 'end'
.
v11.4.0
Readonly
Experimental
readableReturns whether the stream was destroyed or errored before emitting 'end'
.
v9.4.0
Readonly
readableGetter for the property objectMode
of a given Readable
stream.
v12.3.0
-Protected
tokenizerReadonly
writableReadonly
writableReadonly
writableReadonly
writableReadonly
writableReadonly
writableReadonly
writableReadonly
writableStatic
Readonly
captureStatic
captureSets or gets the default captureRejection value for all emitters.
+Protected
tokenizerReadonly
writableReadonly
writableReadonly
writableReadonly
writableReadonly
writableReadonly
writableReadonly
writableReadonly
writableStatic
Readonly
captureStatic
captureSets or gets the default captureRejection value for all emitters.
Static
defaultStatic
Readonly
errorThis symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular
'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an
'error'
event is emitted, therefore the process will still crash if no
regular 'error'
listener is installed.
Optional
_constructProtected
_emitProtected
_transformOptional
_writevEvent emitter +
Optional
_constructProtected
_emitProtected
_transformOptional
_writevEvent emitter The defined events on documents including:
Implementors should not override this method, but instead implement readable._destroy()
.
Optional
error: ErrorError which will be passed as payload in 'error'
event
v8.0.0
-Rest
...args: any[]Protected
emitOptional
cb: (() => void)Optional
cb: (() => void)Optional
encoding: BufferEncodingOptional
cb: (() => void)Rest
...args: any[]Protected
emitOptional
cb: (() => void)Optional
cb: (() => void)Optional
encoding: BufferEncodingOptional
cb: (() => void)Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbol
s.
const EventEmitter = require('events');
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
@@ -163,14 +163,14 @@
Raised when the parser encounters a start tag.
-Raised when the parser encounters an end tag.
-Raised when the parser encounters a comment.
-Raised when the parser encounters text content.
-Raised when the parser encounters a document type declaration
-Base event handler.
+Raised when the parser encounters an end tag.
+Raised when the parser encounters a comment.
+Raised when the parser encounters text content.
+Raised when the parser encounters a document type declaration
+Base event handler.
Name of the event
Event handler
-Rest
...args: any[]Rest
...args: any[]The readable.pause()
method will cause a stream in flowing mode to stop
+
Rest
...args: any[]Rest
...args: any[]The readable.pause()
method will cause a stream in flowing mode to stop
emitting 'data'
events, switching out of flowing mode. Any data that
becomes available will remain in the internal buffer.
const readable = getReadableStreamSomehow();
readable.on('data', (chunk) => {
console.log(`Received ${chunk.length} bytes of data.`);
readable.pause();
console.log('There will be no additional data for 1 second.');
setTimeout(() => {
console.log('Now data will start flowing again.');
readable.resume();
}, 1000);
});
@@ -255,7 +255,7 @@
prevent piping, so that data will flow through the parser as usual.
const SAXParser = require('parse5-sax-parser');
const http = require('http');
const fs = require('fs');
const file = fs.createWriteStream('google.com.html');
const parser = new SAXParser();
parser.on('doctype', ({ name, publicId, systemId }) => {
// Process doctype info and stop parsing
...
parser.stop();
});
http.get('http://google.com', res => {
// Despite the fact that parser.stop() was called whole
// content of the page will be written to the file
res.pipe(parser).pipe(file);
});
-The readable.unpipe()
method detaches a Writable
stream previously attached
+
The readable.unpipe()
method detaches a Writable
stream previously attached
using the pipe method.
If the destination
is not specified, then all pipes are detached.
If the destination
is specified, but no pipe is set up for it, then
diff --git a/enums/parse5.ErrorCodes.html b/enums/parse5.ErrorCodes.html
index 9ca4e542c..266dabfd0 100644
--- a/enums/parse5.ErrorCodes.html
+++ b/enums/parse5.ErrorCodes.html
@@ -1,4 +1,4 @@
-
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
The mode of the document.
Generated using TypeDoc
Generated using TypeDoc
Indicates that the current node is not an element in the HTML namespace
-