public override BaseState Process(HtmlTokenizer tokenizer, StreamReader reader)
        {
            int c;
            do
            {
                c = Read(reader);
            } while (IsWhitespace(c));

            DocTypeToken token = new DocTypeToken();
            DocTypeNameState.Instance.Token = token;

            if (base.IsUppercaseAsciiLetter(c))
            {
                token.Name = Char.ToLower((char)c).ToString();
                return DocTypeNameState.Instance;
            }

            if (c == 0)
            {
                ReportParseError();
                token.Name = "\uFFFD";
                return DocTypeNameState.Instance;
            }

            if (c == '>')
            {
                ReportParseError();
                token.ForceQuirks = true;
                tokenizer.EmitToken(token);
                return DataState.Instance;
            }

            if (c == -1)
            {
                ReportParseError();
                token.ForceQuirks = true;
                tokenizer.EmitToken(token);
                return DataState.Instance;
                // Parse error. Switch to the data state. Reconsume the EOF character.
            }

            token.Name = ((char)c).ToString();
            return DocTypeNameState.Instance;
        }
예제 #2
0
        public override BaseState Process(HtmlTokenizer tokenizer, StreamReader reader)
        {
            int c = Read(reader);
            if (IsWhitespace(c))
            {
                return BeforeDocTypeNameState.Instance;
            }

            if (c==-1)
            {
                ReportParseError();
                DocTypeToken token = new DocTypeToken() { ForceQuirks = true };
                return DataState.Instance;
                // Parse error. Switch to the data state. Reconsume the EOF character.
            }

            ReportParseError();
            BeforeDocTypeNameState.Instance.LastConsumedCharacters.Enqueue((char)c);
            return BeforeDocTypeNameState.Instance;
        }