private void Text()

in src/PSRule/Parser/MarkdownReader.cs [214:248]


        private void Text()
        {
            _Stream.MarkExtentStart();

            // Set the default style
            var textStyle = MarkdownTokens.None;

            var startOfLine = _Stream.IsStartOfLine;

            // Get the text
            var text = _PreserveFormatting ? _Stream.CaptureUntil(LineEndingCharacters, ignoreEscaping: true) : UnwrapStyleMarkers(_Stream, out textStyle);

            // Set the line ending
            var ending = GetEnding(_Stream.SkipLineEnding(max: 2));

            if (string.IsNullOrWhiteSpace(text) && !_PreserveFormatting)
                return;

            if (_Context != MarkdownReaderMode.List && startOfLine && IsList(text))
            {
                _Context = MarkdownReaderMode.List;
                if (_Output.Current != null && _Output.Current.Flag.IsEnding() && !_Output.Current.Flag.ShouldPreserve())
                    _Output.Current.Flag |= MarkdownTokens.Preserve;
            }

            // Override line ending if the line was a list item so that the line ending is preserved
            if (_Context == MarkdownReaderMode.List && ending.IsEnding())
                ending |= MarkdownTokens.Preserve;

            // Add the text to the output stream
            _Output.Text(text, flag: textStyle | ending);

            if (_Context == MarkdownReaderMode.List && ending.IsEnding())
                _Context = MarkdownReaderMode.None;
        }