コード例 #1
0
        protected override void ParseImport(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.String || stream.Current.Type == TokenType.BadString)
            {
                Filename = itemFactory.CreateSpecificParsed <StringValue>(this, text, stream);
                if (Filename != null)
                {
                    Children.Add(Filename);
                }
            }
            else if (UrlItem.IsUrl(text, stream.Current))
            {
                var url = new UrlItem();
                if (url.Parse(itemFactory, text, stream))
                {
                    Url = url;
                    Children.Add(url);
                }
            }

            while (!IsTerminator(stream.Current.Type))
            {
                var query = new MediaQuery();
                if (!query.Parse(itemFactory, text, stream))
                {
                    break;
                }

                _MediaQueries.Add(query);
                Children.Add(query);
            }
        }
コード例 #2
0
        protected override void ParseImport(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.String || stream.Current.Type == TokenType.BadString)
            {
                Filename = itemFactory.CreateSpecificParsed<StringValue>(this, text, stream);
                if (Filename != null)
                    Children.Add(Filename);
            }
            else if (UrlItem.IsUrl(text, stream.Current))
            {
                var url = new UrlItem();
                if (url.Parse(itemFactory, text, stream))
                {
                    Url = url;
                    Children.Add(url);
                }
            }

            while (!IsTerminator(stream.Current.Type))
            {
                var query = new MediaQuery();
                if (!query.Parse(itemFactory, text, stream))
                    break;

                _MediaQueries.Add(query);
                Children.Add(query);
            }
        }
コード例 #3
0
ファイル: ItemFactory.cs プロジェクト: obedurena/SassyStudio
        private ParseItem CreateImport(ComplexItem parent, ITextProvider text, ITokenStream stream)
        {
            var filename = stream.Peek(2);

            // if doing @import url() then we use standard css import
            if (UrlItem.IsUrl(text, filename))
            {
                return(new CssImportDirective());
            }

            if ((filename.Type == TokenType.String || filename.Type == TokenType.BadString))
            {
                // check to see if import starts with http(s)://
                var preamble = text.GetText(filename.Start, 9).Trim('"', '\'');
                if (preamble.StartsWith("//") || preamble.StartsWith("http://") || preamble.StartsWith("https://"))
                {
                    return(new CssImportDirective());
                }

                // check for media query
                var next = stream.Peek(3);
                if (next.Type == TokenType.Identifier)
                {
                    return(new CssImportDirective());
                }

                // check if we are importing actual css file
                if (text.GetText(filename.Start, filename.Length).Trim('"', '\'').EndsWith(".css"))
                {
                    return(new CssImportDirective());
                }
            }

            // since we didn't detect that it's a css import, use the sass import
            return(new SassImportDirective());
        }