-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option for disabling "pretty printing" of html part #345
Comments
You should create specs on all of supported adapters (:nokogiri, :nokogiri_fast, :nokogumbo). |
Unfortunately I haven't had time to work on this, but I will create specs for all those adaptors once I do complete implementation. Note to self: the Nokogiri save options should not be passed at |
It's simple as [:nokogiri, :nokogiri_fast, :nokogumbo].each do |adapter|
# instantiate
end Specs like that are common. |
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 towhite-space: pre-wrap;
this causes extra whitespace in the mail. The specific line that causes the "pretty printing" ispremailer-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 usesDEFAULT_HTML
save options, which includesFORMAT
. 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
.I plan on making a pull request for this soon, creating this issue to ensure that I'm not missing something. I've perused all the current options, and it doesn't seem like there's any other way to overcome this. I guess one can create an interceptor that strips new lines before sending the mail, but it feels like a dirty workaround.
The text was updated successfully, but these errors were encountered: