private HtmlTag ParseTag()
{
HtmlTag tag = this.ParseBlocks();
if (tag != null)
{
return tag;
}
int i = 1;
char ch = this.Peek(i);
if (ch == EndTagChar)
{
i++;
ch = this.Peek(i);
}
if (!IsNameStartChar(ch))
{
// not a tag, treat as LessThan char
return null;
}
while (IsNameChar(ch))
{
i++;
ch = this.Peek(i);
}
if (!Char.IsWhiteSpace(ch) &&
ch != EndTagChar &&
ch != CloseTagChar)
{
// not a tag, treat as LessThan char
return null;
}
// remove tag open char
this.EmptyBuffer(1);
tag = new HtmlTag(this.FlushBuffer(i-1), this.htmlFilter);
this.ParseSyncPoint();
this.ParseAttributes(tag);
if (this.Current == CloseTagChar)
{
// remove GreaterThan char from source
this.EmptyBuffer(1);
}
return tag;
}