Esempio n. 1
0
            public void Initialize(RunType type, RunTextType textType, uint kind, int length, int value)
            {
                InternalDebug.Assert(length <= MaxRunLength && value < MaxRunValue && (kind > MaxRunValue || kind == 0));

                this.lengthAndType = (uint)length | (uint)type | (uint)textType;
                this.valueAndKind  = (uint)value | (uint)kind;
            }
Esempio n. 2
0
        private void OutputFragmentSimple(TextToken token)
        {
            foreach (TokenRun tokenRun in token.Runs)
            {
                if (tokenRun.IsTextRun)
                {
                    RunTextType textType = tokenRun.TextType;
                    if (textType <= RunTextType.NewLine)
                    {
                        if (textType == RunTextType.Unknown)
                        {
                            goto IL_B3;
                        }
                        if (textType != RunTextType.Space)
                        {
                            if (textType != RunTextType.NewLine)
                            {
                                continue;
                            }
                            base.AddLineBreak(1);
                            continue;
                        }
                    }
                    else if (textType <= RunTextType.UnusualWhitespace)
                    {
                        if (textType == RunTextType.Tabulation)
                        {
                            base.AddTabulation(tokenRun.Length);
                            continue;
                        }
                        if (textType != RunTextType.UnusualWhitespace)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (textType == RunTextType.Nbsp)
                        {
                            base.AddNbsp(tokenRun.Length);
                            continue;
                        }
                        if (textType != RunTextType.NonSpace)
                        {
                            continue;
                        }
                        goto IL_B3;
                    }
                    base.AddSpace(tokenRun.Length);
                    continue;
IL_B3:
                    base.AddNonSpaceText(tokenRun.RawBuffer, tokenRun.RawOffset, tokenRun.RawLength);
                }
                else if (tokenRun.IsSpecial)
                {
                    uint kind = tokenRun.Kind;
                }
            }
        }
Esempio n. 3
0
 private void ProcessPreformatedText()
 {
     if (!lineStarted)
     {
         StartParagraphOrLine();
     }
     Token.RunEnumerator enumerator = token.Runs.GetEnumerator();
     while (enumerator.MoveNext())
     {
         TokenRun current = enumerator.Current;
         if (current.IsTextRun)
         {
             if (current.IsAnyWhitespace)
             {
                 RunTextType textType = current.TextType;
                 if (textType != RunTextType.Space)
                 {
                     if (textType == RunTextType.NewLine)
                     {
                         output.OutputNewLine();
                         continue;
                     }
                     if (textType == RunTextType.Tabulation)
                     {
                         output.OutputTabulation(current.Length);
                         continue;
                     }
                 }
                 if (treatNbspAsBreakable)
                 {
                     output.OutputSpace(current.Length);
                 }
                 else
                 {
                     output.OutputNbsp(current.Length);
                 }
             }
             else if (current.TextType == RunTextType.Nbsp)
             {
                 if (treatNbspAsBreakable)
                 {
                     output.OutputSpace(current.Length);
                 }
                 else
                 {
                     output.OutputNbsp(current.Length);
                 }
             }
             else if (current.IsLiteral)
             {
                 output.OutputNonspace(current.Literal, textMapping);
             }
             else
             {
                 output.OutputNonspace(current.RawBuffer, current.RawOffset, current.RawLength, textMapping);
             }
         }
     }
 }
 // Token: 0x06001A0F RID: 6671 RVA: 0x000CED42 File Offset: 0x000CCF42
 private void AddTextRun(RunTextType textType, int runStart, int runEnd)
 {
     if (!this.unwrapFlowed)
     {
         this.tokenBuilder.AddTextRun(textType, runStart, runEnd);
         return;
     }
     this.AddTextRunUnwrap(textType, runStart, runEnd);
 }
 private void ProcessPreformatedText()
 {
     if (!this.lineStarted)
     {
         this.StartParagraphOrLine();
     }
     foreach (TokenRun tokenRun in this.token.Runs)
     {
         if (tokenRun.IsTextRun)
         {
             if (tokenRun.IsAnyWhitespace)
             {
                 RunTextType textType = tokenRun.TextType;
                 if (textType != RunTextType.Space)
                 {
                     if (textType == RunTextType.NewLine)
                     {
                         this.output.OutputNewLine();
                         continue;
                     }
                     if (textType == RunTextType.Tabulation)
                     {
                         this.output.OutputTabulation(tokenRun.Length);
                         continue;
                     }
                 }
                 if (this.treatNbspAsBreakable)
                 {
                     this.output.OutputSpace(tokenRun.Length);
                 }
                 else
                 {
                     this.output.OutputNbsp(tokenRun.Length);
                 }
             }
             else if (tokenRun.TextType == RunTextType.Nbsp)
             {
                 if (this.treatNbspAsBreakable)
                 {
                     this.output.OutputSpace(tokenRun.Length);
                 }
                 else
                 {
                     this.output.OutputNbsp(tokenRun.Length);
                 }
             }
             else if (tokenRun.IsLiteral)
             {
                 this.output.OutputNonspace(tokenRun.Literal, this.textMapping);
             }
             else
             {
                 this.output.OutputNonspace(tokenRun.RawBuffer, tokenRun.RawOffset, tokenRun.RawLength, this.textMapping);
             }
         }
     }
 }
Esempio n. 6
0
        internal void AddRun(RunType type, RunTextType textType, uint kind, int start, int end, int value)
        {
            Token.RunEntry[] arg_26_0     = token.runList;
            Token            expr_16_cp_0 = token;
            int tail;

            expr_16_cp_0.whole.tail = (tail = expr_16_cp_0.whole.tail) + 1;
            arg_26_0[tail].Initialize(type, textType, kind, end - start, value);
            tailOffset = end;
        }
Esempio n. 7
0
        internal void AddRun(RunType type, RunTextType textType, uint kind, int start, int end, int value)
        {
            Token.RunEntry[] runList = this.token.RunList;
            Token            token   = this.token;
            int tail;

            token.Whole.Tail = (tail = token.Whole.Tail) + 1;
            runList[tail].Initialize(type, textType, kind, end - start, value);
            this.tailOffset = end;
        }
Esempio n. 8
0
 // Token: 0x060019CE RID: 6606 RVA: 0x000CCA74 File Offset: 0x000CAC74
 private void OutputFragmentSimple(TextToken token)
 {
     foreach (TokenRun tokenRun in token.Runs)
     {
         if (tokenRun.IsTextRun)
         {
             RunTextType textType = tokenRun.TextType;
             if (textType <= RunTextType.Tabulation)
             {
                 if (textType != RunTextType.Space)
                 {
                     if (textType == RunTextType.NewLine)
                     {
                         this.output.OutputNewLine();
                         continue;
                     }
                     if (textType != RunTextType.Tabulation)
                     {
                         continue;
                     }
                     this.output.OutputTabulation(tokenRun.Length);
                     continue;
                 }
             }
             else if (textType != RunTextType.UnusualWhitespace)
             {
                 if (textType != RunTextType.Nbsp)
                 {
                     if (textType != RunTextType.NonSpace)
                     {
                         continue;
                     }
                     this.output.OutputNonspace(tokenRun.RawBuffer, tokenRun.RawOffset, tokenRun.RawLength, TextMapping.Unicode);
                     continue;
                 }
                 else
                 {
                     if (this.treatNbspAsBreakable)
                     {
                         this.output.OutputSpace(tokenRun.Length);
                         continue;
                     }
                     this.output.OutputNbsp(tokenRun.Length);
                     continue;
                 }
             }
             this.output.OutputSpace(tokenRun.Length);
         }
         else if (tokenRun.IsSpecial && tokenRun.Kind == 167772160U)
         {
             this.output.SetQuotingLevel((int)((ushort)tokenRun.Value));
         }
     }
 }
Esempio n. 9
0
        private void AddTextRun(RunTextType textType, int runStart, int runEnd)
        {
            if (!unwrapFlowed)
            {
                // just add the run
                tokenBuilder.AddTextRun(textType, runStart, runEnd);
                return;
            }

            // do unwrapping preprocessing
            AddTextRunUnwrap(textType, runStart, runEnd);
        }
