Inlined stylesheet is incorrectly encoded
dlouzan opened this issue · comments
Hello, I'm working on an MR in gitlab for migrating some of the mailers to use premailer for html emails but I'm having an issue where premailer is entity encoding some of my stylesheet rules when I inline them.
I've tried this with several premailer-rails versions, including the latest release 1.10.3.
There's some stylesheet rules that I need to inline in the header of the html email (particularly using the @media
tag that seems not properly supported by premailer). One of them includes a direct descendant rule, and premailer is entity-encoding it to >
in the inlined style, even if I tell premailer to ignore it:
%style{ type: 'text/css', 'data-premailer': 'ignore' }
= asset_to_string('mailer_client_specific.css').html_safe
def asset_to_string(name)
app = Rails.application
if Rails.configuration.assets.compile
app.assets.find_asset(name).to_s
else
controller.view_context.render(file: File.join('public/assets', app.assets_manifest.assets[name]))
end
end
mailer_client_specific.css
has a rule like:
table.wrapper > tbody > tr > td {
...
}
And this is incorrectly generated by premailer in the final html as:
table.wrapper > tbody > tr > td {
...
}
As soon as I remove premailer processing this works as intended:
mail(bcc: recipients,
subject: pipeline_subject(status),
skip_premailer: true) do |format|
...
You can take a look at our code in https://gitlab.com/gitlab-org/gitlab/merge_requests/17699
Any ideas? is this a bug in premailer or am I doing anything wrong? Thanks!
The inspiration for inlining the stylesheet was taken from:
This seems to be the same as premailer/premailer#353, sadly no answer in that ticket since 2017 :-(
Closing this as this is clearly an issue on premailer's side. Thanks for reporting though!