예제 #1
0
        //public string Compile(string source)
        //{
        //    using (var sourceStream = new MemoryStream(Encoding.UTF8.GetBytes(source)))
        //    using (var destination = new MemoryStream())
        //    {
        //        Compile(sourceStream, destination);
        //        return Encoding.UTF8.GetString(destination.ToArray());
        //    }
        //}
        public void Compile(PathFile source, Stream destination)
        {
            var tree = TreeFromFile(source);
            var sheet = new CssSheet();

            ProcessTree(tree, sheet);

            using (var writer = new CssWriter(destination))
            {
                writer.Write(sheet);
            }
        }
예제 #2
0
 private void ProcessTree(ScssPackage tree, CssSheet sheet)
 {
     ProcessScope(tree, tree, sheet, null, -1);
     ProcessExtensions(tree, sheet);
 }
예제 #3
0
 internal void Write(CssSheet sheet)
 {
     WriteSheet(sheet);
     //this.Write(_lineBreak);
 }
예제 #4
0
        private void WriteSheet(CssSheet sheet)
        {
            var lastLevel = -1;
            foreach (var node in sheet.Nodes)
            {
                if (node is CssSelector)
                {
                    //Ignore empty selector nodes
                    if (!node.Nodes.Any())
                        continue;

                    lastLevel = WriteSelector(lastLevel, (CssSelector) node);
                }
                else if (node is CssComment)
                {
                    WriteComment((CssComment) node);
                }
                else if (node is CssMedia)
                {
                    WriteMedia(lastLevel, (CssMedia) node);
                }
                else if (node is CssImport)
                {
                    WriteImport((CssImport) node);
                }

                Write(_lineBreak);
            }
        }