src/Markdig/Extensions/SelfPipeline/SelfPipelineExtension.cs
/// <summary>
/// Creates a pipeline automatically configured from an input markdown based on the presence of the configuration tag.
/// </summary>
/// <param name="inputText">The input text.</param>
/// <returns>The pipeline configured from the input</returns>
/// <exception cref="ArgumentNullException"></exception>
Creates a pipeline automatically configured from an input markdown based on the presence of the configuration tag.
Creates a pipeline automatically configured from an input markdown based on the presence of the configuration tag .
public MarkdownPipeline CreatePipelineFromInput(string inputText)
        {
            if (inputText is null) ThrowHelper.ArgumentNullException(nameof(inputText));
            var builder = new MarkdownPipelineBuilder();
            string? defaultConfig = DefaultExtensions;
            var indexOfSelfPipeline = inputText.IndexOf(SelfPipelineHintTagStart, StringComparison.OrdinalIgnoreCase);
            if (indexOfSelfPipeline >= 0)
            {
                var optionStart = indexOfSelfPipeline + SelfPipelineHintTagStart.Length;
                var endOfTag = inputText.IndexOf("-->", optionStart, StringComparison.OrdinalIgnoreCase);
                if (endOfTag >= 0)
                {
                    defaultConfig = inputText.Substring(optionStart, endOfTag - optionStart).Trim();
                }
            }
            if (defaultConfig is { Length: > 0 })
            {
                builder.Configure(defaultConfig);
            }
            return builder.Build();
        }
public MarkdownPipeline CreatePipelineFromInput ( string inputText ) { if ( inputText is null ) ThrowHelper . ArgumentNullException ( nameof ( inputText ) ) ; var builder = new MarkdownPipelineBuilder ( ) ; string ? defaultConfig = DefaultExtensions ; var indexOfSelfPipeline = inputText . IndexOf ( SelfPipelineHintTagStart , StringComparison . OrdinalIgnoreCase ) ; if ( indexOfSelfPipeline >= 0 ) { var optionStart = indexOfSelfPipeline + SelfPipelineHintTagStart . Length ; var endOfTag = inputText . IndexOf ( " " , optionStart , StringComparison . OrdinalIgnoreCase ) ; if ( endOfTag >= 0 ) { defaultConfig = inputText . Substring ( optionStart , endOfTag - optionStart ) . Trim ( ) ; } } if ( defaultConfig is { Length : > 0 } ) { builder . Configure ( defaultConfig ) ; } return builder . Build ( ) ; }
Creates a pipeline automatically configured from an input markdown based on the presence of the configuration tag.
Creates a pipeline automatically configured from an input markdown based on the presence of the configuration tag .
The pipeline configured from the input
The pipeline configured from the input
None
inputText
string
The input text.
The input text .