MarkdownDeep.StringScanner.SkipEol C# (CSharp) Method

SkipEol() public method

public SkipEol ( ) : bool
return bool
        public bool SkipEol()
        {
            if (pos < end)
            {
                char ch = str[pos];
                if (ch == '\r')
                {
                    pos++;
                    if (pos < end && str[pos] == '\n')
                        pos++;
                    return true;
                }

                else if (ch == '\n')
                {
                    pos++;
                    if (pos < end && str[pos] == '\r')
                        pos++;
                    return true;
                }
            }

            return false;
        }

Usage Example

Beispiel #1
0
        public static string NormalizeLineEnds(string str)
        {
            if (str.IndexOfAny(Lineends) < 0)
            {
                return(str);
            }

            var sb = new StringBuilder();
            var sp = new StringScanner(str);

            while (!sp.Eof)
            {
                if (sp.Eol)
                {
                    sb.Append('\n');
                    sp.SkipEol();
                }
                else
                {
                    sb.Append(sp.Current);
                    sp.SkipForward(1);
                }
            }

            return(sb.ToString());
        }
All Usage Examples Of MarkdownDeep.StringScanner::SkipEol