Giter Club home page Giter Club logo

Comments (6)

FlorianRappl avatar FlorianRappl commented on July 30, 2024

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.

mediabuff avatar mediabuff commented on July 30, 2024

Same compliments as for issue #31. Thank you for the fixes.

from anglesharp.

mediabuff avatar mediabuff commented on July 30, 2024

Ok. The fixes seem to work.

from anglesharp.

mediabuff avatar mediabuff commented on July 30, 2024

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.

FlorianRappl avatar FlorianRappl commented on July 30, 2024

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.

FlorianRappl avatar FlorianRappl commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.