Repository navigation
v1.0.0
·
1613 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
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:scopepseudo-classes) and an XPath 1.0 engine:xpath, a compiled reusableXPath, the EXSLT function set, and namespace, variable, and extension binding. A pyquery-styleQuery, a soupsieve-shaped matcher, andcss_to_xpathcover 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 underclean. 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) throughextract, 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
detectmodule, 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 througherrors, and locate each element in the source throughsource_lineandsource_col. (#210, #212) by @gaborbernat. - Sanitize untrusted HTML against a frozen allowlist
Policythat 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
Eanddocument, edit the class token set and inner HTML or text, wrap and unwrap subtrees, trim a document to a selector withprune, read and fill form fields, and compare two subtrees withequals. (#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 aturbohtmlcommand 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:scoperesolution 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
itemrefmerging, tablerowspanbounds, and the WHATWG formselect/optgroupsubmission 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.txtmaps, 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.matchintoquery; the sanitizer, linkifier, and every minifier gather underclean; a malformed selector raises oneSelectorSyntaxErrorfrom every parse path; the twoDetectorclasses split intoEncodingDetectorandLinkDetector; and each surface with more than six arguments takes one frozenoptionsconfig. (#478) by @gaborbernat. - Select a serialization mode with a single
layoutargument in place ofindent, soserialize(indent=2)becomesserialize(layout=Indent(2))andMinifyselects minified output. (#171) by @gaborbernat. - Report a valueless attribute (
<x a>) as the empty string rather thanNoneinattrs, 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
findseveral 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
.soand 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.