Exemplo n.º 1
0
        public INode Parse(HtmlParser parser, HtmlPortion current)
        {
            if (!IsStyle(current))
            {
                return(null);
            }

            var attr         = parser.GetAttribute(current);
            var end          = current.StartIndexOf(new Regex(@"</style\s*>"));
            var contentIndex = end - current.Current;

            current.Next();
            var content = current.Substring(contentIndex);

            current.Jump(contentIndex);
            if (attr.IsSingle)
            {
                return(new StyleTag("<style", attr.Attributes, "", _info));
            }
            var result = new StyleTag("style", attr.Attributes, content, _info);

            current.Jump(current.IndexOf(new Regex(@"</style\s*>")));
            current.Jump();
            return(result);
        }
Exemplo n.º 2
0
        public INode Parse(HtmlParser parser, HtmlPortion current)
        {
            if (current.IsStartTagChar() && current.IsNext('!'))
            {
                var text = current.Substring(' ');
                var t    = text.ToLower() == "<!doctype ";
                if (t)
                {
                    var index = current.IndexOf('>');
                    current.Jump(index);
                    current.Next();
                    return(new DocumentTypeTag());
                }
            }

            return(null);
        }
Exemplo n.º 3
0
 private static int GetEndSingleIndex(HtmlPortion portion)
 {
     return(portion.IndexOf(new Regex(@"^\s*/>")));
 }
Exemplo n.º 4
0
 private static bool IsEnd(HtmlPortion portion)
 {
     return(portion.IndexOf(new Regex(@"^\s*>")) >= 0);
 }