Exemple #1
0
 public void Run()
 {
     if (!endOfFile)
     {
         HtmlTokenId htmlTokenId = parser.Parse();
         if (htmlTokenId != HtmlTokenId.None)
         {
             Process(htmlTokenId);
         }
     }
 }
Exemple #2
0
 public override void Run()
 {
     if (!base.EndOfFile)
     {
         HtmlTokenId htmlTokenId = this.parser.Parse();
         if (htmlTokenId != HtmlTokenId.None)
         {
             this.Process(htmlTokenId);
         }
     }
 }
Exemple #3
0
 // Token: 0x060013C2 RID: 5058 RVA: 0x0008B9CC File Offset: 0x00089BCC
 public void Run()
 {
     if (!this.endOfFile)
     {
         HtmlTokenId htmlTokenId = this.parser.Parse();
         if (htmlTokenId != HtmlTokenId.None)
         {
             this.Process(htmlTokenId);
         }
     }
 }
        public void Run()
        {
            if (!this.endOfFile)
            {
                HtmlTokenId tokenId = this.parser.Parse();

                if (HtmlTokenId.None != tokenId)
                {
                    this.Process(tokenId);
                }
            }
        }
Exemple #5
0
        internal void WriteMarkupTextTo(ITextSink sink)
        {
            if (this.state == HtmlReader.State.BeginTag)
            {
                this.state = HtmlReader.State.ReadTag;
            }
            else if (this.state != HtmlReader.State.SpecialTag && this.state != HtmlReader.State.ReadTag && this.state != HtmlReader.State.Text)
            {
                this.AssertInToken();
                if (this.state > HtmlReader.State.BeginTag)
                {
                    throw new InvalidOperationException("Cannot read tag content as markup text after accessing tag name or attributes");
                }
                throw new InvalidOperationException("Reader must be positioned on Text, StartTag, EndTag, EmptyElementTag or SpecialTag token");
            }
            for (;;)
            {
                this.parserToken.Text.WriteOriginalTo(sink);
                if (this.state == HtmlReader.State.SpecialTag)
                {
                    if (this.parserToken.IsTagEnd)
                    {
                        break;
                    }
                }
                else if (this.state == HtmlReader.State.ReadTag)
                {
                    if (this.parserToken.IsTagEnd)
                    {
                        goto Block_9;
                    }
                }
                else
                {
                    HtmlTokenId htmlTokenId = this.PreviewNextToken();
                    if (htmlTokenId != HtmlTokenId.Text && (!this.literalTags || htmlTokenId != HtmlTokenId.Tag || this.nextParserToken.TagIndex >= HtmlTagIndex.Unknown))
                    {
                        goto IL_CD;
                    }
                }
                this.ParseToken();
            }
            this.state = HtmlReader.State.EndSpecialTag;
            return;

Block_9:
            this.state = HtmlReader.State.EndTag;
            return;

IL_CD:
            this.state = HtmlReader.State.EndText;
        }
Exemple #6
0
        public int ReadText(char[] buffer, int offset, int count)
        {
            if (this.state == HtmlReader.State.EndText)
            {
                return(0);
            }
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (offset > buffer.Length || offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", TextConvertersStrings.OffsetOutOfRange);
            }
            if (count > buffer.Length || count < 0)
            {
                throw new ArgumentOutOfRangeException("count", TextConvertersStrings.CountOutOfRange);
            }
            if (count + offset > buffer.Length)
            {
                throw new ArgumentOutOfRangeException("count", TextConvertersStrings.CountTooLarge);
            }
            if (this.state != HtmlReader.State.Text)
            {
                this.AssertInToken();
                throw new InvalidOperationException("Reader must be positioned on a Text token");
            }
            int num = 0;

            while (count != 0)
            {
                int num2 = this.parserToken.Text.Read(buffer, offset, count);
                if (num2 == 0)
                {
                    HtmlTokenId htmlTokenId = this.PreviewNextToken();
                    if (htmlTokenId != HtmlTokenId.Text && (!this.literalTags || htmlTokenId != HtmlTokenId.Tag || this.nextParserToken.TagIndex >= HtmlTagIndex.Unknown))
                    {
                        this.state = HtmlReader.State.EndText;
                        break;
                    }
                    this.ParseToken();
                    this.parserToken.Text.Rewind();
                }
                else
                {
                    offset += num2;
                    count  -= num2;
                    num    += num2;
                }
            }
            return(num);
        }
Exemple #7
0
 internal void WriteTextTo(ITextSink sink)
 {
     if (this.state != HtmlReader.State.Text)
     {
         this.AssertInToken();
         throw new InvalidOperationException("Reader must be positioned on a Text token");
     }
     for (;;)
     {
         this.parserToken.Text.WriteTo(sink);
         HtmlTokenId htmlTokenId = this.PreviewNextToken();
         if (htmlTokenId != HtmlTokenId.Text && (!this.literalTags || htmlTokenId != HtmlTokenId.Tag || this.nextParserToken.TagIndex >= HtmlTagIndex.Unknown))
         {
             break;
         }
         this.ParseToken();
     }
     this.state = HtmlReader.State.EndText;
 }
 public HtmlTokenId MakeEmptyToken(HtmlTokenId tokenId)
 {
     return((HtmlTokenId)base.MakeEmptyToken((TokenId)tokenId));
 }
 public HtmlTokenId MakeEmptyToken(HtmlTokenId tokenId, int argument)
 {
     return((HtmlTokenId)base.MakeEmptyToken((TokenId)tokenId, argument));
 }
