I have the following CSS class that uses a pseudo-element to insert a line break:
.test-class:after {
content: '\00000a';
white-space: pre;
}
In my ASP.NET web application, this works fine when debugging. However, in release mode, when the CSS file is minified, the content is modified such that '\00000a' becomes '\n'.
This results in the character "n" being visibly rendered on screen, rather than inserting a line break.
I'm aware that a similar problem has been asked previously here:
CSS bundle minification replacing Unicode characters
However, I believe the problem in my case is to do with the minification process itself rather than the page/response content encoding. I say this because in an effort to get to the bottom of the problem, I've created a test IBundleTransform deriving from the built-in CssMinify class that I believe demonstrates that the problem is within the internals of the CssMinify class itself.
Bundle b = new Bundle("~/Content/Test");
b.Include("~/Content/Test.css");
b.Transforms.Add(new CustomMinifier());
bundles.Add(b);
...
public class CustomMinifier : CssMinify
{
public override void Process(BundleContext context, BundleResponse response)
{
base.Process(context, response);
}
}
Sticking a break within the Process method and inspecting response.Contents before and after the call to base.Process reveals the following.
Before
@charset 'utf-8';
.test-class:after {
content: '\00000a';
white-space: pre;
}
After
@charset 'utf-8';.test-class:after{content:'\n';white-space:pre}
Is there anything I can do to work around this behaviour?
Many thanks.