Esempio n. 1
0
 public bool IsAppropriateEndTagToken()
 {
     if (_lastStartTag == null)
     {
         return(false);
     }
     return(_tagPending.Name().Equals(_lastStartTag.Name()));
 }
Esempio n. 2
0
        public Element Insert(Token.StartTag startTag)
        {
            // handle empty unknown tags
            // when the spec expects an empty tag, will directly hit insertEmpty, so won't generate fake end tag.
            if (startTag.IsSelfClosing && !Tag.IsKnownTag(startTag.Name()))
            {
                Element el = InsertEmpty(startTag);
                Process(new Token.EndTag(el.TagName())); // ensure we get out of whatever state we are in
                return(el);
            }

            Element element = new Element(Tag.ValueOf(startTag.Name()), _baseUri, startTag.Attributes);

            Insert(element);
            return(element);
        }
Esempio n. 3
0
        public Element InsertEmpty(Token.StartTag startTag)
        {
            Tag     tag = Tag.ValueOf(startTag.Name());
            Element el  = new Element(tag, _baseUri, startTag.Attributes);

            InsertNode(el);
            if (startTag.IsSelfClosing)
            {
                _tokeniser.AcknowledgeSelfClosingFlag();
                if (!tag.IsKnownTag()) // unknown tag, remember this is self closing for output
                {
                    tag.SetSelfClosing();
                }
            }
            return(el);
        }
Esempio n. 4
0
        Element Insert(Token.StartTag startTag)
        {
            Tag tag = Tag.ValueOf(startTag.Name());
            // todo: wonder if for xml parsing, should treat all tags as unknown? because it's not html.
            Element el = new Element(tag, _baseUri, startTag.Attributes);

            InsertNode(el);
            if (startTag.IsSelfClosing)
            {
                _tokeniser.AcknowledgeSelfClosingFlag();
                if (!tag.IsKnownTag()) // unknown tag, remember this is self closing for output. see above.
                {
                    tag.SetSelfClosing();
                }
            }
            else
            {
                _stack.AddLast(el);
            }
            return(el);
        }