🌜
🌞
parse5-html-rewriting-stream

parse5-html-rewriting-stream

v7.0.0

Streaming HTML rewriter.

npm install parse5-html-rewriting-stream

README

Release Notes

7.0.0
By Felix • Published on April 20, 2022

Welcome to [email protected]! ✨ This is a huge release with many changes, features and fixes.

From an organisational perspective, the most important change is that parse5 is now maintained by a team, consisting of James (@43081j), Titus (@wooorm) and me (@fb55). We come from three projects that rely on parse5 — namely Cheerio, rehype, and Lit.

We need your support to continue the project! If you care about parse5, please support us financially on OpenCollective.

Headlining features of this release are ES Modules, TypeScript, and performance improvements: 7.0.0 is 45% faster than 6.0.1 with default options, and 167% faster with location information enabled (for the bench/perf benchmark, on an M1 Mac). Version 7.0.0 is a revamp of every part of the library. There are too many changes to list them all here, so here is a high-level overview:

Breaking: ESM

All of parse5’s packages are now ECMAScript Modules. We are providing dual packages for parse5 and parse5-htmlparser2-tree-adapter for now (see https://github.com/inikulin/parse5/pull/418 and https://github.com/inikulin/parse5/pull/496).

To migrate, please read this Gist on how to update. Note that private internals are no longer available; instead, everything that you need should be imported from the main package.

Implemented by @43081j in #351

Breaking: TypeScript

The codebase has been ported to TypeScript. This helped uncover a number of subtle logic bugs, such as dc4e269022ebbae0767d8f790a29d6be1835fe1e, b4b5d4ad6f90b3c9fd03a90e2ed5267929979a11, or a0aff9578bb44511bc169c1d7f9e2f2780f7f8a0. TypeScript also helps us refactor with confidence and a lot of the changes in this release would have been much harder to do without it.

To migrate, please remove @types/parse5* as we now ship our own types.

Implemented by @fb55 in #362

Potentially breaking changes

If you are using deep imports for any parts of the codebase, you will likely encounter some breakages:

Show internal changes

Other changes

  • minor add hooks for stack events to tree adapter interface #385
  • minor add support for fragments in parse5-parser-stream #487
  • minor add serializeOuter (like .outerHTML), scriptingEnabled option #383
  • patch fix parsing of << in comments parsed wrongly as <! (#326)
  • patch fix position of endTag for mixed-case foreign elements (#353)
  • patch fix end position of html, body (#436)
  • docs: parse5 has a new documentation website at parse5.js.org #443

New Contributors

Thanks @anko, @TrySound, @samouri, @alan-agius4, and @pmdartus!

Full Changelog: https://github.com/inikulin/parse5/compare/v6.0.1...v7.0.0

6.0.1
By Felix • Published on July 24, 2020
  • Fixed: Handling of self-closing <hr> tags (by @43081j).
  • Fixed: Broken link in TreeAdapter document (GH #317) (by @ursm).
  • Fixed: SAXParser example (GH #316) (by @mvasilkov).
6.0.0
By Felix • Published on April 15, 2020
  • Added (breaking): Tree adapter interface now has updateNodeSourceCodeLocation method which enables usage of custom location info formats (GH #314) (by @DMartens).
5.1.1
By Ivan Nikulin • Published on November 6, 2019
  • Fixed: Serialization of attributes in non-standard namespaces (by @Zirro).
  • Fixed: Quirks and limited-quirks mode detection by doctype (by @squidfunk).
5.1.0
By Ingvar Stepanyan • Published on August 14, 2018
  • Fixed: Location info for text events in SAXParser and RewritingStream now contains correct endCol and endLine covering all concatenated raw tokens (GH #266).
  • Fixed: SAXParser and RewritingStream now flush last buffered chunk when calling .end() with no parameters (GH #271).
  • Updated (breaking): ParserStream, SAXParser and RewritingStream no longer assume that each binary chunk is a valid finished UTF-8 chunk, and instead accept only decoded strings (GH #269).
5.0.0
By Ivan Nikulin • Published on May 23, 2018

Starting from this release parse5 functionality will be shipped in separate packages. With parse5 package contatining only basic functionality. Please, refer to the list of packages for more info.

  • Updated (breaking): source code location now inserted by tree adapter, so tree adapter developers have control over location info property name. Tree adapters should implement setNodeSourceCodeLocation and getNodeSourceCodeLocation methods. Location info property name added by currently implemented tree adapters has been renamed from __location to sourceCodeLocation (GH #189).

  • Updated (breaking): Location info line and col properties have been renamed to startLine and startCol respectively.

  • Updated (breaking): SAXParser now passes token objects to event handlers instead of separate arguments. See SAXParser documentation for more info. (GH #247).

  • Added: endLine and endCol location info properties.

  • Added: scriptingEnabled flag to the ParserOptions which controls how <noscript> tags are handled by the parser. (GH #192).

  • Added: HTML rewriting stream. (GH #222).

  • Removed (breaking): parse5 no longer ship TypeScript definitions. Existing TypeScript definitions have been moved to DefinitelyTyped repo. Please, track the PR in the DefinitelyTyped repo for the updates.

General

License
MIT
Typescript Types
Built-in
Tree-shakeable
Yes

Popularity

GitHub Stargazers
3,133
Community Interest
3,013
Number of Forks
231

Maintenance

Commits
11/2110/22060
Last Commit
Open Issues
17
Closed Issues
282
Open Pull Requests
6
Closed Pull Requests
64

Versions

Versions Released
11/2110/2201
Latest Version Released
Apr 20, 2022
Current Tags
latest7.0.0

Dependencies

Dependencies (2)
Dev Dependencies (0)

Contributors

inikulin
inikulin
Commits: 490
RReverser
RReverser
Commits: 24
diervo
diervo
Commits: 20
sakagg
sakagg
Commits: 6
yyx990803
yyx990803
Commits: 6
notslang
notslang
Commits: 6
webdesus
webdesus
Commits: 4
stevenvachon
stevenvachon
Commits: 4
squidfunk
squidfunk
Commits: 3
alanclarke
alanclarke
Commits: 2
wooorm
wooorm
Commits: 2
Sebmaster
Sebmaster
Commits: 2
Zirro
Zirro
Commits: 2
dkoleary88
dkoleary88
Commits: 1
anko
anko
Commits: 1