Esempio n. 10
0
        internal void AddRun(RunType type, RunTextType textType, uint kind, int start, int end, int value)
        {
#if DEBUG
            InternalDebug.Assert(this.preparedForNumRuns > 0);
            this.preparedForNumRuns--;
#endif
            InternalDebug.Assert(this.state >= FirstStarted);
            InternalDebug.Assert(end >= start);
            InternalDebug.Assert(this.token.whole.head != this.token.whole.tail || this.tailOffset == this.token.whole.headOffset);
            InternalDebug.Assert(this.token.whole.tail + 1 < this.token.runList.Length);
            InternalDebug.Assert(start == this.tailOffset);

            this.token.runList[this.token.whole.tail++].Initialize(type, textType, kind, end - start, value);
            this.tailOffset = end;
        }
 // Token: 0x0600139C RID: 5020 RVA: 0x0008A038 File Offset: 0x00088238
 private void OutputText(HtmlToken token)
 {
     foreach (TokenRun tokenRun in token.Runs)
     {
         if (tokenRun.IsTextRun)
         {
             if (tokenRun.IsAnyWhitespace)
             {
                 RunTextType textType = tokenRun.TextType;
                 if (textType != RunTextType.Space)
                 {
                     if (textType == RunTextType.NewLine)
                     {
                         this.output.OutputNewLine();
                         continue;
                     }
                     if (textType == RunTextType.Tabulation)
                     {
                         this.output.OutputTabulation(tokenRun.Length);
                         continue;
                     }
                 }
                 this.output.OutputSpace(tokenRun.Length);
             }
             else if (tokenRun.TextType == RunTextType.Nbsp)
             {
                 if (this.treatNbspAsBreakable)
                 {
                     this.output.OutputSpace(tokenRun.Length);
                 }
                 else
                 {
                     this.output.OutputNbsp(tokenRun.Length);
                 }
             }
             else if (tokenRun.IsLiteral)
             {
                 this.output.OutputNonspace(tokenRun.Literal, TextMapping.Unicode);
             }
             else
             {
                 this.output.OutputNonspace(tokenRun.RawBuffer, tokenRun.RawOffset, tokenRun.RawLength, TextMapping.Unicode);
             }
         }
     }
 }
Esempio n. 12
0
 private void OutputText(HtmlToken token)
 {
     foreach (TokenRun tokenRun in token.Runs)
     {
         if (tokenRun.IsTextRun)
         {
             if (tokenRun.IsAnyWhitespace)
             {
                 RunTextType textType = tokenRun.TextType;
                 if (textType != RunTextType.Space)
                 {
                     if (textType == RunTextType.NewLine)
                     {
                         base.AddLineBreak(1);
                         continue;
                     }
                     if (textType == RunTextType.Tabulation)
                     {
                         base.AddTabulation(tokenRun.Length);
                         continue;
                     }
                 }
                 base.AddSpace(tokenRun.Length);
             }
             else if (tokenRun.TextType == RunTextType.Nbsp)
             {
                 if (this.treatNbspAsBreakable)
                 {
                     base.AddSpace(tokenRun.Length);
                 }
                 else
                 {
                     base.AddNbsp(tokenRun.Length);
                 }
             }
             else if (tokenRun.IsLiteral)
             {
                 base.AddNonSpaceText(this.literalBuffer, 0, tokenRun.ReadLiteral(this.literalBuffer));
             }
             else
             {
                 base.AddNonSpaceText(tokenRun.RawBuffer, tokenRun.RawOffset, tokenRun.RawLength);
             }
         }
     }
 }
Esempio n. 13
0
 public void Initialize(RunType type, RunTextType textType, uint kind, int length, int value)
 {
     lengthAndType = (uint)(length | (int)type | (int)textType);
     valueAndKind  = (uint)(value | (int)kind);
 }
Esempio n. 14
0
 public void AddRun(RunTextType textType, HtmlRunKind kind, int start, int end)
 {
     base.AddRun(RunType.Normal, textType, (uint)kind, start, end, 0);
 }
