You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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:
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 ::Nokogiri::HTML() but rather to the .to_html() method, as in: @processed_doc.to_html(:encoding => @options[:output_encoding], save_with: @options[:nokogiri_html_options])
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: