Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlockProcessor" /> class.
        /// </summary>
        /// <param name="document">The document to build blocks into.</param>
        /// <param name="parsers">The list of parsers.</param>
        /// <param name="context">A parser context used for the parsing.</param>
        /// <param name="trackTrivia">Whether to parse trivia such as whitespace, extra heading characters and unescaped string values.</param>
        /// <exception cref="ArgumentNullException">
        /// </exception>
        public BlockProcessor(MarkdownDocument document, BlockParserList parsers, MarkdownParserContext?context, bool trackTrivia = false)
        {
            Setup(document, parsers, context, trackTrivia);

            document.IsOpen = true;
            Open(document);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlockProcessor" /> class.
 /// </summary>
 /// <param name="stringBuilders">The string builders cache.</param>
 /// <param name="document">The document to build blocks into.</param>
 /// <param name="parsers">The list of parsers.</param>
 /// <exception cref="System.ArgumentNullException">
 /// </exception>
 public BlockProcessor(StringBuilderCache stringBuilders, MarkdownDocument document, BlockParserList parsers, MarkdownParserContext context)
 {
     if (stringBuilders == null)
     {
         throw new ArgumentNullException(nameof(stringBuilders));
     }
     if (document == null)
     {
         throw new ArgumentNullException(nameof(document));
     }
     if (parsers == null)
     {
         throw new ArgumentNullException(nameof(parsers));
     }
     parserStateCache = new BlockParserStateCache(this);
     StringBuilders   = stringBuilders;
     Document         = document;
     document.IsOpen  = true;
     Parsers          = parsers;
     Context          = context;
     OpenedBlocks     = new List <Block>();
     NewBlocks        = new Stack <Block>();
     root             = this;
     Open(document);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlockProcessor" /> class.
 /// </summary>
 /// <param name="document">The document to build blocks into.</param>
 /// <param name="parsers">The list of parsers.</param>
 /// <param name="context">A parser context used for the parsing.</param>
 /// <param name="trackTrivia">Whether to parse trivia such as whitespace, extra heading characters and unescaped string values.</param>
 /// <exception cref="ArgumentNullException">
 /// </exception>
 public BlockProcessor(MarkdownDocument document, BlockParserList parsers, MarkdownParserContext?context, bool trackTrivia = false)
 {
     if (document is null)
     {
         ThrowHelper.ArgumentNullException(nameof(document));
     }
     if (parsers is null)
     {
         ThrowHelper.ArgumentNullException(nameof(parsers));
     }
     TrackTrivia      = trackTrivia;
     parserStateCache = new BlockParserStateCache(this);
     Document         = document;
     document.IsOpen  = true;
     Parsers          = parsers;
     Context          = context;
     OpenedBlocks     = new List <Block>();
     NewBlocks        = new Stack <Block>();
     root             = this;
     Open(document);
 }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlockProcessor" /> class.
 /// </summary>
 /// <param name="stringBuilders">The string builders cache.</param>
 /// <param name="document">The document to build blocks into.</param>
 /// <param name="parsers">The list of parsers.</param>
 /// <exception cref="System.ArgumentNullException">
 /// </exception>
 public BlockProcessor(StringBuilderCache stringBuilders, MarkdownDocument document, BlockParserList parsers)
 {
     parserStateCache = new BlockParserStateCache(this);
     StringBuilders   = stringBuilders ?? throw new ArgumentNullException(nameof(stringBuilders));
     Document         = document ?? throw new ArgumentNullException(nameof(document));
     document.IsOpen  = true;
     Parsers          = parsers ?? throw new ArgumentNullException(nameof(parsers));
     OpenedBlocks     = new List <Block>();
     NewBlocks        = new Stack <Block>();
     root             = this;
     Open(document);
 }