Esempio n. 15
0
 public void AddLiteralRun(RunTextType textType, HtmlRunKind kind, int start, int end, int literal)
 {
     base.AddRun(RunType.Literal, textType, (uint)kind, start, end, literal);
 }
Esempio n. 16
0
 public void AddLiteralTextRun(RunTextType textType, int start, int end, int literal)
 {
     AddRun((RunType)3221225472u, textType, 67108864u, start, end, literal);
 }
Esempio n. 17
0
        private void AddTextRunUnwrap(RunTextType textType, int runStart, int runEnd)
        {
            switch (textType)
            {
            case RunTextType.NewLine:

                if (!lastSpace || (signaturePossible && lineCount == 3))
                {
                    lastLineFlowed = false;
                    tokenBuilder.AddTextRun(textType, runStart, runEnd);
                }
                else
                {
                    lastLineFlowed = true;
                }

                lineCount         = 0;
                lastSpace         = false;
                signaturePossible = true;
                quotingExpected   = true;

                lastLineQuotingLevel = quotingLevel;
                quotingLevel         = 0;
                break;

            case RunTextType.Space:
            case RunTextType.UnusualWhitespace:

                if (quotingExpected)
                {
                    InternalDebug.Assert(lineCount == 0);

                    runStart++;             // skip first space at the beginning of line

                    // need to add invalid run to keep it contigous
                    tokenBuilder.SkipRunIfNecessary(runStart, RunKind.Text);

                    if (lastLineQuotingLevel != quotingLevel)
                    {
                        if (lastLineFlowed)
                        {
                            tokenBuilder.AddLiteralTextRun(RunTextType.NewLine, runStart, runStart, '\n');
                        }

                        tokenBuilder.AddSpecialRun(TextRunKind.QuotingLevel, runStart, quotingLevel);
                        lastLineQuotingLevel = quotingLevel;
                    }

                    quotingExpected = false;
                }

                InternalDebug.Assert(lineCount != 0 || lastLineQuotingLevel == quotingLevel);

                if (runStart != runEnd)
                {
                    lineCount += runEnd - runStart;
                    lastSpace  = true;

                    tokenBuilder.AddTextRun(textType, runStart, runEnd);

                    if (lineCount != 3 || runEnd - runStart != 1)
                    {
                        signaturePossible = false;
                    }
                }

                break;

            case RunTextType.Tabulation:

                if (quotingExpected)
                {
                    InternalDebug.Assert(lineCount == 0);

                    if (lastLineQuotingLevel != quotingLevel)
                    {
                        if (lastLineFlowed)
                        {
                            tokenBuilder.AddLiteralTextRun(RunTextType.NewLine, runStart, runStart, '\n');
                        }

                        tokenBuilder.AddSpecialRun(TextRunKind.QuotingLevel, runStart, quotingLevel);
                        lastLineQuotingLevel = quotingLevel;
                    }

                    quotingExpected = false;
                }

                InternalDebug.Assert(lineCount != 0 || lastLineQuotingLevel == quotingLevel);

                tokenBuilder.AddTextRun(textType, runStart, runEnd);

                lineCount += runEnd - runStart;

                lastSpace         = false;
                signaturePossible = false;

                break;

            case RunTextType.Nbsp:
            case RunTextType.NonSpace:

                if (quotingExpected)
                {
                    InternalDebug.Assert(lineCount == 0);

                    while (runStart != runEnd && parseBuffer[runStart] == '>')
                    {
                        quotingLevel++;
                        runStart++;
                    }

                    // we may have skipped some stuff, in such case need to add invalid run to keep it contigous
                    tokenBuilder.SkipRunIfNecessary(runStart, RunKind.Text);

                    if (runStart != runEnd)
                    {
                        // end of quotation, check the quoting level

                        if (lastLineQuotingLevel != quotingLevel)
                        {
                            if (lastLineFlowed)
                            {
                                tokenBuilder.AddLiteralTextRun(RunTextType.NewLine, runStart, runStart, '\n');
                            }

                            tokenBuilder.AddSpecialRun(TextRunKind.QuotingLevel, runStart, quotingLevel);
                            lastLineQuotingLevel = quotingLevel;
                        }

                        quotingExpected = false;
                    }
                }

                if (runStart != runEnd)
                {
                    InternalDebug.Assert(lineCount != 0 || lastLineQuotingLevel == quotingLevel);

                    tokenBuilder.AddTextRun(textType, runStart, runEnd);

                    lineCount += runEnd - runStart;
                    lastSpace  = false;

                    if (lineCount > 2 || parseBuffer[runStart] != '-' || (runEnd - runStart == 2 && parseBuffer[runStart + 1] != '-'))
                    {
                        signaturePossible = false;
                    }
                }

                break;

            default:

                InternalDebug.Assert(false, "unexpected run textType");
                break;
            }
        }
        // Token: 0x060010E4 RID: 4324 RVA: 0x0007AB10 File Offset: 0x00078D10
        protected void Process(TextTokenId tokenId)
        {
            switch (tokenId)
            {
            case TextTokenId.EndOfFile:
                this.endOfFile = true;
                break;

            case TextTokenId.Text:
                foreach (TokenRun tokenRun in this.parser.Token.Runs)
                {
                    if (tokenRun.IsTextRun)
                    {
                        RunTextType textType = tokenRun.TextType;
                        if (textType <= RunTextType.Tabulation)
                        {
                            if (textType != RunTextType.Space)
                            {
                                if (textType == RunTextType.NewLine)
                                {
                                    this.output.WriteControlText("\\line\r\n", false);
                                    continue;
                                }
                                if (textType != RunTextType.Tabulation)
                                {
                                    continue;
                                }
                                for (int i = 0; i < tokenRun.Length; i++)
                                {
                                    this.output.WriteControlText("\\tab", true);
                                }
                                continue;
                            }
                        }
                        else if (textType != RunTextType.UnusualWhitespace)
                        {
                            if (textType == RunTextType.Nbsp)
                            {
                                for (int j = 0; j < tokenRun.Length; j++)
                                {
                                    this.output.WriteText("\u00a0");
                                }
                                continue;
                            }
                            if (textType != RunTextType.NonSpace)
                            {
                                continue;
                            }
                            this.output.WriteText(tokenRun.RawBuffer, tokenRun.RawOffset, tokenRun.RawLength);
                            continue;
                        }
                        for (int k = 0; k < tokenRun.Length; k++)
                        {
                            this.output.WriteText(" ");
                        }
                    }
                    else if (tokenRun.IsSpecial)
                    {
                        uint kind = tokenRun.Kind;
                    }
                }
                return;

            case TextTokenId.EncodingChange:
                break;

            default:
                return;
            }
        }
