/// <summary> /// Initializes a new instance of the <see cref="MarkdownParser" /> class. /// </summary> /// <param name="text">The reader.</param> /// <param name="pipeline">The pipeline.</param> /// <param name="context">A parser context used for the parsing.</param> /// <exception cref="System.ArgumentNullException"> /// </exception> private MarkdownParser(string text, MarkdownPipeline pipeline, MarkdownParserContext context) { if (text == null) { ThrowHelper.ArgumentNullException_text(); } if (pipeline == null) { ThrowHelper.ArgumentNullException(nameof(pipeline)); } roughLineCountEstimate = text.Length / 40; text = FixupZero(text); lineReader = new LineReader(text); preciseSourceLocation = pipeline.PreciseSourceLocation; // Initialize the pipeline document = new MarkdownDocument(); // Initialize the block parsers blockProcessor = new BlockProcessor(document, pipeline.BlockParsers, context); // Initialize the inline parsers inlineProcessor = new InlineProcessor(document, pipeline.InlineParsers, pipeline.PreciseSourceLocation, context) { DebugLog = pipeline.DebugLog }; documentProcessed = pipeline.DocumentProcessed; }
/// <summary> /// Initializes a new instance of the <see cref="MarkdownParser" /> class. /// </summary> /// <param name="text">The reader.</param> /// <param name="pipeline">The pipeline.</param> /// <exception cref="System.ArgumentNullException"> /// </exception> private MarkdownParser(string text, MarkdownPipeline pipeline) { if (text == null) { throw new ArgumentNullException(nameof(text)); } if (pipeline == null) { throw new ArgumentNullException(nameof(pipeline)); } text = FixupZero(text); lineReader = new LineReader(text); preciseSourceLocation = pipeline.PreciseSourceLocation; // Initialize the pipeline var stringBuilderCache = pipeline.StringBuilderCache ?? new StringBuilderCache(); document = new MarkdownDocument(); // Initialize the block parsers blockProcessor = new BlockProcessor(stringBuilderCache, document, pipeline.BlockParsers); // Initialize the inline parsers inlineProcessor = new InlineProcessor(stringBuilderCache, document, pipeline.InlineParsers, pipeline.PreciseSourceLocation) { DebugLog = pipeline.DebugLog }; documentProcessed = pipeline.DocumentProcessed; }