예제 #1
0
        internal Element InsertEmpty(Token.StartTag startTag)
        {
            Tag     tag = Tag.ValueOf(startTag.Name());
            Element el  = new Element(tag, baseUri, startTag.attributes);

            InsertNode(el);
            if (startTag.IsSelfClosing())
            {
                if (tag.IsKnown)
                {
                    if (tag.IsSelfClosing)
                    {
                        tokeniser.AcknowledgeSelfClosingFlag();
                    }
                }
                else
                {
                    // if not acked, promulagates error
                    // unknown tag, remember this is self closing for output
                    tag.SetSelfClosing();
                    tokeniser.AcknowledgeSelfClosingFlag();
                }
            }
            // not an distinct error
            return(el);
        }
예제 #2
0
파일: Tokeniser.cs 프로젝트: wushian/dcsoup
 internal void Emit(Token token)
 {
     Validate.IsFalse(isEmitPending, "There is an unread token pending!");
     emitPending   = token;
     isEmitPending = true;
     if (token.type == TokenType.StartTag)
     {
         Token.StartTag startTag = (Token.StartTag)token;
         lastStartTag = startTag;
         if (startTag.selfClosing)
         {
             selfClosingFlagAcknowledged = false;
         }
     }
     else
     {
         if (token.type == TokenType.EndTag)
         {
             Token.EndTag endTag = (Token.EndTag)token;
             if (endTag.attributes != null)
             {
                 Error("Attributes incorrectly present on end tag");
             }
         }
     }
 }
예제 #3
0
        internal FormElement InsertForm(Token.StartTag startTag, bool onStack)
        {
            Tag         tag = Tag.ValueOf(startTag.Name());
            FormElement el  = new FormElement(tag, baseUri, startTag.attributes);

            SetFormElement(el);
            InsertNode(el);
            if (onStack)
            {
                stack.AddLast(el);
            }
            return(el);
        }
예제 #4
0
        internal Element Insert(Token.StartTag startTag)
        {
            // handle empty unknown tags
            // when the spec expects an empty tag, will directly hit insertEmpty, so won't generate this fake end tag.
            if (startTag.IsSelfClosing())
            {
                Element el = InsertEmpty(startTag);
                stack.AddLast(el);
                tokeniser.Transition(TokeniserState.Data);
                // handles <script />, otherwise needs breakout steps from script data
                tokeniser.Emit(new Token.EndTag(el.TagName));
                // ensure we get out of whatever state we are in. emitted for yielded processing
                return(el);
            }
            Tag     tag  = Tag.ValueOf(startTag.Name());
            Element el_1 = new Element(tag, baseUri, startTag.attributes);

            Insert(el_1);
            return(el_1);
        }
예제 #5
0
        internal 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.IsKnown)
                {
                    // unknown tag, remember this is self closing for output. see above.
                    tag.SetSelfClosing();
                }
            }
            else
            {
                stack.AddLast(el);
            }
            return(el);
        }
예제 #6
0
파일: Tokeniser.cs 프로젝트: bkzhn/dcsoup
 internal void Emit(Token token)
 {
     Validate.IsFalse(isEmitPending, "There is an unread token pending!");
     emitPending = token;
     isEmitPending = true;
     if (token.type == TokenType.StartTag)
     {
         Token.StartTag startTag = (Token.StartTag)token;
         lastStartTag = startTag;
         if (startTag.selfClosing)
         {
             selfClosingFlagAcknowledged = false;
         }
     }
     else
     {
         if (token.type == TokenType.EndTag)
         {
             Token.EndTag endTag = (Token.EndTag)token;
             if (endTag.attributes != null)
             {
                 Error("Attributes incorrectly present on end tag");
             }
         }
     }
 }