Exemple #10
0
        private void Process(HtmlTokenId tokenId)
        {
            var token = parser.Token;

            switch (tokenId)
            {
            case HtmlTokenId.Tag:



                if (token.IsTagBegin)
                {
                    switch (token.TagIndex)
                    {
                    case HtmlTagIndex.Title:


                        break;

                    case HtmlTagIndex.Comment:
                    case HtmlTagIndex.Script:
                    case HtmlTagIndex.Style:

                        insideComment = !token.IsEndTag;
                        break;

                    case HtmlTagIndex.A:

                        if (outputAnchorLinks)
                        {
                            insideAnchor = !token.IsEndTag;
                            if (!token.IsEndTag)
                            {
                            }
                            else
                            {
                            }
                        }
                        break;

                    case HtmlTagIndex.Base:
                    case HtmlTagIndex.BaseFont:
                    case HtmlTagIndex.BGSound:
                    case HtmlTagIndex.Link:
                    case HtmlTagIndex.FrameSet:
                    case HtmlTagIndex.Frame:
                    case HtmlTagIndex.Iframe:


                        break;

                    case HtmlTagIndex.Map:
                    case HtmlTagIndex.Div:
                    case HtmlTagIndex.P:
                    case HtmlTagIndex.H1:
                    case HtmlTagIndex.H2:
                    case HtmlTagIndex.H3:
                    case HtmlTagIndex.H4:
                    case HtmlTagIndex.H5:
                    case HtmlTagIndex.H6:
                    case HtmlTagIndex.Center:
                    case HtmlTagIndex.BlockQuote:
                    case HtmlTagIndex.Address:
                    case HtmlTagIndex.Marquee:
                    case HtmlTagIndex.BR:

                    case HtmlTagIndex.HR:

                    case HtmlTagIndex.Form:
                    case HtmlTagIndex.FieldSet:
                    case HtmlTagIndex.OptGroup:
                    case HtmlTagIndex.Select:
                    case HtmlTagIndex.Option:

                    case HtmlTagIndex.OL:
                    case HtmlTagIndex.UL:
                    case HtmlTagIndex.Dir:
                    case HtmlTagIndex.Menu:
                    case HtmlTagIndex.LI:
                    case HtmlTagIndex.DL:
                    case HtmlTagIndex.DT:
                    case HtmlTagIndex.DD:

                    case HtmlTagIndex.Table:
                    case HtmlTagIndex.Caption:
                    case HtmlTagIndex.ColGroup:
                    case HtmlTagIndex.Col:
                    case HtmlTagIndex.Tbody:
                    case HtmlTagIndex.Thead:
                    case HtmlTagIndex.Tfoot:
                    case HtmlTagIndex.TR:
                    case HtmlTagIndex.TC:

                    case HtmlTagIndex.Pre:
                    case HtmlTagIndex.PlainText:
                    case HtmlTagIndex.Listing:

                        collapseWhitespaceState = CollapseWhitespaceState.NewLine;
                        break;

                    case HtmlTagIndex.TH:
                    case HtmlTagIndex.TD:

                        if (!token.IsEndTag)
                        {
                            output.Write("\t");
                        }
                        break;


                    case HtmlTagIndex.NoEmbed:
                    case HtmlTagIndex.NoFrames:

                        insideComment = !token.IsEndTag;
                        break;
                    }
                }



                switch (token.TagIndex)
                {
                case HtmlTagIndex.A:

                    if (!token.IsEndTag && outputAnchorLinks)
                    {
                    }
                    break;

                case HtmlTagIndex.Area:

                    if (!token.IsEndTag && outputAnchorLinks)
                    {
                    }
                    break;

                case HtmlTagIndex.Img:
                case HtmlTagIndex.Image:

                    if (!token.IsEndTag && outputAnchorLinks)
                    {
                    }
                    break;
                }

                break;



            case HtmlTokenId.Text:

                if (!insideComment)
                {
                    token.Text.WriteToAndCollapseWhitespace(output, ref collapseWhitespaceState);
                }
                break;



            case HtmlTokenId.OverlappedClose:
            case HtmlTokenId.OverlappedReopen:

                break;



            case HtmlTokenId.Restart:

                break;



            case HtmlTokenId.EncodingChange:

                var encodingOutput = output as ConverterEncodingOutput;
                if (encodingOutput != null)
                {
                    var codePage = token.Argument;

                    if (encodingOutput.CodePageSameAsInput)
                    {
                            #if DEBUG
                        Encoding newOutputEncoding;

                        InternalDebug.Assert(Charset.TryGetEncoding(codePage, out newOutputEncoding));
                            #endif


                        encodingOutput.Encoding = Charset.GetEncoding(codePage);
                    }
                }
                break;



            case HtmlTokenId.EndOfFile:

                output.Write("\r\n");
                output.Flush();

                endOfFile = true;
                break;
            }
        }
        // Token: 0x060013EC RID: 5100 RVA: 0x0008DCE8 File Offset: 0x0008BEE8
        protected override void Process(HtmlTokenId tokenId)
        {
            this.token = this.parser.Token;
            switch (tokenId)
            {
            case HtmlTokenId.EndOfFile:
                base.CloseAllContainersAndSetEOF();
                break;

            case HtmlTokenId.Text:
                if (this.insideStyle)
                {
                    this.OutputEncapsulatedMarkup();
                    this.token.Text.WriteTo(this.cssParserInput);
                    return;
                }
                if (this.insideComment)
                {
                    this.OutputEncapsulatedMarkup();
                    return;
                }
                if (this.insidePre)
                {
                    base.ProcessPreformatedText();
                    return;
                }
                base.ProcessText();
                return;

            case HtmlTokenId.EncodingChange:
                if (this.output != null && this.output.OutputCodePageSameAsInput)
                {
                    this.output.OutputEncoding = this.token.TokenEncoding;
                    return;
                }
                break;

            case HtmlTokenId.Tag:
                this.OutputEncapsulatedMarkup();
                if (this.token.TagIndex <= HtmlTagIndex.Unknown)
                {
                    if (this.insideStyle && this.token.TagIndex == HtmlTagIndex._COMMENT)
                    {
                        this.token.Text.WriteTo(this.cssParserInput);
                        return;
                    }
                }
                else
                {
                    HtmlDtd.TagDefinition tagDefinition = HtmlFormatConverter.GetTagDefinition(this.token.TagIndex);
                    if (!this.token.IsEndTag)
                    {
                        if (this.token.IsTagBegin)
                        {
                            base.PushElement(tagDefinition, this.token.IsEmptyScope);
                        }
                        base.ProcessStartTagAttributes(tagDefinition);
                        return;
                    }
                    if (this.token.IsTagEnd)
                    {
                        base.PopElement(this.BuildStackTop - 1 - this.temporarilyClosedLevels, this.token.Argument != 1);
                        return;
                    }
                }
                break;

            case HtmlTokenId.Restart:
                break;

            case HtmlTokenId.OverlappedClose:
                this.temporarilyClosedLevels = this.token.Argument;
                return;

            case HtmlTokenId.OverlappedReopen:
                this.temporarilyClosedLevels = 0;
                return;

            default:
                return;
            }
        }
 public HtmlTokenId MakeEmptyToken(HtmlTokenId tokenId, Encoding tokenEncoding)
 {
     return((HtmlTokenId)base.MakeEmptyToken((TokenId)tokenId, tokenEncoding));
 }
