Skip to content

v1.0.0

Choose a tag to compare

@gaborbernat gaborbernat released this 06 Jul 22:28
· 1613 commits to main since this release
Immutable release. Only release title and notes can be modified.
0c1279a

Features

  • Query a tree with the full Selectors Level 4 grammar (:is(), :where(), :has(), :not(), :nth-child(An+B of S), the structural, input, :lang(), :dir(), and :scope pseudo-classes) and an XPath 1.0 engine: xpath, a compiled reusable XPath, the EXSLT function set, and namespace, variable, and extension binding. A pyquery-style Query, a soupsieve-shaped matcher, and css_to_xpath cover the BeautifulSoup, cssselect, parsel, and pyquery surfaces. (#179) by @gaborbernat.
  • Serialize back to HTML with pretty-print, whitespace minification, and lazy streaming (serialize_iter), and minify HTML, CSS, and JavaScript through native engines under clean. Every transform is round-trip safe, replacing rcssmin, csscompressor, rjsmin, jsmin, minify-html, and htmlmin. (#343, #346) by @gaborbernat.
  • Convert a tree to GitHub-Flavored Markdown, layout-aware text, or annotated (start, end, label) spans, and extract a page's main article, boilerplate paragraphs, publication date, tables, links, and structured data (JSON-LD, Microdata, RDFa, Dublin Core, Open Graph) through extract, replacing markdownify, html2text, inscriptis, trafilatura, readability, htmldate, extruct, and microdata. (#273, #276) by @gaborbernat.
  • Detect a byte stream's encoding and a text's natural language from the standalone detect module, which reports confidence and a BOM label, covers 69 languages across nine scripts, and replaces chardet, charset-normalizer, and cchardet. (#315, #474) by @gaborbernat.
  • Parse incrementally from a stream with IncrementalParser, read the WHATWG parse errors recovery swallows through errors, and locate each element in the source through source_line and source_col. (#210, #212) by @gaborbernat.
  • Sanitize untrusted HTML against a frozen allowlist Policy that is safe with no arguments and scrubs inline and embedded CSS, foreign namespaces, and media hosts, and auto-link URLs and email addresses, together replacing bleach. (#8, #9) by @gaborbernat.
  • Build and edit the tree in place: construct nodes and a whole HTML5 page with E and document, edit the class token set and inner HTML or text, wrap and unwrap subtrees, trim a document to a selector with prune, read and fill form fields, and compare two subtrees with equals. (#275, #225, #468) by @gaborbernat.
  • Clean, canonicalize, and extract page URLs through extract, backed by a native URL pipeline (WHATWG splitting, percent-coding, relative-reference joining, UTS #46 IDNA, and Public Suffix List registrable-domain filtering), and run the toolkit from a turbohtml command line covering minify, detect, to-markdown, to-text, and sanitize. (#321, #470) by @gaborbernat.

Bug fixes

  • Bring tree construction to WHATWG conformance across foster parenting, foreign content, the select, table, and template insertion modes, doctype and quirks detection, duplicate and void-element handling, validated against the html5lib-tests corpus. (#32) by @gaborbernat.
  • Resolve every label in the WHATWG Encoding Standard, decode the replacement and gb18030 families and the windows-1252 C1 bytes, and honor the 1024-byte <meta> prescan. (#54, #423) by @gaborbernat.
  • Match the Selectors Level 4 corrections: forgiving :is()/:where() lists, quirks-mode case folding, CSS escape decoding, namespace prefixes, whitespace-only :empty, and :scope resolution inside :has(). (#174) by @gaborbernat.
  • Fix XPath 1.0 semantics: shortest round-tripping number formatting, half-to-positive-infinity rounding, fixed function arity, node-set typing, and arena-safe predicate compilation. (#398) by @gaborbernat.
  • Correct the Markdown and text exporters on nested and loose lists, link and image escaping, the <pre> leading newline, ordinal <li value>, and raw-text suppression in every namespace. (#384) by @gaborbernat.
  • Fix extraction on landmark-wrapped and list-structured articles, Microdata itemref merging, table rowspan bounds, and the WHATWG form select/optgroup submission rules. (#385, #408) by @gaborbernat.
  • Keep the CSS and JavaScript minifiers value-safe: calc() type mixing, duplicate-declaration fallbacks, currentcolor, conditional folding, and adjacent-string-literal concatenation. (#415) by @gaborbernat.
  • Raise a precise, typed error from every public failure path in place of a silent wrong result or a leaked low-level type, and document each callable's exceptions. (#434) by @gaborbernat.

Documentation

  • Ship a migration guide for each library turbohtml replaces, every one carrying a monthly-downloads badge, a measured benchmark, and a speed-up multiplier, with the index ordered by adoption. (#313) by @gaborbernat.
  • Restructure the reference, how-to, and migration trees around the eight-namespace taxonomy (parse/DOM, detect, query, clean, convert, extract, build, serialize), and add llms.txt maps, a sitemap, and per-page meta descriptions. (#478) by @gaborbernat.
  • Add a written security policy, a "How turbohtml was built" page, and the seven design principles that shape the library. (#500) by @gaborbernat.

Breaking changes

  • Give the public surface one name per concept. CSS matching folds from turbohtml.match into query; the sanitizer, linkifier, and every minifier gather under clean; a malformed selector raises one SelectorSyntaxError from every parse path; the two Detector classes split into EncodingDetector and LinkDetector; and each surface with more than six arguments takes one frozen options config. (#478) by @gaborbernat.
  • Select a serialization mode with a single layout argument in place of indent, so serialize(indent=2) becomes serialize(layout=Indent(2)) and Minify selects minified output. (#171) by @gaborbernat.
  • Report a valueless attribute (<x a>) as the empty string rather than None in attrs, matching the WHATWG tokenizer and the DOM. (#87) by @gaborbernat.

Security

  • Harden against untrusted input: ASan and UBSan fuzz gates on every entry point, a DOMPurify XSS oracle and an html5lib-tests tree-equality oracle over the sanitizer, mutation-XSS namespace checks, caps on element nesting and duplicate attributes, and one overflow-safe buffer-growth helper across the C core. (#503, #511) by @gaborbernat.

Performance

  • Speed the read path: a per-tree atom index runs a tag-pinned find several times faster, :has() evaluates in one amortized-linear pass, streaming serialization sizes its buffer up front, and link-time optimization re-inlines across a subsystem-first C layout. (#162, #509) by @gaborbernat.

Packaging

  • Build the release wheels with profile-guided, link-time optimization trained offline over a real-world corpus of clean, malformed, legacy-encoded, and structured-data markup. (#481) by @gaborbernat.
  • Pin every network-sourced C data table (IANA TLDs, the Public Suffix List, and the Unicode IDNA and NFC tables) to a named source commit and a SHA-256 checksum, so a rebuild is reproducible and aborts on a poisoned upstream. (#478) by @gaborbernat.
  • Strip the compiled extension's local symbol table from the release wheels at link time, trimming about 65 KB from the Linux .so and 46 KB from the macOS bundle; the source distribution still carries every test, tool, and generated table needed to build from source. (#478) by @gaborbernat.

🐍 PyPI release

📜 Full Changelog