Exemple #1
0
        private void ParseAttributes(string content, ref int pos)
        {
            if (pos >= content.Length)
            {
                return;
            }

            char attributeEndChar = HtmlStringHelper.GetAttributeTerminatingChar(content[pos]);

            if (attributeEndChar != '\0')
            {
                string attributes = HtmlStringHelper.ExtractTokenFromTagString(content, ref pos,
                                                                               new[] { attributeEndChar });
                if (attributes[attributes.Length - 1] != attributeEndChar)
                {
                    throw new HamlMalformedTagException(
                              "Malformed HTML Attributes collection \"" + attributes + "\".", SourceFileLineNum);
                }
                var attribCollection = new HamlNodeHtmlAttributeCollection(SourceFileLineNum, attributes);

                foreach (var attribute in attribCollection.Children.OfType <HamlNodeHtmlAttribute>().OrderBy(n => n.Name))
                {
                    _attributes.Add(attribute);
                }

                pos++;
            }
        }
Exemple #2
0
        private void ParseName(ref int index)
        {
            string result = HtmlStringHelper.ExtractTokenFromTagString(Content, ref index, new[] { '=', '\0' });

            if (string.IsNullOrEmpty(result))
            {
                throw new HamlMalformedTagException("Malformed HTML attribute \"" + Content + "\"", SourceFileLineNum);
            }

            _name = result.TrimEnd('=');
        }
Exemple #3
0
        private static string ParseName(ref int index, string content, int lineNumber)
        {
            string result = HtmlStringHelper.ExtractTokenFromTagString(content, ref index, new[] { ':', '\0' });

            if (string.IsNullOrEmpty(result))
            {
                throw new HamlMalformedTagException("Malformed HTML attribute \"" + content + "\"", lineNumber);
            }

            return(result.TrimEnd(':').TrimStart(' '));
        }
Exemple #4
0
        private static string GetNextAttributeToken(string attributeCollection, char closingBracketChar, ref int index)
        {
            var    terminatingChars = new[] { ',', ' ', '\t', closingBracketChar };
            string nameValuePair    = HtmlStringHelper.ExtractTokenFromTagString(attributeCollection, ref index,
                                                                                 terminatingChars);

            if (terminatingChars.Contains(nameValuePair[nameValuePair.Length - 1]))
            {
                nameValuePair = nameValuePair.Substring(0, nameValuePair.Length - 1);
            }
            return(nameValuePair);
        }
Exemple #5
0
        private void ParseAttributes(string content, ref int pos)
        {
            if (pos >= content.Length)
            {
                return;
            }

            char attributeEndChar = HtmlStringHelper.GetAttributeTerminatingChar(content[pos]);

            if (attributeEndChar != '\0')
            {
                string attributes = HtmlStringHelper.ExtractTokenFromTagString(content, ref pos,
                                                                               new[] { attributeEndChar });
                if (attributes[attributes.Length - 1] != attributeEndChar)
                {
                    throw new HamlMalformedTagException(
                              "Malformed HTML Attributes collection \"" + attributes + "\".", SourceFileLineNum);
                }
                AddChild(new HamlNodeHtmlAttributeCollection(SourceFileLineNum, attributes));

                pos++;
            }
        }