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.HTMLParseris now a thin behaviour with onlyc:Premailex.HTMLParser.parse/1andc:Premailex.HTMLParser.to_html/1callbacks #109Premailex.DOMis a new module that handles all selector matching, traversal, and tree manipulation #109Premailex.Utilhas been removed with functions moved intoPremailex.DOM#109Premailex.HTMLInlineStyles.process/2is now a pure tree to tree transformation that accepts an explicit list of CSS rules #109
Breaking changes
Premailex.HTMLInlineStyles.process/3no longer exposed, usePremailex.HTMLInlineStyles.process/2#109Premailex.HTMLToPlainText.process/1no longer accepts HTML string #109Premailex.HTMLParserbehaviour callbackto_stringrenamed toto_html#109Premailex.HTMLParserbehaviour no longer requiresall,filter, ortextcallbacks #109Premailex.HTMLParserno longer exposesparse, usePremailex.parse/2instead #109Premailex.HTMLParserno longer exposesto_string, usePremailex.to_html/2instead #109Premailex.HTMLParserno longer exposesall, usePremailex.DOM.all/2instead #109Premailex.HTMLParserno longer exposesfilter, usePremailex.DOM.reject/2instead #109Premailex.HTMLParserno longer exposestext, usePremailex.DOM.text_content/1instead #109Premailex.Utilhas been removed:- Renamed
Premailex.CSSParser.parse_rules/1toPremailex.CSSParser.parse_declaration_block/1#106 - Renamed
Premailex.CSSParser.merge/1toPremailex.CSSParser.cascade/1#109 c:Premailex.HTTPAdapter.request/5callback no longer requires thePremailex.HTTPAdapter.HTTPResponsestruct in favor of using a map (83d5566)Premailex.parse/2now always returns a list #109Flokiminimum version bumped from~> 0.19to~> 0.24#109Premailex.to_inline_css/2:optimizeoption has been replaced by a single boolean option:remove_style_tags#109
Additions
- Added
Premailex.parse/2andPremailex.to_html/2#109 - Added support for
LazyHTML#101 (thanks @Ch4s3) - Added fallback support for
:xmerl#104 - Added
Premailex.CSSParser.split_selector_groups/1for selector group splitting (1403b29) - Added
Premailex.DOM.traverse_with_matching_items/3for 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, andevenarguments supported) #109
Other
Flokiis now optional #101Premailex.CSSParserrewritten and no longer uses regular expressions to parse CSS #106Premailex.CSSParser.parse_declaration_block/1now does case insensitive, terminal!importantdetection #106Premailex.HTMLInlineStyles.process/2tree 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.