Exemple #1
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);
 }
Exemple #2
0
        private BlockProcessor(BlockProcessor root)
        {
            // These properties are not changing between a parent and a children BlockProcessor
            this.root             = root;
            this.parserStateCache = root.parserStateCache;
            Document = root.Document;
            Parsers  = root.Parsers;

            // These properties are local to a state
            OpenedBlocks = new List <Block>();
            NewBlocks    = new Stack <Block>();
        }
Exemple #3
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);
 }
Exemple #4
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);
 }