selectolax Changelog¶
Version 1.0.1¶
Add the
scriptingoption toLexborHTMLParser, which parses<noscript>the way a browser with scripting enabled does: its content becomes raw text, so a<noscript>in<head>no longer pushes the head elements after it into<body>. The default is unchanged.Add
template_fragments()for reaching the content of<template>elements which are ignored by HTML5 compliant parsers.Do not replace
<-undef>it not longer possible to get it.The internal
<html>wrapper of an HTML fragment is no longer reported as theparentof the fragment’s top-level nodes.create_tag()no longer returnsNonefor the tags whose start tag the HTML parser drops (html,head,body,caption,col,colgroup,frame,frameset,tbody,td,tfoot,th,thead,tr).Fix
inner_htmlcovering only the first top-level node of an HTML fragment.Improve the speed of comment extraction
Improve the speed of
len(attrs)by counting the attribute list directlyFix encoding initialization when
encoding=True.
Version 1.0.0¶
This release contains breaking changes.
The main change is that the Modest backend is no longer available. It is outdated and unmaintained, contains bugs, and does not follow modern HTML5 standards.
The second is that parse_fragment() is gone. It re-implemented fragment parsing by guessing
whether the input was a document or a fragment; LexborHTMLParser(html, is_fragment=True) already
does this properly, so the guessing layer has been removed.
The rest of the changes fix corner cases where the bugs were happening rarely, usually when heavily modifying the tree.
Breaking: Remove the Modest backend.
selectolax.parseris now a stub that raisesImportErroron import. Use the lexbor backend (from selectolax.lexbor import LexborHTMLParser) instead.Breaking: Remove
parse_fragment().Breaking: Fix
css_matchesandany_css_matchesmissing matches outside the first top-level node of an HTML fragment. They now search the same scope ascss.Breaking: Fix
tagsandstrip_tagsdoing nothing on an HTML fragment.tagsreturned an empty list andstrip_tagsremoved nothing, because the fragment was not reachable from the document node.Breaking: Fix the internal
<html>wrapper of an HTML fragment being reported as a match.Breaking: Fix
scripts_containandscript_srcs_containmissing matches outside the first top-level node of an HTML fragment. They now search the same scope ascss.Breaking: Fix
scripts_containandscript_srcs_containanswering from another scope’s cached result. The cache is keyed by the node the search is rooted at rather than the node it was called on.Breaking: Fix
select()missing matches outside the first top-level node of an HTML fragment. It now searches the same scope ascss.Breaking: Fix
traverse()covering only the first top-level node of an HTML fragment, and yielding nothing when the fragment starts with a text node.Breaking: Fix
attribute_longer_thanandany_attribute_longer_thanreturning inconsistent resultsBreaking:
attributesandattrsnow report an attribute’s qualified name instead of its local name. An element carrying bothhrefandxlink:hrefused to collapse them into a singlehrefkey.Breaking: Fix
iter()skipping the remaining children when a node is removed during iterationBreaking: Fix an HTML fragment whose first node is text dropping the rest of the fragment.
LexborHTMLParser('a<span>s</span>', is_fragment=True).text()returned'a'instead of'as'.Fix
text()silently returning truncated text instead of raising when a fragment fails to be collected.Fix
scripts_containandscript_srcs_containsometimes returning wrong results due to HTML mutations.Fix a single undecodable byte in an untrusted document making
html,inner_html,html_pretty,attributes,attrs,id,tag,text_lexborandtext_contentraiseUnicodeDecodeError. Bytes Lexbor passes through verbatim are now substituted with U+FFFD, the waytext()already did.Fix
text_lexborsometimes holding temporary memory longer than neededImprove memory consumption, potential stack overflow and slow extraction in
merge_text_nodes(). It is now up to 10 times faster.Improve speed of
__eq__Improve speed of
attrs.items()andattrs.values().Fix the
inner_htmlsetter attaching element children to non-element nodesFix
headandbodydangling after settinginner_htmlon the<html>elementFix the
inner_htmlsetter freeing the replaced childrenFix
rootgoing stale on an HTML fragment.Fix a segfault when walking the tree from the root of an HTML fragment that had been detached from the fragment, for example by
unwrap().Avoid segfaults when hitting OOM
Improve performance of the
textmethod. Text fragments are now concatenated as raw bytes, up to 5x faster.Fix
skip_emptybeing ignored bytext(deep=True)Fix
text()raisingUnicodeDecodeErroron undecodable bytes whendeep=False. It now substitutes U+FFFD, like the deep path always didFix handling of the
idmethod on text nodesFix
attrs[key] = valueraisingAttributeErrorinstead ofTypeErrorwhenvalueis not a stringPrevent segfaults when instantiating
LexborNodeorLexborAttributesdirectly.Fix
unwrap()corrupting the tree in some cases.Fix
headandbodygoing stale once<head>/<body>is removed from the document.Fix
attrsreading freed memory when it outlives the node it was obtained from.Fix memory leak in
attrs[key] = None; it leaked the value buffer header on every call.Fix possible memory leak in
clone()Add
encoding=TruetoLexborHTMLParser, which detects the encoding ofbytesinput and transcodes it to UTF-8 before parsing.
Version 0.4.13¶
Support lexbor-only builds with
--disable-modestImporting
selectolaxno longer automatically importsselectolax.parserandselectolax.lexborUpdate lexbor
Version 0.4.12¶
Add
optionsparameter toLexborHTMLParserto pass Lexbor document parsing options (for example,LexborDocumentOptions.WO_EVENTSto disable mutation events). Fixes #221.Fix
LexborHTMLParser.clone()losing nodes for empty HTML fragmentsAllow empty elements in
text_lexbor. Fixes #220.Update lexbor
Version 0.4.11¶
Add NULL checks for CSS selectors module to prevent crashes
Fix html5test pretty print serialization mode checks
Update lexbor
Version 0.4.10¶
Do not destroy nodes when stripping tags
Allow building selectolax using older lexbor versions (#218)
Update lexbor. Fixes crashes when parsing HTML (#217).
Version 0.4.9¶
Add an ability to specify tags and namespace for fragmented parser
Add a new serialization mode when pretty printing:
html5testAllow empty HTML fragments
Fix attrs access for non-element nodes
Improve buffer cleanups
Fix duplicate text when doing
text(deep=True)on a text nodeImprove text concatenation performance
Improve attribute handling
Version 0.4.8¶
Add Add
html_pretty,inner_html_prettymethodsEnable free-threading
Improve
merge_text_nodesUpdate lexbor
Version 0.4.7¶
Fix
.text()anditer()for HTML fragments when there are multiple nodes at the root level. Resolves #209.Update lexbor. Resolves #212.
Breaking changes: Empty tags are now serialized to
<div value="">instead of<div value>(Commit 4530fed).Improve
unwrap_tagsandmerge_text_nodes.
Version 0.4.6¶
Fix HTML parsing in fragment parser for
LexborHTMLParserFix memory leak in fragment parser
Improve
skip_emptyparameter for text methodsAdd
comment_contentmethodMinor performance optimizations
Add
create_tagmethod toLexborHTMLParserFix advanced selector (
.select()) when attributes are empty.
Version 0.4.5¶
Broken release. Not published to PyPi.
Version 0.4.4¶
Add
is_fragmentparameter toLexborHTMLParser@pygarapAdd the ability to skip empty text nodes for lexbor backend to
.text,.iter,.traverse@pygarapAdd new properties to lexbor backend:
is_element_node,is_text_node,is_comment_node,is_document_node. @pygarapUpdate
lexborlibrary
Version 0.4.3¶
Update
lexborlibraryFix missing description on PyPi.
Version 0.4.2¶
Broken release. Not published to PyPi.
Version 0.4.1¶
Fix parsing of CSS selectors that contain Unicode characters.
Version 0.4.0¶
Fix incorrect default value in docstrings for strict argument
Fix incorrect exception handling for
any_css_matchesFix docstring for
css_firstmethodFix memory leak in
merge_text_nodesfor lexbor backendUpdate lexbor backend
Add
.inner_htmlproperty. Allows to get and set inner HTML of a node.Update various docstrings.
Optimize performance for
css_firstin lexbor backendFix segfaults when accessing attributes. Resolves #135.
Add new
.clonemethod to lexbor backend. Resolve #117.Improve unicode handling for malformed text. Resolves #138.
Fix segfaults when doing double
.decompose. Resolves #179.Fix sefgaults when doing double
.unwrap. Resolves #169.Fix typo for tag names. Clarify available tag names.
Version 0.3.34¶
Released
Lexbor backend now supports
:lexbor-contains("abc" i)CSS pseudo-class to match text nodes.
Version 0.3.33¶
Released
Add
merge_text_nodesto lexbor backend. Fixes #170. @amirshukayevPerformance improvements in Cython code. @Vizonex
Version 0.3.32¶
Released
Update lexbor. New version of lexbor fixes bugs with CSS selectors.
Version 0.3.31¶
Released
Improve type hints, add docstrings to type hints
Prevent decomposing of the root node
Unpin Cython version and make it Optional
Allow empty attribute values. Fixes #165.
Version 0.3.30¶
Released
Update lexbor
Expose
SelectolaxErrorexception in lexbor.pyi
Version 0.3.29¶
Released
Feat: Add unwrap empty tags functionality. Fixes #159.
Version 0.3.28¶
Released
Fix: Update lexbor and improve HTML serialization speed. Fixes #153.
Fix: typo in type annotations. Fixes #147.
Fix: Fix incorrect type annotations for
LexborHTMLParser.__init__. Fixes #144.
Version 0.3.27¶
Released
Fix: Header detected as head
Version 0.3.26¶
Released
Improve type hints
Version 0.3.25¶
Released
Feat: Add
parse_fragment()andcreate_tag()Add missing typing for
Node.insert_child()Add
Node.parserto access theHTMLParserto which the node belongs
Version 0.3.24¶
Released
Add
Node.insert_childmethod to lexbor and modest backends
Version 0.3.23¶
Released
Add Python 3.13 wheels
Update lexbor
Version 0.3.21¶
Released
Breaking change:
lexborbackend now includes the root node when querying CSS selectors. Same asModestbackend.Fix
css_matchesandany_css_matchesmethods forModestbackend on some compilers
Version 0.3.20¶
Released
Fixup for 0.3.19 release
Fix tag order for
lexborbackend
Version 0.3.19¶
Released
Increase maximum HTML size to 2.4GB
Version 0.3.18¶
Released
Fix memory leak when using CSS selectors,
lexborbackend
Version 0.3.17¶
Released
Update lexbor
Add Python 3.12 wheels
Version 0.3.16¶
Released
Make HTML nodes hashable
Pin Cython version
Version 0.3.15¶
Released
Improve typing. Thanks to @nesb1
Version 0.3.14¶
Released
Fix memory leak for
lexborbackend
Version 0.3.13¶
Released
Update
lexbor
Version 0.3.12¶
Released
Update
lexborAdd Python 3.11 wheels
Version 0.3.11¶
Released
Fix out-of-bounds bug for
merge_text_nodesmethod.
Version 0.3.10¶
Released
This release does not contain any changes. Due to a typo in the version number (#70), we need to make a new release.
Version 0.3.9¶
Released
Remove trailing separator when using
text(deep=True, separator='x').Add a new
merge_text_nodesmethod for Modest backend.
Version 0.3.8¶
Released
Fix incorrect text handling when using
text(deep=True)on a text node.
Version 0.3.7¶
Released
Fix return type of HTMLParser.tags
Version 0.3.6¶
Released
Improve text handling
Add binary builds for Python 3.10 and ARM on MacOS and Linux
Version 0.3.5¶
Released
Add type annotations
Version 0.3.4¶
Released
Fix
HTMLParser.html
Version 0.3.3¶
Released
Use
documentfor theHTMLParser.html,LexborHTMLParser.htmlroot properties
Version 0.3.2¶
Released
Fix
selectormethod for lexborImprove text extraction for lexbor
Version 0.3.1¶
Released
Fix
setup.pyfor Windows
Version 0.3.0¶
Released
Added
lexborbackendFix cloning for
Modestbackend
Version 0.2.14¶
Released
Added advanced Selector (the
selectmethod)Improved speed of
strip_tagsAdded
clonemethod for theHtmlParserobjectExposed
detect_encoding,decode_errors,use_meta_tags,raw_htmlattributes forHtmlParserAdded
sgetmethod to theattrsproperty
Version 0.2.13¶
Released
Version 0.2.12¶
Released
Build wheels Apple Silicon
Version 0.2.11¶
Released
Version 0.2.10¶
Released
Fix root node property (#32). The
rootproperty now points to the html tag.
Version 0.2.9¶
Released
Fix README for PyPI
Version 0.2.8¶
Released
Add wheels for Python 3.9
Version 0.2.7¶
Released
Add
raw_valueattribute forNodeobjects (#22)Improve node modification operations
Version 0.2.6¶
Released
Fix dependency on the source
Nodewhen inserting to or modifying destinationNode
Version 0.2.5¶
Released
Allow to pass Node instances to
replace_with,insert_beforeandinsert_aftermethodsAdded
insert_beforeandinsert_aftermethods
Version 0.2.4¶
Released
Set maximum input size to 80MB
Update modest
Version 0.2.3¶
Released
Rebuild PyPi wheels to support Python 3.8 and manylinux2010
Version 0.2.2¶
Released
Fix node comparison
Version 0.2.1¶
Released
Add optional
include_textparameter for theiterandtraversemethods
Version 0.2.0¶
Released