Option for disabling "pretty printing" of html part
AnrichVS opened this issue · comments
Some of the mails I send contain user submitted content that was created by Quill editor. Quill editor relies on the white-space: pre-wrap;
CSS property to preserve tabs and multiple spaces, see this.
The to_inline_css
method(premailer-1.10.3/lib/premailer/adapter/nokogiri.rb:12
) causes "pretty printing" of the html that is returned, meaning that newlines are created. Due to white-space: pre-wrap;
this causes extra whitespace in the mail. The specific line that causes the "pretty printing" is premailer-1.10.3/lib/premailer/adapter/nokogiri.rb:224
. This line does: doc = ::Nokogiri::HTML(thing, nil, @options[:input_encoding] || default_encoding) { |c| c.recover }
, NokogiriL::HTML uses DEFAULT_HTML
save options, which includes FORMAT
. See this.
To overcome this, this can be done:
doc = ::Nokogiri::HTML(thing, nil, @options[:input_encoding] || default_encoding, Nokogiri::XML::Node::SaveOptions::DEFAULT_HTML ^ Nokogiri::XML::Node::SaveOptions::FORMAT) { |c| c.recover }
Preferably that would be a option, which can then be passed through via @options
.
This describes the issue, and I'll make a pull request for this if I find time.
The specific line that causes the "pretty printing" is
premailer-1.10.3/lib/premailer/adapter/nokogiri.rb:224
.
That's in the premailer gem. This sounds like it should be an option in premailer, not premailer-rails.