Exemple #13
0
        private void Process(HtmlTokenId tokenId)
        {
            token = parser.Token;
            switch (tokenId)
            {
            case HtmlTokenId.EndOfFile:
                if (lineStarted)
                {
                    output.OutputNewLine();
                    lineStarted = false;
                }
                if (!convertFragment)
                {
                    if (injection != null && injection.HaveHead)
                    {
                        if (wideGap)
                        {
                            output.OutputNewLine();
                            wideGap = false;
                        }
                        injection.Inject(false, output);
                    }
                    output.CloseDocument();
                    output.Flush();
                }
                endOfFile = true;
                break;

            case HtmlTokenId.Text:
                if (!insideComment)
                {
                    if (insideAnchor && urlCompareSink.IsActive)
                    {
                        token.Text.WriteTo(urlCompareSink);
                    }
                    if (insidePre)
                    {
                        ProcessPreformatedText();
                        return;
                    }
                    if (normalizedInput)
                    {
                        ProcessText();
                        return;
                    }
                    NormalizeProcessText();
                    return;
                }
                break;

            case HtmlTokenId.EncodingChange:
                if (output.OutputCodePageSameAsInput)
                {
                    int argument = token.Argument;
                    output.OutputEncoding = Charset.GetEncoding(argument);
                    return;
                }
                break;

            case HtmlTokenId.Tag:
            {
                if (token.TagIndex <= HtmlTagIndex.Unknown)
                {
                    return;
                }
                HtmlDtd.TagDefinition tagDefinition = GetTagDefinition(token.TagIndex);
                if (normalizedInput)
                {
                    if (!token.IsEndTag)
                    {
                        if (token.IsTagBegin)
                        {
                            PushElement(tagDefinition);
                        }
                        ProcessStartTagAttributes(tagDefinition);
                        return;
                    }
                    if (token.IsTagBegin)
                    {
                        PopElement(tagDefinition);
                        return;
                    }
                }
                else
                {
                    if (!token.IsEndTag)
                    {
                        if (token.IsTagBegin)
                        {
                            LFillTagB(tagDefinition);
                            PushElement(tagDefinition);
                            RFillTagB(tagDefinition);
                        }
                        ProcessStartTagAttributes(tagDefinition);
                        return;
                    }
                    if (token.IsTagBegin)
                    {
                        LFillTagE(tagDefinition);
                        PopElement(tagDefinition);
                        RFillTagE(tagDefinition);
                        return;
                    }
                }
                break;
            }

            case HtmlTokenId.Restart:
            case HtmlTokenId.OverlappedClose:
            case HtmlTokenId.OverlappedReopen:
                break;

            default:
                return;
            }
        }
Exemple #14
0
        private void Process(HtmlTokenId tokenId)
        {
            this.token = this.parser.Token;
            switch (tokenId)
            {
            case HtmlTokenId.EndOfFile:
                if (this.injection != null)
                {
                    bool haveHead = this.injection.HaveHead;
                }
                base.CloseAllContainersAndSetEOF();
                if (this.output != null)
                {
                    this.output.Flush();
                }
                break;

            case HtmlTokenId.Text:
                if (!this.insideParam)
                {
                    this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                    this.OutputText(this.token);
                    return;
                }
                if (this.tagPendingParameter != HtmlNameIndex._NOTANAME)
                {
                    this.scratch.AppendTokenText(this.token, 256);
                    return;
                }
                break;

            case HtmlTokenId.EncodingChange:
                if (this.output != null && this.output.OutputCodePageSameAsInput)
                {
                    this.output.OutputEncoding = this.token.TokenEncoding;
                    return;
                }
                break;

            case HtmlTokenId.Tag:
                if (this.token.IsTagBegin)
                {
                    if (this.token.IsEndTag)
                    {
                        if (this.token.NameIndex == HtmlNameIndex.Param)
                        {
                            if (this.insideParam)
                            {
                                HtmlNameIndex htmlNameIndex = this.tagPendingParameter;
                                if (htmlNameIndex <= HtmlNameIndex.ParaIndent)
                                {
                                    if (htmlNameIndex != HtmlNameIndex.Color)
                                    {
                                        if (htmlNameIndex == HtmlNameIndex.ParaIndent)
                                        {
                                            BufferString bufferString = this.scratch.BufferString;
                                            bufferString.TrimWhitespace();
                                            int num  = 0;
                                            int num2 = 0;
                                            int num3 = 0;
                                            int num4 = 0;
                                            int num6;
                                            for (int num5 = 0; num5 != bufferString.Length; num5 = num6)
                                            {
                                                int i = num5;
                                                num6 = num5;
                                                while (i < bufferString.Length)
                                                {
                                                    if (bufferString[i] == ',')
                                                    {
                                                        break;
                                                    }
                                                    i++;
                                                    num6++;
                                                }
                                                while (i > num5 && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(bufferString[i - 1])))
                                                {
                                                    i--;
                                                }
                                                if (num6 < bufferString.Length)
                                                {
                                                    do
                                                    {
                                                        num6++;
                                                    }while (num6 < bufferString.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(bufferString[num6])));
                                                }
                                                BufferString bufferString2 = bufferString.SubString(num5, i - num5);
                                                if (bufferString2.EqualsToLowerCaseStringIgnoreCase("left"))
                                                {
                                                    num++;
                                                }
                                                else if (bufferString2.EqualsToLowerCaseStringIgnoreCase("right"))
                                                {
                                                    num2++;
                                                }
                                                else if (bufferString2.EqualsToLowerCaseStringIgnoreCase("in"))
                                                {
                                                    num3++;
                                                }
                                                else if (bufferString2.EqualsToLowerCaseStringIgnoreCase("out"))
                                                {
                                                    num4++;
                                                }
                                            }
                                            if (num + num4 != 0)
                                            {
                                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.LeftPadding, new PropertyValue(LengthUnits.Points, 30 * (num + num4) - ((this.indentLevel == 0) ? 12 : 0)));
                                            }
                                            if (num3 - num4 != 0)
                                            {
                                                if (num3 - num4 > 0)
                                                {
                                                    base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FirstLineIndent, new PropertyValue(LengthUnits.Points, 30 * (num3 - num4) - ((this.indentLevel == 0 && num + num4 == 0) ? 12 : 0)));
                                                }
                                                else
                                                {
                                                    base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FirstLineIndent, new PropertyValue(LengthUnits.Points, 30 * (num3 - num4) + ((this.indentLevel == 0 && num4 - num3 == num + num4) ? 12 : 0)));
                                                }
                                            }
                                            if (num2 != 0)
                                            {
                                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.RightPadding, new PropertyValue(LengthUnits.Points, 30 * num2));
                                            }
                                            if (num + num4 != 0 && this.indentLevel == 0)
                                            {
                                                this.indentLevel++;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        PropertyValue value = HtmlSupport.ParseColor(this.scratch.BufferString, true, false);
                                        if (value.IsColor)
                                        {
                                            if (value.Color.Red > 250U && value.Color.Green > 250U && value.Color.Blue > 250U)
                                            {
                                                value = new PropertyValue(PropertyType.Color, 14737632U);
                                            }
                                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontColor, value);
                                        }
                                    }
                                }
                                else if (htmlNameIndex != HtmlNameIndex.Excerpt)
                                {
                                    if (htmlNameIndex != HtmlNameIndex.Lang)
                                    {
                                        if (htmlNameIndex == HtmlNameIndex.FontFamily)
                                        {
                                            PropertyValue value = HtmlSupport.ParseFontFace(this.scratch.BufferString, this);
                                            if (!value.IsNull)
                                            {
                                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontFace, value);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        PropertyValue value = HtmlSupport.ParseLanguage(this.scratch.BufferString, null);
                                        if (!value.IsNull)
                                        {
                                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.Language, value);
                                        }
                                    }
                                }
                                this.insideParam = false;
                            }
                        }
                        else if (this.token.NameIndex != HtmlNameIndex.Unknown)
                        {
                            if (this.token.NameIndex == HtmlNameIndex.ParaIndent && this.indentLevel != 0)
                            {
                                this.indentLevel--;
                            }
                            base.CloseContainer(this.token.NameIndex);
                        }
                        this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                        return;
                    }
                    HtmlNameIndex nameIndex = this.token.NameIndex;
                    if (nameIndex <= HtmlNameIndex.ParaIndent)
                    {
                        if (nameIndex <= HtmlNameIndex.Param)
                        {
                            if (nameIndex == HtmlNameIndex.Nofill)
                            {
                                base.OpenContainer(FormatContainerType.Block, false, 2, base.GetStyle(14), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;
                            }
                            if (nameIndex == HtmlNameIndex.FlushRight)
                            {
                                base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.TextAlignment, new PropertyValue(TextAlign.Right));
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;
                            }
                            if (nameIndex == HtmlNameIndex.Param)
                            {
                                this.insideParam = true;
                                this.scratch.Reset();
                                return;
                            }
                        }
                        else if (nameIndex <= HtmlNameIndex.Italic)
                        {
                            if (nameIndex == HtmlNameIndex.Color)
                            {
                                base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex.Color;
                                return;
                            }
                            if (nameIndex == HtmlNameIndex.Italic)
                            {
                                base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(4), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;
                            }
                        }
                        else
                        {
                            switch (nameIndex)
                            {
                            case HtmlNameIndex.Center:
                                base.OpenContainer(FormatContainerType.Block, false, 2, base.GetStyle(13), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;

                            case HtmlNameIndex.Height:
                                break;

                            case HtmlNameIndex.Underline:
                                base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(5), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;

                            case HtmlNameIndex.FlushBoth:
                                base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.TextAlignment, new PropertyValue(TextAlign.Justify));
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;

                            default:
                                if (nameIndex == HtmlNameIndex.ParaIndent)
                                {
                                    base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                                    this.tagPendingParameter = HtmlNameIndex.ParaIndent;
                                    if (this.indentLevel != 0)
                                    {
                                        this.indentLevel++;
                                        return;
                                    }
                                    return;
                                }
                                break;
                            }
                        }
                    }
                    else if (nameIndex <= HtmlNameIndex.FlushLeft)
                    {
                        if (nameIndex == HtmlNameIndex.Fixed)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(10), this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                        if (nameIndex == HtmlNameIndex.Smaller)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontSize, new PropertyValue(PropertyType.RelHtmlFontUnits, -1));
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                        switch (nameIndex)
                        {
                        case HtmlNameIndex.Bold:
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(1), this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;

                        case HtmlNameIndex.FlushLeft:
                            base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.TextAlignment, new PropertyValue(TextAlign.Left));
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                    }
                    else if (nameIndex <= HtmlNameIndex.Lang)
                    {
                        if (nameIndex == HtmlNameIndex.Excerpt)
                        {
                            base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.QuotingLevelDelta, new PropertyValue(PropertyType.Integer, 1));
                            this.tagPendingParameter = HtmlNameIndex.Excerpt;
                            return;
                        }
                        if (nameIndex == HtmlNameIndex.Lang)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(6), this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex.Lang;
                            return;
                        }
                    }
                    else
                    {
                        if (nameIndex == HtmlNameIndex.Bigger)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontSize, new PropertyValue(PropertyType.RelHtmlFontUnits, 1));
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                        if (nameIndex == HtmlNameIndex.FontFamily)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex.FontFamily;
                            return;
                        }
                    }
                    this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                    return;
                }
                break;

            case HtmlTokenId.Restart:
            case HtmlTokenId.OverlappedClose:
            case HtmlTokenId.OverlappedReopen:
                break;

            default:
                return;
            }
        }
        // Token: 0x0600139B RID: 5019 RVA: 0x00089DF8 File Offset: 0x00087FF8
        private void Process(HtmlTokenId tokenId)
        {
            this.token = this.parser.Token;
            switch (tokenId)
            {
            case HtmlTokenId.EndOfFile:
                if (this.injection != null && this.injection.HaveTail)
                {
                    if (!this.output.LineEmpty)
                    {
                        this.output.OutputNewLine();
                    }
                    this.injection.Inject(false, this.output);
                }
                this.output.CloseDocument();
                this.output.Flush();
                this.endOfFile = true;
                break;

            case HtmlTokenId.Text:
                if (!this.insideParam)
                {
                    this.OutputText(this.token);
                    return;
                }
                break;

            case HtmlTokenId.EncodingChange:
                if (this.output.OutputCodePageSameAsInput)
                {
                    this.output.OutputEncoding = this.token.TokenEncoding;
                    return;
                }
                break;

            case HtmlTokenId.Tag:
                if (this.token.IsTagBegin)
                {
                    HtmlNameIndex nameIndex = this.token.NameIndex;
                    if (nameIndex <= HtmlNameIndex.ParaIndent)
                    {
                        if (nameIndex <= HtmlNameIndex.Param)
                        {
                            if (nameIndex != HtmlNameIndex.Nofill && nameIndex != HtmlNameIndex.FlushRight)
                            {
                                if (nameIndex != HtmlNameIndex.Param)
                                {
                                    return;
                                }
                                this.insideParam = !this.token.IsEndTag;
                                return;
                            }
                        }
                        else if (nameIndex <= HtmlNameIndex.Italic)
                        {
                            if (nameIndex != HtmlNameIndex.Color && nameIndex != HtmlNameIndex.Italic)
                            {
                                return;
                            }
                            break;
                        }
                        else
                        {
                            switch (nameIndex)
                            {
                            case HtmlNameIndex.Center:
                            case HtmlNameIndex.FlushBoth:
                                break;

                            case HtmlNameIndex.Height:
                            case HtmlNameIndex.Underline:
                                return;

                            default:
                                if (nameIndex != HtmlNameIndex.ParaIndent)
                                {
                                    return;
                                }
                                break;
                            }
                        }
                    }
                    else if (nameIndex <= HtmlNameIndex.FlushLeft)
                    {
                        if (nameIndex == HtmlNameIndex.Fixed || nameIndex == HtmlNameIndex.Smaller)
                        {
                            break;
                        }
                        switch (nameIndex)
                        {
                        case HtmlNameIndex.Bold:
                        case HtmlNameIndex.Strike:
                            return;

                        case HtmlNameIndex.FlushLeft:
                            break;

                        default:
                            return;
                        }
                    }
                    else if (nameIndex <= HtmlNameIndex.Lang)
                    {
                        if (nameIndex == HtmlNameIndex.Excerpt)
                        {
                            if (!this.output.LineEmpty)
                            {
                                this.output.OutputNewLine();
                            }
                            if (!this.token.IsEndTag)
                            {
                                this.quotingLevel++;
                            }
                            else
                            {
                                this.quotingLevel--;
                            }
                            this.output.SetQuotingLevel(this.quotingLevel);
                            return;
                        }
                        if (nameIndex != HtmlNameIndex.Lang)
                        {
                            return;
                        }
                        break;
                    }
                    else
                    {
                        if (nameIndex != HtmlNameIndex.Bigger && nameIndex != HtmlNameIndex.FontFamily)
                        {
                            return;
                        }
                        break;
                    }
                    if (!this.output.LineEmpty)
                    {
                        this.output.OutputNewLine();
                        return;
                    }
                }
                break;

            case HtmlTokenId.Restart:
            case HtmlTokenId.OverlappedClose:
            case HtmlTokenId.OverlappedReopen:
                break;

            default:
                return;
            }
        }
