Download Latest Version v12.0.0 source code.tar.gz (91.0 kB)
Email in envelope

Get an email when there's a new version of htmlparser2

Home / v12.0.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2026-03-20 1.7 kB
v12.0.0 source code.tar.gz 2026-03-20 91.0 kB
v12.0.0 source code.zip 2026-03-20 104.0 kB
Totals: 3 Items   196.7 kB 1

What's Changed

This release aligns HTML parsing with the WHATWG spec Almost all changes are to HTML mode only — XML mode is unaffected unless noted.

Raw-text & RCDATA tags

  • <iframe>, <noembed>, <noframes>, and <plaintext> are now raw-text tags, their content is no longer parsed as HTML
  • <textarea> now decodes entities like <title> already did
  • Self-closing <script/>, <style/>, etc. now enter their raw-text state (the / is ignored per spec) unless recognizeSelfClosing is enabled

SVG & MathML

  • Tag names inside <svg> are case-adjusted per spec (foreignObject, clipPath, etc.)
  • CDATA sections inside foreign content are treated as text
  • Special-tag detection is disabled inside foreign content
  • Stray </svg> / </math> no longer corrupt the parser's context tracking

Comments & declarations

  • <!-->, <!--->, <!->, <!> now parse as valid comments per spec
  • <?…> and non-DOCTYPE <!…> in HTML mode emit bogus comments instead of being silently dropped
  • <!DOCTYPEhtml> (no space) is recognized as a DOCTYPE
  • Unclosed comments, <!DOCTYPE, <?…, <![CDATA[… at EOF emit the correct token type

Implicit open/close

  • <h1><h6> implicitly close other headings
  • <a> closes a previous <a>
  • Nested <form> is ignored when one is already open
  • <image> is rewritten to <img> outside foreign content
  • </> is silently ignored instead of emitted as text

Other fixes

  • Fixed reset() not clearing attribute state, which could leak data across parseComplete() calls

https://github.com/fb55/htmlparser2/pull/2387

Full Changelog: https://github.com/fb55/htmlparser2/compare/v11.0.0...v12.0.0

Source: README.md, updated 2026-03-20