Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
        // This class is immutable

        /// <summary>
        /// Initializes a new instance of the <see cref="MarkdownPipeline" /> class.
        /// </summary>
        internal MarkdownPipeline(OrderedList <IMarkdownExtension> extensions, BlockParserList blockParsers, InlineParserList inlineParsers, StringBuilderCache cache, TextWriter debugLog, ProcessDocumentDelegate documentProcessed)
        {
            // Add all default parsers
            Extensions         = extensions;
            BlockParsers       = blockParsers ?? throw new ArgumentNullException(nameof(blockParsers));
            InlineParsers      = inlineParsers ?? throw new ArgumentNullException(nameof(inlineParsers));
            StringBuilderCache = cache;
            DebugLog           = debugLog;
            DocumentProcessed  = documentProcessed;
        }
Exemplo n.º 4
0
        // This class is immutable

        /// <summary>
        /// Initializes a new instance of the <see cref="MarkdownPipeline" /> class.
        /// </summary>
        internal MarkdownPipeline(OrderedList <IMarkdownExtension> extensions, BlockParserList blockParsers, InlineParserList inlineParsers, TextWriter debugLog, ProcessDocumentDelegate documentProcessed)
        {
            if (blockParsers == null)
            {
                ThrowHelper.ArgumentNullException(nameof(blockParsers));
            }
            if (inlineParsers == null)
            {
                ThrowHelper.ArgumentNullException(nameof(inlineParsers));
            }
            // Add all default parsers
            Extensions        = extensions;
            BlockParsers      = blockParsers;
            InlineParsers     = inlineParsers;
            DebugLog          = debugLog;
            DocumentProcessed = documentProcessed;
        }