Skip to content

v1.0.0

Latest

Choose a tag to compare

@danschultzer danschultzer released this 24 May 14:31
· 2 commits to main since this release

Requires Elixir 1.15 or higher. (55ab43d)

This release contains significant performance improvements, with typical HTML emails seeing a 30x+ speedup when inlining styles. Premailex is also now zero dependency thanks to the new fallback HTML parser Premailex.HTMLParser.Xmerl.

Architecture changes

The layers between parser, DOM operations, and the top-level API have been reshaped:

  • Premailex.HTMLParser is now a thin behaviour with only c:Premailex.HTMLParser.parse/1 and c:Premailex.HTMLParser.to_html/1 callbacks #109
  • Premailex.DOM is a new module that handles all selector matching, traversal, and tree manipulation #109
  • Premailex.Util has been removed with functions moved into Premailex.DOM #109
  • Premailex.HTMLInlineStyles.process/2 is now a pure tree to tree transformation that accepts an explicit list of CSS rules #109

Breaking changes

  • Premailex.HTMLInlineStyles.process/3 no longer exposed, use Premailex.HTMLInlineStyles.process/2 #109
  • Premailex.HTMLToPlainText.process/1 no longer accepts HTML string #109
  • Premailex.HTMLParser behaviour callback to_string renamed to to_html #109
  • Premailex.HTMLParser behaviour no longer requires all, filter, or text callbacks #109
  • Premailex.HTMLParser no longer exposes parse, use Premailex.parse/2 instead #109
  • Premailex.HTMLParser no longer exposes to_string, use Premailex.to_html/2 instead #109
  • Premailex.HTMLParser no longer exposes all, use Premailex.DOM.all/2 instead #109
  • Premailex.HTMLParser no longer exposes filter, use Premailex.DOM.reject/2 instead #109
  • Premailex.HTMLParser no longer exposes text, use Premailex.DOM.text_content/1 instead #109
  • Premailex.Util has been removed:
    • Premailex.Util.traverse/3 is now Premailex.DOM.replace_all_matches/3 #109
    • Premailex.Util.traverse_until_first/3 is now Premailex.DOM.replace_first_match/3 #109
    • Premailex.Util.traverse_reduce/3 is removed, use Premailex.DOM.traverse_with_matching_items/3 for indexed single-walk updates #109
  • Renamed Premailex.CSSParser.parse_rules/1 to Premailex.CSSParser.parse_declaration_block/1 #106
  • Renamed Premailex.CSSParser.merge/1 to Premailex.CSSParser.cascade/1 #109
  • c:Premailex.HTTPAdapter.request/5 callback no longer requires the Premailex.HTTPAdapter.HTTPResponse struct in favor of using a map (83d5566)
  • Premailex.parse/2 now always returns a list #109
  • Floki minimum version bumped from ~> 0.19 to ~> 0.24 #109
  • Premailex.to_inline_css/2 :optimize option has been replaced by a single boolean option :remove_style_tags #109

Additions

  • Added Premailex.parse/2 and Premailex.to_html/2 #109
  • Added support for LazyHTML #101 (thanks @Ch4s3)
  • Added fallback support for :xmerl #104
  • Added Premailex.CSSParser.split_selector_groups/1 for selector group splitting (1403b29)
  • Added Premailex.DOM.traverse_with_matching_items/3 for indexed single-walk tree updates #109
  • Added support for structural pseudo-classes: :first-child, :last-child, :only-child, :last-of-type, :only-of-type, :nth-child, :nth-of-type, :nth-last-child, :nth-last-of-type, :empty, :root (An+B, odd, and even arguments supported) #109

Other

  • Floki is now optional #101
  • Premailex.CSSParser rewritten and no longer uses regular expressions to parse CSS #106
  • Premailex.CSSParser.parse_declaration_block/1 now does case insensitive, terminal !important detection #106
  • Premailex.HTMLInlineStyles.process/2 tree traversal performance changed from O(N^2) to O(N) #107
  • Fixed compiler warnings in Premailex.HTMLParser.Meeseeks #96 (thanks @agatheblues)

Thanks to @meeq for fixing Premailex.HTMLInlineStyles spec in #99.