src/Markdig/Helpers/LineReader.cs
/// <summary>
/// Reads a new line from the underlying <see cref="TextReader"/> and update the <see cref="SourcePosition"/> for the next line.
/// </summary>
/// <returns>A new line or null if the end of <see cref="TextReader"/> has been reached</returns>
Reads a new line from the underlying  and update the  for the next line.
Reads a new line from the underlying and update the for the next line .
public StringSlice ReadLine()
        {
            string text = _text;
            int sourcePosition = SourcePosition;
            for (int i = sourcePosition; i < text.Length; i++)
            {
                char c = text[i];
                if (c == '\r')
                {
                    int length = 1;
                    var newLine = NewLine.CarriageReturn;
                    if (c == '\r' && (uint)(i + 1) < (uint)text.Length && text[i + 1] == '\n')
                    {
                        i++;
                        length = 2;
                        newLine = NewLine.CarriageReturnLineFeed;
                    }
                    var slice = new StringSlice(text, sourcePosition, i - length, newLine);
                    SourcePosition = i + 1;
                    return slice;
                }
                if (c == '\n')
                {
                    var slice = new StringSlice(text, sourcePosition, i - 1, NewLine.LineFeed);
                    SourcePosition = i + 1;
                    return slice;
                }
            }
            if (sourcePosition >= text.Length)
                return default;
            SourcePosition = int.MaxValue;
            return new StringSlice(text, sourcePosition, text.Length - 1);
        }
public StringSlice ReadLine ( ) { string text = _text ; int sourcePosition = SourcePosition ; for ( int i = sourcePosition ; i < text . Length ; i ++ ) { char c = text [ i ] ; if ( c == ' \r ' ) { int length = 1 ; var newLine = NewLine . CarriageReturn ; if ( c == ' \r ' && ( uint ) ( i + 1 ) < ( uint ) text . Length && text [ i + 1 ] == ' \n ' ) { i ++ ; length = 2 ; newLine = NewLine . CarriageReturnLineFeed ; } var slice = new StringSlice ( text , sourcePosition , i - length , newLine ) ; SourcePosition = i + 1 ; return slice ; } if ( c == ' \n ' ) { var slice = new StringSlice ( text , sourcePosition , i - 1 , NewLine . LineFeed ) ; SourcePosition = i + 1 ; return slice ; } } if ( sourcePosition >= text . Length ) return default ; SourcePosition = int . MaxValue ; return new StringSlice ( text , sourcePosition , text . Length - 1 ) ; }
Reads a new line from the underlying  and update the  for the next line.
Reads a new line from the underlying and update the for the next line .
A new line or null if the end of  has been reached
A new line or null if the end of has been reached