Parsing options.
The resulting document node.
Event emitter The defined events on documents including:
Raised then parser encounters a <script> element.
If this event has listeners, parsing will be suspended once it is emitted.
So, if <script> has the src attribute, you can fetch it, execute and then resume parsing just like browsers do.
The script element that caused the event.
Write additional html at the current parsing position. Suitable for implementing the DOM document.write and document.writeln methods.
HTML to write.
Resumes parsing.
WritableStream events
Generated using TypeDoc
Converts plain text files into HTML document as required by HTML specification. A writable stream.
NOTE: This API is available only for Node.js.
const parse5 = require('parse5'); const fs = require('fs'); const file = fs.createReadStream('war_and_peace.txt'); const converter = new parse5.PlainTextConversionStream(); converter.once('finish', () => { console.log(converter.document.childNodes[1].childNodes[0].tagName); //> 'head' }); file.pipe(converter);