Exemple #16
0
        // Token: 0x060013C5 RID: 5061 RVA: 0x0008BA64 File Offset: 0x00089C64
        private void Process(HtmlTokenId tokenId)
        {
            HtmlToken token = this.parser.Token;

            switch (tokenId)
            {
            case HtmlTokenId.EndOfFile:
                this.output.Write("\r\n");
                this.output.Flush();
                this.endOfFile = true;
                break;

            case HtmlTokenId.Text:
                if (!this.insideComment)
                {
                    token.Text.WriteToAndCollapseWhitespace(this.output, ref this.collapseWhitespaceState);
                    return;
                }
                break;

            case HtmlTokenId.EncodingChange:
            {
                ConverterEncodingOutput converterEncodingOutput = this.output as ConverterEncodingOutput;
                if (converterEncodingOutput != null && converterEncodingOutput.CodePageSameAsInput)
                {
                    converterEncodingOutput.Encoding = token.TokenEncoding;
                    return;
                }
                break;
            }

            case HtmlTokenId.Tag:
            {
                if (token.IsTagBegin)
                {
                    switch (token.TagIndex)
                    {
                    case HtmlTagIndex.A:
                        if (!token.IsEndTag)
                        {
                        }
                        break;

                    case HtmlTagIndex.Address:
                    case HtmlTagIndex.BlockQuote:
                    case HtmlTagIndex.BR:
                    case HtmlTagIndex.Caption:
                    case HtmlTagIndex.Center:
                    case HtmlTagIndex.Col:
                    case HtmlTagIndex.ColGroup:
                    case HtmlTagIndex.DD:
                    case HtmlTagIndex.Dir:
                    case HtmlTagIndex.Div:
                    case HtmlTagIndex.DL:
                    case HtmlTagIndex.DT:
                    case HtmlTagIndex.FieldSet:
                    case HtmlTagIndex.Form:
                    case HtmlTagIndex.H1:
                    case HtmlTagIndex.H2:
                    case HtmlTagIndex.H3:
                    case HtmlTagIndex.H4:
                    case HtmlTagIndex.H5:
                    case HtmlTagIndex.H6:
                    case HtmlTagIndex.HR:
                    case HtmlTagIndex.LI:
                    case HtmlTagIndex.Listing:
                    case HtmlTagIndex.Map:
                    case HtmlTagIndex.Marquee:
                    case HtmlTagIndex.Menu:
                    case HtmlTagIndex.OL:
                    case HtmlTagIndex.OptGroup:
                    case HtmlTagIndex.Option:
                    case HtmlTagIndex.P:
                    case HtmlTagIndex.PlainText:
                    case HtmlTagIndex.Pre:
                    case HtmlTagIndex.Select:
                    case HtmlTagIndex.Table:
                    case HtmlTagIndex.Tbody:
                    case HtmlTagIndex.TC:
                    case HtmlTagIndex.Tfoot:
                    case HtmlTagIndex.Thead:
                    case HtmlTagIndex.TR:
                    case HtmlTagIndex.UL:
                        this.collapseWhitespaceState = CollapseWhitespaceState.NewLine;
                        break;

                    case HtmlTagIndex.Comment:
                    case HtmlTagIndex.Script:
                    case HtmlTagIndex.Style:
                        this.insideComment = !token.IsEndTag;
                        break;

                    case HtmlTagIndex.NoEmbed:
                    case HtmlTagIndex.NoFrames:
                        this.insideComment = !token.IsEndTag;
                        break;

                    case HtmlTagIndex.TD:
                    case HtmlTagIndex.TH:
                        if (!token.IsEndTag)
                        {
                            this.output.Write("\t");
                        }
                        break;
                    }
                }
                HtmlTagIndex tagIndex = token.TagIndex;
                if (tagIndex != HtmlTagIndex.A)
                {
                    if (tagIndex != HtmlTagIndex.Area)
                    {
                        switch (tagIndex)
                        {
                        case HtmlTagIndex.Image:
                        case HtmlTagIndex.Img:
                            if (!token.IsEndTag)
                            {
                                return;
                            }
                            break;

                        default:
                            return;
                        }
                    }
                    else if (!token.IsEndTag)
                    {
                        return;
                    }
                }
                else if (!token.IsEndTag)
                {
                    return;
                }
                break;
            }

            case HtmlTokenId.Restart:
            case HtmlTokenId.OverlappedClose:
            case HtmlTokenId.OverlappedReopen:
                break;

            default:
                return;
            }
        }
