HTML2Text - extract readable plain text from HTML using Rust NIF

HTML2Text provides a simple and efficient way to extract readable plain text from HTML content. It leverages the power of Rust’s html2text crate to deliver fast HTML parsing and text extraction while maintaining the logical structure and readability of the content.

9 Likes

html2text v0.2.0 released — breaking changes and a cleaner API!

This version introduces a new, more consistent API with proper error handling and an optional keyword list for configuration.


What changed

Before (v0.1.x):

HTML2Text.convert(html, width)
# => returns plain string
  • The second argument was required and only accepted a width (integer or :infinity)
  • Errors (like width too narrow) would raise directly

Now (v0.2.0):

HTML2Text.convert(html, opts)
# => {:ok, result} | {:error, reason}

HTML2Text.convert!(html, opts)
# => result (raises on error)
  • convert/2 now returns {:ok, text} or {:error, reason}
  • convert!/2 is a new function that raises on error (for convenience)
  • The second parameter is now an optional keyword list of options
1 Like