Example #1
0
        public override ImportAction Import(dotless.Core.Parser.Tree.Import import)
        {
            // get the current directory we are importing from
            var currentDirectory = _imports.Peek();

            // get the themed file
            import.Path = GetThemedImport(currentDirectory, import.Path);

            // now that we have a new path, get it queued up for future future imports that this new file may have
            _imports.Push(GetDirectory(import.Path));

            // perform the import (and maybe some nested imports)
            var result = base.Import(import);

            // we are done with this directory
            _imports.Pop();

            return result;
        }
Example #2
0
        public override dotless.Core.Parser.Infrastructure.Nodes.Node Execute(dotless.Core.Parser.Infrastructure.Nodes.Node node, out bool visitDeeper)
        {
            visitDeeper = false;
            Root tree = node as Root;
            Comment c = null;
            List<IgnoreCommentMarker> markers = new List<IgnoreCommentMarker>();
            IgnoreCommentMarker marker = null;

            if (tree != null && tree.Rules != null)
            {
                for (int ruleCount = 0; ruleCount < tree.Rules.Count; ruleCount++)
                {
                    c = tree.Rules[ruleCount] as Comment;
                    if (c != null)
                    {
                        if (c.Value == "// start-ignore")
                        {
                            marker = new IgnoreCommentMarker();
                            marker.Start = ruleCount;
                        }
                        if (c.Value == "// end-ignore")
                        {
                            if (marker != null)
                            {
                                marker.End = ruleCount;
                                markers.Add(marker);
                                marker = null;
                            }
                        }
                    }
                }

                foreach (var m in markers)
                {
                    for (int ruleCount = m.Start; ruleCount <= m.End; ruleCount++)
                    {
                        tree.Rules[ruleCount].ForceIgnoreOutput = true;
                    }
                }
            }

            return node;
        }
Example #3
0
 void dotless.Core.Loggers.ILogger.Log(dotless.Core.Loggers.LogLevel level, string message)
 {
     var logger = (dotless.Core.Loggers.ILogger)this;
     switch (level)
     {
         case dotless.Core.Loggers.LogLevel.Error:
             logger.Error(message);
             break;
         case dotless.Core.Loggers.LogLevel.Warn:
             logger.Warn(message);
             break;
         case dotless.Core.Loggers.LogLevel.Info:
             logger.Info(message);
             break;
         case dotless.Core.Loggers.LogLevel.Debug:
             logger.Debug(message);
             break;
         default:
             throw new NotImplementedException(string.Format("The LogLevel has not been implemented. LogLevel: {0}", level));
     }
 }
    public override dotless.Core.Parser.Infrastructure.Nodes.Node Evaluate(dotless.Core.Parser.Infrastructure.Env env)
    {
      if (!string.IsNullOrEmpty(Unit) && !Contains(all_units, Unit))
      {
        env.Logger.Error("Invalid unit: '" + Unit + "'");
      }

      if (!string.IsNullOrEmpty(Unit) && Contains(physical_units, Unit))
      {
        //if (!env.ppi)

        // convert all units to inch
        // convert inch to px using ppi
        if (!"px".Equals(Unit))
        {
          Value = (Value / densities[Unit]) * DPI;
          //m_unit = "px";
        }

        Unit = "";
      }

      return this;
    }
        public override dotless.Core.Parser.Infrastructure.Nodes.Node Execute(dotless.Core.Parser.Infrastructure.Nodes.Node node, out bool visitDeeper)
        {
            visitDeeper = true;

            if (node is Rule)
            {
                var rule = node as Rule;
                if (rule.Variable)
                {
                    if (_variables.ContainsKey(rule.Name.TrimStart(Convert.ToChar("@"))))
                    {
                        var overrideValue = _variables[rule.Name.TrimStart(Convert.ToChar("@"))];
                        if (!string.IsNullOrEmpty(overrideValue))
                        {
                            var parse = new Parser();
                            var ruleset = parse.Parse(rule.Name + ":    " + overrideValue + ";", "variableoverrideplugin.less");
                            return ruleset.Rules[0] as Rule;
                        }
                    }
                }
            }

            return node;
        }
 public void Log(dotless.Core.Loggers.LogLevel level, string message)
 {
     if (level == dotless.Core.Loggers.LogLevel.Error)
     {
         throw new ProcessingException("Failed to execute DotLess processor: " + message);
     }
 }
		public DefaultImporter(dotless.Core.Input.IFileReader fileReader) : base(fileReader) { }
Example #8
0
 dotless.Core.Parser.Tree.Url INodeProvider.Url(dotless.Core.Parser.Infrastructure.Nodes.Node value, IImporter importer, NodeLocation location)
 {
     //ignore the raw imported file path. It is the default behavior in less.js
     return new Url(value);
 }