Exemple #17
0
        public int ReadMarkupText(char[] buffer, int offset, int count)
        {
            if (this.state == HtmlReader.State.EndTag || this.state == HtmlReader.State.EndSpecialTag || this.state == HtmlReader.State.EndText)
            {
                return(0);
            }
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (offset > buffer.Length || offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", TextConvertersStrings.OffsetOutOfRange);
            }
            if (count > buffer.Length || count < 0)
            {
                throw new ArgumentOutOfRangeException("count", TextConvertersStrings.CountOutOfRange);
            }
            if (count + offset > buffer.Length)
            {
                throw new ArgumentOutOfRangeException("count", TextConvertersStrings.CountTooLarge);
            }
            if (this.state == HtmlReader.State.BeginTag)
            {
                this.state = HtmlReader.State.ReadTag;
            }
            else if (this.state != HtmlReader.State.SpecialTag && this.state != HtmlReader.State.ReadTag && this.state != HtmlReader.State.Text)
            {
                this.AssertInToken();
                if (this.state > HtmlReader.State.BeginTag)
                {
                    throw new InvalidOperationException("Cannot read tag content as markup text after accessing tag name or attributes");
                }
                throw new InvalidOperationException("Reader must be positioned on Text, StartTag, EndTag, EmptyElementTag or SpecialTag token");
            }
            int num = 0;

            while (count != 0)
            {
                int num2 = this.parserToken.Text.ReadOriginal(buffer, offset, count);
                if (num2 == 0)
                {
                    if (this.state == HtmlReader.State.SpecialTag)
                    {
                        if (this.parserToken.IsTagEnd)
                        {
                            this.state = HtmlReader.State.EndSpecialTag;
                            break;
                        }
                    }
                    else if (this.state == HtmlReader.State.ReadTag)
                    {
                        if (this.parserToken.IsTagEnd)
                        {
                            this.state = HtmlReader.State.EndTag;
                            break;
                        }
                    }
                    else
                    {
                        HtmlTokenId htmlTokenId = this.PreviewNextToken();
                        if (htmlTokenId != HtmlTokenId.Text && (!this.literalTags || htmlTokenId != HtmlTokenId.Tag || this.nextParserToken.TagIndex >= HtmlTagIndex.Unknown))
                        {
                            this.state = HtmlReader.State.EndText;
                            break;
                        }
                    }
                    this.ParseToken();
                    this.parserToken.Text.Rewind();
                }
                else
                {
                    offset += num2;
                    count  -= num2;
                    num    += num2;
                }
            }
            return(num);
        }
        private void Process(HtmlTokenId tokenId)
        {
            this.token = this.parser.Token;

            switch (tokenId)
            {
            case HtmlTokenId.Tag:

                if (this.token.TagIndex <= HtmlTagIndex.Unknown)
                {
                    break;
                }

                HtmlDtd.TagDefinition tagDef = GetTagDefinition(this.token.TagIndex);

                if (this.normalizedInput)
                {
                    if (!this.token.IsEndTag)
                    {
                        if (this.token.IsTagBegin)
                        {
                            this.PushElement(tagDef);
                        }

                        this.ProcessStartTagAttributes(tagDef);
                    }
                    else
                    {
                        if (this.token.IsTagBegin)
                        {
                            this.PopElement(tagDef);
                        }
                    }
                }
                else
                {
                    if (!this.token.IsEndTag)
                    {
                        if (this.token.IsTagBegin)
                        {
                            this.LFillTagB(tagDef);
                            this.PushElement(tagDef);
                            this.RFillTagB(tagDef);
                        }

                        this.ProcessStartTagAttributes(tagDef);
                    }
                    else
                    {
                        if (this.token.IsTagBegin)
                        {
                            this.LFillTagE(tagDef);
                            this.PopElement(tagDef);
                            this.RFillTagE(tagDef);
                        }
                    }
                }
                break;



            case HtmlTokenId.Text:

                if (!this.insideComment)
                {
                    if (this.insideAnchor && this.urlCompareSink.IsActive)
                    {
                        token.Text.WriteTo(this.urlCompareSink);
                    }

                    if (this.insidePre)
                    {
                        this.ProcessPreformatedText();
                    }
                    else if (this.normalizedInput)
                    {
                        this.ProcessText();
                    }
                    else
                    {
                        this.NormalizeProcessText();
                    }
                }
                break;



            case HtmlTokenId.OverlappedClose:
            case HtmlTokenId.OverlappedReopen:

                break;



            case HtmlTokenId.Restart:

                break;



            case HtmlTokenId.EncodingChange:

                if (this.output.OutputCodePageSameAsInput)
                {
                    int codePage = this.token.Argument;

                        #if DEBUG
                    Encoding newOutputEncoding;

                    InternalDebug.Assert(Charset.TryGetEncoding(codePage, out newOutputEncoding));
                        #endif



                    this.output.OutputEncoding = Charset.GetEncoding(codePage);
                }

                break;



            case HtmlTokenId.EndOfFile:

                if (this.lineStarted)
                {
                    this.output.OutputNewLine();
                    this.lineStarted = false;
                }

                if (!this.convertFragment)
                {
                    if (this.injection != null && this.injection.HaveHead)
                    {
                        if (this.wideGap)
                        {
                            this.output.OutputNewLine();
                            this.wideGap = false;
                        }

                        this.injection.Inject(false, this.output);
                    }

                    this.output.CloseDocument();
                    this.output.Flush();
                }

                this.endOfFile = true;
                break;
            }
        }
        private void Process(HtmlTokenId tokenId)
        {
            this.token = this.parser.Token;
            switch (tokenId)
            {
            case HtmlTokenId.EndOfFile:
                if (this.lineStarted)
                {
                    this.output.OutputNewLine();
                    this.lineStarted = false;
                }
                if (!this.convertFragment)
                {
                    if (this.injection != null && this.injection.HaveHead)
                    {
                        if (this.wideGap)
                        {
                            this.output.OutputNewLine();
                            this.wideGap = false;
                        }
                        this.injection.Inject(false, this.output);
                    }
                    this.output.CloseDocument();
                    this.output.Flush();
                }
                this.endOfFile = true;
                break;

            case HtmlTokenId.Text:
                if (!this.insideComment)
                {
                    if (this.insideAnchor && this.urlCompareSink.IsActive)
                    {
                        this.token.Text.WriteTo(this.urlCompareSink);
                    }
                    if (this.insidePre)
                    {
                        this.ProcessPreformatedText();
                        return;
                    }
                    if (this.normalizedInput)
                    {
                        this.ProcessText();
                        return;
                    }
                    this.NormalizeProcessText();
                    return;
                }
                break;

            case HtmlTokenId.EncodingChange:
                if (this.output.OutputCodePageSameAsInput)
                {
                    this.output.OutputEncoding = this.token.TokenEncoding;
                    return;
                }
                break;

            case HtmlTokenId.Tag:
            {
                if (this.token.TagIndex <= HtmlTagIndex.Unknown)
                {
                    return;
                }
                HtmlDtd.TagDefinition tagDefinition = HtmlToTextConverter.GetTagDefinition(this.token.TagIndex);
                if (this.normalizedInput)
                {
                    if (!this.token.IsEndTag)
                    {
                        if (this.token.IsTagBegin)
                        {
                            this.PushElement(tagDefinition);
                        }
                        this.ProcessStartTagAttributes(tagDefinition);
                        return;
                    }
                    if (this.token.IsTagBegin)
                    {
                        this.PopElement(tagDefinition);
                        return;
                    }
                }
                else
                {
                    if (!this.token.IsEndTag)
                    {
                        if (this.token.IsTagBegin)
                        {
                            this.LFillTagB(tagDefinition);
                            this.PushElement(tagDefinition);
                            this.RFillTagB(tagDefinition);
                        }
                        this.ProcessStartTagAttributes(tagDefinition);
                        return;
                    }
                    if (this.token.IsTagBegin)
                    {
                        this.LFillTagE(tagDefinition);
                        this.PopElement(tagDefinition);
                        this.RFillTagE(tagDefinition);
                        return;
                    }
                }
                break;
            }

            case HtmlTokenId.Restart:
            case HtmlTokenId.OverlappedClose:
            case HtmlTokenId.OverlappedReopen:
                break;

            default:
                return;
            }
        }