HTMLEntities 4.0.0

I wrapped up and released a new version of HTMLEntities last night.
The version number has inflated to 4.0.0 to reflect some significant
changes in the interface.

What is it?

HTMLEntities is a simple library to facilitate encoding and decoding
of named (ý and so on) or numerical ({ or Ī)
entities in HTML and XHTML documents.

What’s changed?

This update has many requested improvements and fixes:

  • Now understands all the entities referred to in the XHTML 1.0 DTD
    (253 entities compared with 131 in version 3.0.1).
  • Calls to_s on parameters to play nicely with Rails 1.2.1.
  • Entity mapping data is now lazily loaded.
  • New instantiation-based interface (but legacy interface is preserved
    for compatibility).
  • Handles HTML4 as well as XHTML1 (the former lacks the ' entity).
  • Encodes basic entities numerically when :basic isn’t specified and
    :decimal or :hexadecimal is.
  • Performs a maximum of two gsub passes instead of three when
    encoding, which should be more efficient on long strings.

What about existing code?

Using HTMLEntities already? You probably don’t need to change
anything. The old syntax still works, although it should be considered
deprecated. However, HTMLEntities is now a class instead of a module,
so if you have been including HTMLEntities and calling the methods
directly, you’ll need to make a few changes.

Learn more

Examples and documentation are available at
http://htmlentities.rubyforge.org/

Get it

gem install htmlentities

Or grab a tarball here:
http://rubyforge.org/frs/?group_id=1462

Credits

Thanks to Dallas DeVries, Johan Duflost, Paul W., Marcos Kuhns and
Jaime I. for bug reports and feature requests.