示例#1
0
 public HamlNodeHtmlAttribute(HamlSourceFileMetrics metrics, string nameValuePair)
     : base(metrics, nameValuePair)
 {
     int index = 0;
     ParseName(ref index);
     ParseValue(index);
 }
        public HamlNodeHtmlAttributeCollection(HamlSourceFileMetrics metrics, string attributeCollection)
            : base(metrics, attributeCollection)
        {
            if (Content[0] != '(' && Content[0] != '{')
                throw new HamlParserMalformedTagException("AttributeCollection tag must start with an opening bracket or curly bracket.", Metrics);

            ParseChildren(attributeCollection);
        }
示例#3
0
 public HamlNodeTextContainer(HamlSourceFileMetrics metrics, string content)
     : base(metrics, content)
 {
     if (string.IsNullOrEmpty(content))
         AddChild(new HamlNodeTextLiteral(Metrics.SubSpan(0, 0), content));
     else
         ParseFragments(content);
 }
示例#4
0
 public HamlLine(string content, HamlRuleEnum hamlRule, HamlSourceFileMetrics metrics = null, string indent = "", bool isInline = false)
 {
     Metrics = metrics ?? new HamlSourceFileMetrics(0, -1, content.Length, 0);
     Content = content;
     Indent = isInline ? "" : indent;
     IndentCount = IsBlankLine(content, hamlRule)
         ? 0
         : GetIndentCount(indent);
     HamlRule = hamlRule;
     IsInline = isInline;
 }
示例#5
0
        public static IEnumerable<HamlLine> ParseHamlLine(string currentLine, int currentLineIndex)
        {
            int whiteSpaceIndex = 0;

            while (whiteSpaceIndex < currentLine.Length
                && (currentLine[whiteSpaceIndex] == ' ' || currentLine[whiteSpaceIndex] == '\t'))
            {
                whiteSpaceIndex++;
            }

            string indent = currentLine.Substring(0, whiteSpaceIndex);
            string content = (whiteSpaceIndex == currentLine.Length) ? "" : currentLine.Substring(whiteSpaceIndex);
            int tokenLength = 0;
            var hamlRule = HamlRuleFactory.ParseHamlRule(ref content, out tokenLength);

            var metrics = new HamlSourceFileMetrics(currentLineIndex, whiteSpaceIndex, currentLine.Length - whiteSpaceIndex, tokenLength);
            var result = new List<HamlLine>();
            var line = new HamlLine(content, hamlRule, metrics, indent, false);

            ProcessInlineTags(line, result);
            return result;
        }
 private HamlInvalidChildNodeException(Type nodeType, Type childType, HamlSourceFileMetrics lineNo, Exception ex)
     : base(string.Format("Node '{0}' has invalid child node {1} at {2}", nodeType.FullName, childType.FullName, lineNo), ex)
 {
 }
示例#7
0
 public HamlNodeTagClass(HamlSourceFileMetrics metrics, string className)
     : base(metrics, className)
 {
 }
示例#8
0
 private static void ProcessInlineTags(HamlLine line, List<HamlLine> result)
 {
     if (IsRuleThatAllowsInlineContent(line.HamlRule))
     {
         int contentIndex = GetEndOfTagIndex('%' + line.Content)-1;
         if (contentIndex < line.Content.Length-1)
         {
             string subTag = line.Content.Substring(contentIndex);
             line.Content = line.Content.Substring(0, contentIndex);
             int tokenLength;
             var subTagRule = HamlRuleFactory.ParseHamlRule(ref subTag, out tokenLength);
             var colNo = contentIndex + line.Metrics.TokenLength;
             var metrics = new HamlSourceFileMetrics(line.Metrics.LineNo,
                 line.Metrics.ColNo + colNo, line.Metrics.Length - colNo, tokenLength);
             var subLine = new HamlLine(subTag, subTagRule, metrics, line.Indent + "\t", isInline: true);
             ProcessInlineTags(subLine, result);
         }
     }
     result.Insert(0, line);
 }
 public HamlUnknownNodeTypeException(Type nodeType, HamlSourceFileMetrics metrics)
     : this(nodeType, metrics, null)
 {
 }
示例#10
0
 public HamlNodeWalkerException(string hamlNodeType, HamlSourceFileMetrics metrics, Exception e)
     : base(string.Format("Exception occurred walking {0} HamlNode at {1}.", hamlNodeType, metrics),
         e)
 {
 }
示例#11
0
 public HamlParserUnknownRuleException(string ruleValue, HamlSourceFileMetrics metrics)
     : this(ruleValue, metrics, null)
 {
 }
示例#12
0
 private HamlParserUnknownRuleException(string ruleValue, HamlSourceFileMetrics metrics, Exception ex)
     : base(string.Format("Unknown rule '{0}' at {1}", ruleValue, metrics), ex)
 {
 }
示例#13
0
 public HamlNodeTextVariable(HamlSourceFileMetrics metrics, string content)
     : base(metrics, content)
 {
 }
 public HamlInvalidChildNodeException(Type nodeType, Type childType, HamlSourceFileMetrics lineNo)
     : this(nodeType, childType, lineNo, null)
 {
 }
示例#15
0
 public HamlNodeTextLiteral(HamlSourceFileMetrics metrics, string content)
     : base(metrics, content)
 {
 }
示例#16
0
 public HamlNodeTagId(HamlSourceFileMetrics metrics, string tagId)
     : base(metrics, tagId)
 {
 }
 private HamlUnknownNodeTypeException(Type nodeType, HamlSourceFileMetrics metrics, Exception ex)
     : base(string.Format("Unknown node type '{0}' at {1}", nodeType.FullName, metrics), ex)
 {
 }