Ejemplo n.º 1
0
        private void NormalizeProcessText()
        {
            Token.RunEnumerator runs = this.token.Runs;

            runs.MoveNext(true);

            while (runs.IsValidPosition)
            {
                TokenRun run = runs.Current;

                if (run.IsAnyWhitespace)
                {
                    int cntWhitespaces = 0;

                    do
                    {
                        cntWhitespaces += runs.Current.TextType == RunTextType.NewLine ? 1 : 2;
                    }while (runs.MoveNext(true) && (runs.Current.TextType <= RunTextType.LastWhitespace));

                    this.NormalizeAddSpace(cntWhitespaces == 1);
                }
                else if (run.TextType == RunTextType.Nbsp)
                {
                    this.NormalizeAddNbsp(run.Length);

                    runs.MoveNext(true);
                }
                else
                {
                    this.NormalizeAddNonspace(run);

                    runs.MoveNext(true);
                }
            }
        }
Ejemplo n.º 2
0
        private void NormalizeAddNonspace(TokenRun run)
        {
            if (!this.lineStarted)
            {
                this.StartParagraphOrLine();
            }

            if (this.normalizerContext.hasSpace)
            {
                this.normalizerContext.hasSpace = false;



                if ('\0' == this.normalizerContext.lastCh || !this.normalizerContext.oneNL || !ParseSupport.TwoFarEastNonHanguelChars(this.normalizerContext.lastCh, run.FirstChar))
                {
                    this.output.OutputSpace(1);
                }
            }

            if (run.IsLiteral)
            {
                this.output.OutputNonspace(run.Literal, this.textMapping);
            }
            else
            {
                this.output.OutputNonspace(run.RawBuffer, run.RawOffset, run.RawLength, this.textMapping);
            }

            this.normalizerContext.eatSpace = false;
            this.normalizerContext.lastCh   = run.LastChar;
            this.normalizerContext.oneNL    = false;
        }
Ejemplo 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);
             }
         }
     }
 }
Ejemplo n.º 4
0
 private void NormalizeProcessText()
 {
     Token.RunEnumerator runs = token.Runs;
     runs.MoveNext(true);
     while (runs.IsValidPosition)
     {
         TokenRun current = runs.Current;
         if (current.IsAnyWhitespace)
         {
             int      num = 0;
             TokenRun current3;
             do
             {
                 int      arg_48_0 = num;
                 TokenRun current2 = runs.Current;
                 num = arg_48_0 + ((current2.TextType == RunTextType.NewLine) ? 1 : 2);
                 if (!runs.MoveNext(true))
                 {
                     break;
                 }
                 current3 = runs.Current;
             }while (current3.TextType <= RunTextType.UnusualWhitespace);
             NormalizeAddSpace(num == 1);
         }
         else if (current.TextType == RunTextType.Nbsp)
         {
             NormalizeAddNbsp(current.Length);
             runs.MoveNext(true);
         }
         else
         {
             NormalizeAddNonspace(current);
             runs.MoveNext(true);
         }
     }
 }
Ejemplo n.º 5
0
 private void NormalizeProcessText()
 {
     Token.RunEnumerator runs = this.token.Runs;
     runs.MoveNext(true);
     while (runs.IsValidPosition)
     {
         TokenRun run = runs.Current;
         if (run.IsAnyWhitespace)
         {
             int      num = 0;
             TokenRun tokenRun2;
             do
             {
                 int      num2     = num;
                 TokenRun tokenRun = runs.Current;
                 num = num2 + ((tokenRun.TextType == RunTextType.NewLine) ? 1 : 2);
                 if (!runs.MoveNext(true))
                 {
                     break;
                 }
                 tokenRun2 = runs.Current;
             }while (tokenRun2.TextType <= RunTextType.UnusualWhitespace);
             this.NormalizeAddSpace(num == 1);
         }
         else if (run.TextType == RunTextType.Nbsp)
         {
             this.NormalizeAddNbsp(run.Length);
             runs.MoveNext(true);
         }
         else
         {
             this.NormalizeAddNonspace(run);
             runs.MoveNext(true);
         }
     }
 }