Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InlineProcessor" /> class.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="parsers">The parsers.</param>
 /// <param name="preciseSourcelocation">A value indicating whether to provide precise source location.</param>
 /// <param name="context">A parser context used for the parsing.</param>
 /// <exception cref="ArgumentNullException">
 /// </exception>
 public InlineProcessor(MarkdownDocument document, InlineParserList parsers, bool preciseSourcelocation, MarkdownParserContext context)
 {
     if (document == null)
     {
         ThrowHelper.ArgumentNullException(nameof(document));
     }
     if (parsers == null)
     {
         ThrowHelper.ArgumentNullException(nameof(parsers));
     }
     Document = document;
     Parsers  = parsers;
     Context  = context;
     PreciseSourceLocation = preciseSourcelocation;
     lineOffsets           = new List <StringLineGroup.LineOffset>();
     ParserStates          = new object[Parsers.Count];
     LiteralInlineParser   = new LiteralInlineParser();
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InlineProcessor" /> class.
 /// </summary>
 /// <param name="stringBuilders">The string builders.</param>
 /// <param name="document">The document.</param>
 /// <param name="parsers">The parsers.</param>
 /// <param name="inlineCreated">The inline created event.</param>
 /// <exception cref="System.ArgumentNullException">
 /// </exception>
 public InlineProcessor(StringBuilderCache stringBuilders, MarkdownDocument document, InlineParserList parsers, bool preciseSourcelocation)
 {
     if (stringBuilders == null)
     {
         throw new ArgumentNullException(nameof(stringBuilders));
     }
     if (document == null)
     {
         throw new ArgumentNullException(nameof(document));
     }
     if (parsers == null)
     {
         throw new ArgumentNullException(nameof(parsers));
     }
     StringBuilders        = stringBuilders;
     Document              = document;
     Parsers               = parsers;
     PreciseSourceLocation = preciseSourcelocation;
     lineOffsets           = new List <StringLineGroup.LineOffset>();
     ParserStates          = new object[Parsers.Count];
     LiteralInlineParser   = new LiteralInlineParser();
 }
Beispiel #3
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
            var blockParserList = new BlockParserList();

            blockParserList.AddRange(pipeline.BlockParsers);
            blockProcessor = new BlockProcessor(stringBuilderCache, document, blockParserList);

            // Initialize the inline parsers
            var inlineParserList = new InlineParserList();

            inlineParserList.AddRange(pipeline.InlineParsers);
            inlineProcessor = new InlineProcessor(stringBuilderCache, document, inlineParserList, pipeline.PreciseSourceLocation)
            {
                DebugLog = pipeline.DebugLog
            };

            documentProcessed = pipeline.DocumentProcessed;
        }