Comments (6)
To be honest I don't know any more - its been a while since I wrote that one. All I can say is that pseudo elements are currently not supported. Of course the parser should still work for them, but since there is no mechanism for, e.g. having a visual tree that is then modified by a pseudo elements such as before and after, such a mechanism cannot take place. At some point, however, it is obviously desired.
I think that v0.8 will probably not ship with a solution for pseudo elements, but v0.9 will definitely contain some something to deal with them. Maybe you have a good idea how to bring them in efficiently.
from anglesharp.
Same compliments as for issue #31. Thank you for the fixes.
from anglesharp.
Ok. The fixes seem to work.
from anglesharp.
Related Item - Parsing of URL in background in line images - no support. Might be a good addition to convert the following to object model.
eg. .App_Header_ .logo { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEcAAAAcCAMAAAAEJ1IZAAAABGdBTUEAALGPC/xhBQAAVAI/VAI/VAI/VAI/VAI/VAI/VAAAA////AI/VRZ0U8AAAAFJ0Uk5TYNV4S2UbgT/Gk6uQt585w2wGXS0zJO2lhGttJK6j4YqZSobH1AAAAAElFTkSuQmCC"); background-size: 71px 28px; background-position: 0 19px; width: 71px; }
So, I ended doing Regex parsing as follows
public class UrlInlineContent { static Regex regexCssInlineImage = new Regex(@"data:(?.+);(?.+),(?.+)", RegexOptions.CultureInvariant | RegexOptions.Compiled); static Regex regexTrimQuotes = new Regex(@"'(.*?)'", RegexOptions.CultureInvariant | RegexOptions.Compiled); static Regex regexUrls = new Regex( @"url\s*\(" + // Match url, optionally some whitespaces and then ( @"\s*" + // Match optionally some whitespaces @"(""|\'|)" + // It seems that the quotes are optional according to http://www.w3.org/TR/CSS2/syndata.html#uri //\K // Reset the match @"(?![""\']?(?:https?://|ftp://)) " + // Put your negative-rules here (do not match url\'s with http, https or ftp) @"(?(?:[^\\\\]|\\\\.)*? )" + // Match anything except a backslash or backslash and a character zero or more times ungreedy @"(?= " + // Lookahead @"\1" + // Match what was matched in group 2 @"\s*" + // Match optionally some whitespaces @"\)" + // Match ) @")", RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace); public string mimeType; public string encodeType; public byte[] content; public string extension; static public IEnumerable GetUrls(string source) { return regexUrls.Matches(source).Cast().Select(url => url.Groups["urlContent"].Value); } static public UrlInlineContent GetContent(string url) { var ui = new UrlInlineContent(); var groups = regexCssInlineImage.Match(url).Groups; ui.mimeType = groups["mimeType"].Value; ui.encodeType = groups["encodeType"].Value; if (ui.encodeType == "base64") { var contentBase64 = groups["content"].Value; ui.content = Convert.FromBase64String(contentBase64); ui.extension = '.' + ui.mimeType.Split('/')[1]; } return ui; } static public string TrimQuotes(string text) { return regexTrimQuotes.Match(text).Groups[1].Value; } }
from anglesharp.
Hm that URL should be supported already, since the argument of the url
function will be passed on to an Url
constructor, which I think should be also designed for base64 data URLs. I will look into that.
from anglesharp.
Alright I think I get what you are missing (since parsing seems to work, unit test is ok): You want the URL to be exposed! That is actually planned. Right now I still expose an old value model, that will be removed in one of the next versions. Then a much better variant that is only accessible via C# will be available (since JS only relies on strings - which is why the W3C marked the former specification obsolete).
from anglesharp.
Related Issues (20)
- Redirect to Custom URL Scheme HOT 2
- Issues with Headers HOT 2
- Use libraries provided by framework HOT 3
- Provide repo link as part of nuget package HOT 8
- QuerySelectorAll problem HOT 1
- SemVer scheme in AngleSharp -alpha versions broken HOT 1
- Multipart/form-data support HOT 1
- IndexOutOfRangeException in AngleSharp.Common.ArrayPoolBuffer.Append HOT 1
- Getting Attributes for each Element HOT 1
- InvalidOperationException: Stack empty in AngleSharp.Html.Parser.HtmlDomBuilder HOT 1
- Attributes in Elements HOT 3
- Parser Issue Findings from Fuzzing HOT 4
- Additional Findings from Fuzzing HOT 3
- NullReferenceException when using own HttpClient HOT 1
- How to Change the Accept header in DocumentRequest HOT 1
- Link element source not loaded when element is appended to document
- AngleSharp 1.2.0-beta.410 can not be loaded in .Net Framework because of System.Memory version error HOT 3
- obsolete reference HOT 2
- Digitally Sign AngleSharp NuGet Package Assemblies HOT 1
- DomGeometry Support HOT 3
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 anglesharp.