Skip to content

Releases: philss/floki

v0.38.1

17 Mar 20:56
a3a6291

Choose a tag to compare

Performance

This version contains major performance improvements in the following functions:

  • Floki.filter_out/2.
  • Floki.find/2 - with some improvements to specific selectors, like classes
    and attribute selectors.
  • Floki.text/2.

Those functions are not only faster, but are now using less memory. Please check
the PRs related to this release if you want to better understand the numbers.

All the improvements in this version were made by Barna Kovacs - @preciz,
so shout out and thanks to him!

Pull requests

  • Fix build status badge by @sgerrand in #632
  • Update v0.38.0 changelog item for breaking changes by @kianmeng in #634
  • Bump earmark from 1.4.47 to 1.4.48 by @dependabot[bot] in #635
  • Speed up do_classes_matches? by @preciz in #649
  • Make filter_out faster by @preciz in #650
  • Speed up attribute lookup by @preciz in #651
  • Enable tuple traversal optimization for multiple selectors by @preciz in #652
  • Optimize HTMLTree to_tuple conversion using Enum.reduce by @preciz in #657
  • Optimize Finder.get_descendant_ids/2 memory usage and speed by @preciz in #660
  • Fix unused require Logger warning in parser_test.exs by @preciz in #661
  • Optimize Finder.get_siblings/2 memory usage and speed by @preciz in #663
  • Optimize FlatText.get/3 memory usage and speed by @preciz in #664
  • Optimize class matching in Floki.Selector by @preciz in #665
  • Release v0.38.1 by @philss in #662

New Contributors

Full Changelog: v0.38.0...v0.38.1

v0.38.0

15 Jun 02:58
2c41ba8

Choose a tag to compare

Added

  • This version adds initial support for the :has pseudo-selector.
    It is a great addition that enables finding elements containing
    matching children.

    Examples for selectors:

    • "div:has(h1)"
    • "div:has(h1, p, span)"
    • "div:has(p.foo)"
    • "div:has(img[src='https://example.com'])"
    • "tr:has(*:fl-contains('TEST'))"

    Note that combinators like ">" are not allowed yet.

    Thank you @bvobart for this feature!

Fixed

  • Add :style option documentation to Floki.text/2.
    Thanks @s3cur3 for the fix.

  • Fix deprecation warnings for upcoming Elixir 1.19.

  • Prevent from crashing when selector is an empty string.

Removed

  • Remove support for Elixir 1.14 and OTP 23.

  • Remove deprecated functions and function clauses
    that were accepting strings (binaries).

    Affected functions:

    • parse/1 - removed function
    • map/2 - removed function
    • attr/4 - removed clause
    • find/2 - removed clause
    • text/3 - removed clause
    • text/3 - removed clause
    • attribute/2 - removed clause
    • filter_out/2 - removed clause

    HTML must be parsed before searching. Functions like Floki.find/2,
    Floki.attribute/2, and other HTML manipulation functions no longer work
    directly with HTML strings
    . The HTML must be parsed first using
    Floki.parse_fragment/2 or Floki.parse_document/2.

    Before:

    html = "<div class='foobar'><p>Hello</p></div>"
    Floki.find(html, "p")
    Floki.attribute(html, "div", "class")

    After:

    html = "<div class='foobar'><p>Hello</p></div>"
    parsed_html = Floki.parse_fragment!(html)
    Floki.find(parsed_html, "p")
    Floki.attribute(parsed_html, "div", "class")

Pull requests

New Contributors

Full Changelog: v0.37.1...v0.38.0

v0.37.1

22 Mar 22:31
be2b265

Choose a tag to compare

Fixed

Move regex declaration from module tag to inside function. This is a fix to be compatible with the upcoming OTP 28.

Pull requests

Full Changelog: v0.37.0...v0.37.1

v0.37.0

06 Dec 13:27
2c68b0f

Choose a tag to compare

Added

Fixed

  • Fix bug propagating identity encoder in raw_html/2 - thanks @andyleclair.

Removed

  • Remove support for Elixir 1.13 and OTP 22.

Pull requests

New Contributors

Full Changelog: v0.36.3...v0.37.0

v0.36.3

21 Oct 19:36
4032396

Choose a tag to compare

This release contains some performance improvements, thanks to @ypconstante.

Fixed

  • Stop Floki.get_by_id/2 traversal on first match. Thanks @ypconstante.

  • Remove extra whitespaces from nodes without attributes on Floki.raw_html/1.
    Thank you @ypconstante.

  • Fix Floki.raw_html/1 typespecs. Thanks @davydog187.

Pull requests

New Contributors

Full Changelog: v0.36.2...v0.36.3

v0.36.2

27 Apr 16:08
241eeb2

Choose a tag to compare

Added

  • Implement the Inspect protocol for the Floki.HTMLTree struct.
    This struct is currently private. Thank you @vittoriabitton.

Fixed

  • Fix regression to respect config option :encode in Floki.raw_html/2.
    Thanks @Sgoettschkes.

  • Make the Floki.raw_html/2 treat the contents of the <title> tag as plain text.
    The idea is to align with parse_document/2.
    Thank you @aymanosman.

Pull requests

New Contributors

Full Changelog: v0.36.0...v0.36.2

v0.36.1

27 Apr 16:08
v0.36.1
b98dc57

Choose a tag to compare

Fixed

  • Fix typespec of get_by_id/2.

Pull requests

Full Changelog: v0.36.0...v0.36.1

v0.36.0

01 Mar 21:37
v0.36.0
6fc70d4

Choose a tag to compare

Added

  • Add Floki.get_by_id/1 that returns one element by ID or nil.
    Thanks @SteffenDE.

Changed

  • Improve options validation with Keyword.validate!/2.
    This is not a change in APIs, but the error messages and opts validation should be standardized now.
    Thanks @vittoriabitton.

Removed

  • Drop support for Elixir v1.12.

Pull requests

New Contributors

Full Changelog: v0.35.4...v0.36.0

v0.35.4

20 Feb 02:04
v0.35.4
b66034f

Choose a tag to compare

Fixed

  • Fix regression in the order of elements in Floki.find/2

Pull requests

Full Changelog: v0.35.3...v0.35.4

v0.35.3

25 Jan 20:29
3bdbc28

Choose a tag to compare

This release has great performance improvements, thanks to the PRs
from @ypconstante!

Most of the main functions, such as Floki.raw_html/2 and Floki.find/2 are
faster and are using less memory. It's something like twice as fast, and half
usage of memory for find/2, for example.

Fixed

  • Add :leex to Mix compilers. Fixes the build when running with dev version of Elixir.
    Thanks @wojtekmach.

  • Fix Floki.raw_html/2 when a tree using attributes as maps is given.
    Thanks @SupaMic.

  • Add a guard to Floki.find/2 so people can have a better error message when an
    invalid input is given. Thanks @Hajto.

  • Fix parsers to consider IO data as inputs. This may change in the next version
    of Floki, as I plan to drop support for IO data.
    Thanks @ypconstante.

Removed

  • Remove outdated Gleam wrapper code. The external functions syntax in Gleam
    has changed. So now
    the wrapper is not needed anymore.
    Thanks @michallepicki.

Pull requests

New Contributors

Full Changelog: v0.35.2...v0.35.3