Esempio n. 19
0
 public void AddTextRun(RunTextType textType, int start, int end)
 {
     AddRun((RunType)2147483648u, textType, 67108864u, start, end, 0);
 }
Esempio n. 20
0
 public void AddRun(RunTextType textType, HtmlRunKind kind, int start, int end)
 {
     base.AddRun((RunType)2147483648u, textType, (uint)kind, start, end, 0);
 }
Esempio n. 21
0
 public void AddLiteralTextRun(RunTextType textType, int start, int end, int literal)
 {
     InternalDebug.Assert(start == this.tailOffset);
     this.AddRun(RunType.Literal, textType, (uint)RunKind.Text, start, end, literal);
 }
Esempio n. 22
0
 public void AddTextRun(RunTextType textType, int start, int end)
 {
     InternalDebug.Assert(start == this.tailOffset);
     this.AddRun(RunType.Normal, textType, (uint)RunKind.Text, start, end, 0);
 }
Esempio n. 23
0
 // Token: 0x06001A10 RID: 6672 RVA: 0x000CED64 File Offset: 0x000CCF64
 private void AddTextRunUnwrap(RunTextType textType, int runStart, int runEnd)
 {
     if (textType <= RunTextType.Tabulation)
     {
         if (textType != RunTextType.Space)
         {
             if (textType == RunTextType.NewLine)
             {
                 if (!this.lastSpace || (this.signaturePossible && this.lineCount == 3))
                 {
                     this.lastLineFlowed = false;
                     this.tokenBuilder.AddTextRun(textType, runStart, runEnd);
                 }
                 else
                 {
                     this.lastLineFlowed = true;
                 }
                 this.lineCount            = 0;
                 this.lastSpace            = false;
                 this.signaturePossible    = true;
                 this.quotingExpected      = true;
                 this.lastLineQuotingLevel = this.quotingLevel;
                 this.quotingLevel         = 0;
                 return;
             }
             if (textType != RunTextType.Tabulation)
             {
                 return;
             }
             if (this.quotingExpected)
             {
                 if (this.lastLineQuotingLevel != this.quotingLevel)
                 {
                     if (this.lastLineFlowed)
                     {
                         this.tokenBuilder.AddLiteralTextRun(RunTextType.NewLine, runStart, runStart, 10);
                     }
                     this.tokenBuilder.AddSpecialRun(TextRunKind.QuotingLevel, runStart, this.quotingLevel);
                     this.lastLineQuotingLevel = this.quotingLevel;
                 }
                 this.quotingExpected = false;
             }
             this.tokenBuilder.AddTextRun(textType, runStart, runEnd);
             this.lineCount        += runEnd - runStart;
             this.lastSpace         = false;
             this.signaturePossible = false;
             return;
         }
     }
     else if (textType != RunTextType.UnusualWhitespace)
     {
         if (textType != RunTextType.Nbsp && textType != RunTextType.NonSpace)
         {
             return;
         }
         if (this.quotingExpected)
         {
             while (runStart != runEnd && this.parseBuffer[runStart] == '>')
             {
                 this.quotingLevel++;
                 runStart++;
             }
             this.tokenBuilder.SkipRunIfNecessary(runStart, RunKind.Text);
             if (runStart != runEnd)
             {
                 if (this.lastLineQuotingLevel != this.quotingLevel)
                 {
                     if (this.lastLineFlowed)
                     {
                         this.tokenBuilder.AddLiteralTextRun(RunTextType.NewLine, runStart, runStart, 10);
                     }
                     this.tokenBuilder.AddSpecialRun(TextRunKind.QuotingLevel, runStart, this.quotingLevel);
                     this.lastLineQuotingLevel = this.quotingLevel;
                 }
                 this.quotingExpected = false;
             }
         }
         if (runStart == runEnd)
         {
             return;
         }
         this.tokenBuilder.AddTextRun(textType, runStart, runEnd);
         this.lineCount += runEnd - runStart;
         this.lastSpace  = false;
         if (this.lineCount > 2 || this.parseBuffer[runStart] != '-' || (runEnd - runStart == 2 && this.parseBuffer[runStart + 1] != '-'))
         {
             this.signaturePossible = false;
             return;
         }
         return;
     }
     if (this.quotingExpected)
     {
         runStart++;
         this.tokenBuilder.SkipRunIfNecessary(runStart, RunKind.Text);
         if (this.lastLineQuotingLevel != this.quotingLevel)
         {
             if (this.lastLineFlowed)
             {
                 this.tokenBuilder.AddLiteralTextRun(RunTextType.NewLine, runStart, runStart, 10);
             }
             this.tokenBuilder.AddSpecialRun(TextRunKind.QuotingLevel, runStart, this.quotingLevel);
             this.lastLineQuotingLevel = this.quotingLevel;
         }
         this.quotingExpected = false;
     }
     if (runStart != runEnd)
     {
         this.lineCount += runEnd - runStart;
         this.lastSpace  = true;
         this.tokenBuilder.AddTextRun(textType, runStart, runEnd);
         if (this.lineCount != 3 || runEnd - runStart != 1)
         {
             this.signaturePossible = false;
             return;
         }
     }
 }
Esempio n. 24
0
 public void AddTextRun(RunTextType textType, int start, int end)
 {
     this.AddRun((RunType)2147483648U, textType, 67108864U, start, end, 0);
 }