Comments (8)
Can you debug and find out the string passed to AngleSharp´s QuerySelectorAll
method, in FindElementsWithStyles
when it fails?
As a workaround now, use the v1.4.3
tag - the current version on Nu Get, which uses the old HTML parser instead of AngleSharp introduced in #76.
from premailer.net.
The string passed was @Keyframes progress-bar-stripes, i found that the error is when the selector starts with @, i added the next validation to the method FindElementsWithStyles.
foreach (var style in stylesToApply)
{
if (!style.Value.Name.StartsWith("@"))
{
var elementsForSelector = _document.QuerySelectorAll(style.Value.Name);
foreach (var el in elementsForSelector)
{
var existing = result.ContainsKey(el) ? result[el] : new List<StyleClass>();
existing.Add(style.Value);
result[el] = existing;
}
}
}
Now it is working.
from premailer.net.
@martinnormark You said in #78 that you're waiting on this issue to be sorted before a NuGet release with the new AngelSharp. Is there any idea when this will be? I'm actually getting the same issue as #9 and I'm hoping the AngelSharp switch will fix this.
from premailer.net.
Have you tried verifying using current master branch, and writing a test case for it?
Haven't looked further into a general way of solving this issue yet.
from premailer.net.
I have downloaded bootstrap from here https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css to my C drive and have added the next test case to PreMailerTests.cs to reproduce the error.
public void MoveCssInline_BootstrapFramework()
{
string input = "<html lang=\"en\"><head></head><body><div class=\"container\"><form class=\"form-signin\"><h2 class=\"form-signin-heading\">Please sign in</h2><label for=\"inputEmail\" class=\"sr-only\">Email address</label><input type=\"email\" id=\"inputEmail\" class=\"form-control\" placeholder=\"Email address\" required=\"\" autofocus=\"\"><label for=\"inputPassword\" class=\"sr-only\">Password</label><input type=\"password\" id=\"inputPassword\" class=\"form-control\" placeholder=\"Password\" required=\"\"><div class=\"checkbox\"><label><input type=\"checkbox\" value=\"remember-me\"> Remember me</label></div><button class=\"btn btn-lg btn-primary btn-block\" type=\"submit\">Sign in</button></form></div> <!-- /container --></body></html>";
string bootstrapFrameworkContent = File.ReadAllText("C:\\bootstrap.min.css");
var premailedOutput = PreMailer.MoveCssInline(input, css: bootstrapFrameworkContent);
Assert.IsTrue(premailedOutput.Html.Contains("<html lang=\"en\">"));
}
from premailer.net.
@arbh89 Is that method to test #9? Or for this issue? I'll see if I can find some time to write up a test case if not (although I'm crazy busy at the minute).
from premailer.net.
This issue. There's a comment with markup to test #9 in that issue: #9 (comment)
from premailer.net.
As a catch all, I've wrapped querying DOM elements by CSS selector in a try-catch block, adding to the warnings array of the result the failed selectors.
For this particular issue, note that even the minified Bootstrap CSS is a 118 KB footprint in every email you sent.
Currently PreMailer does not parse a keyframe
block correctly, since each percentage step within will become their own selector. It should probably identify blocks such as this as unsupported selectors, and force it into the actual style
block of the email so that animations will work - regardless of the removeStyleElements
flag.
from premailer.net.
Related Issues (20)
- MoveCssInline returns self-closing title when empty HOT 5
- MoveCssInline encodes non-ASCII characters even when they should be valid HTML
- Regex in CssParser never ends and uses 100% cpu. HOT 1
- url embedded resources HOT 2
- Request to change colors defined with hsl/hsla to rgb/rgba HOT 1
- Anchor tags should be appended after analytics tags
- Performance issue when process email containing useless big Style tag to small body content HOT 1
- MoveCssInline is HTML encoding CSS HOT 2
- Inliner strips out vml from html tag HOT 1
- Configure continuous benchmark
- Add more example HTML emails to benchmark
- Automate contributors list in README
- Resolve css var's with their actual values?
- Ability to specify which classes should not be removed, like "preheader"
- How to keep html entities (such as ©) from being converted to special characters? HOT 3
- Are you looking for maintainers? HOT 23
- RobiniaDocs API Explorer
- Bug in comment regex, fix in issue description HOT 1
- Two same CSS properties on same dom element does not work HOT 3
- Bump the AngleSharp Version to 1.1.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from premailer.net.