BlockProcessor Class
The block processor.
public class BlockProcessorConstructors
| Name | Description |
|---|---|
| BlockProcessor(MarkdownDocument, BlockParserList, MarkdownParserContext?, bool) | Initializes a new instance of the BlockProcessor class. |
BlockProcessor(MarkdownDocument, BlockParserList, MarkdownParserContext?, bool)
BlockProcessor.csInitializes a new instance of the BlockProcessor class.
public BlockProcessor(MarkdownDocument document, BlockParserList parsers, MarkdownParserContext? context, bool trackTrivia = false)Parameters
documentMarkdownDocument- The document to build blocks into.
parsersBlockParserList- The list of parsers.
contextMarkdownParserContext?- A parser context used for the parsing.
trackTriviabool- Whether to parse trivia such as whitespace, extra heading characters and unescaped string values.
Exceptions
Properties
| Name | Description |
|---|---|
| Column | Gets or sets the column. |
| ColumnBeforeIndent | Gets the column position before the indent occurred. |
| Context | Gets the parser context or null if none is available. |
| CurrentBlock | Gets the last block that is opened. |
| CurrentChar | Gets the current character being processed. |
| CurrentContainer | Gets the current active container. |
| CurrentLineStartPosition | Gets or sets the current line start position. |
| Document | Gets the root document. |
| Indent | Gets the current indent position (number of columns between the previous indent and the current position). |
| IsBlankLine | Gets a value indicating whether the line is blank (valid only after BlockProcessor.ParseIndent has been called). |
| IsCodeIndent | Gets a value indicating whether a code indentation is at the beginning of the line being processed. |
| IsLazy | Gets a boolean indicating whether the current line being parsed is lazy continuation. |
| LastBlock | Gets the last block that is created. |
| LineIndex | Gets the index of the line in the source text. |
| LinesBefore | Gets or sets the stack of empty lines not yet assigned to any Block. An entry may contain an empty StringSlice. In that case the StringSlice.NewLine is relevant. Otherwise, the StringSlice entry will contain trivia. |
| NewBlocks | Gets the new blocks to push. A BlockParser is required to push new blocks that it creates to this property. |
| NextContinue | Gets the next block in a BlockParser.TryContinue. |
| Parsers | Gets the list of BlockParsers configured with this parser state. |
| SkipFirstUnwindSpace | Gets or sets the skip first unwind space. |
| Start | Gets the position of the current character in the line being processed. |
| StartBeforeIndent | Gets the character position before the indent occurred. |
| TrackTrivia | True to parse trivia such as whitespace, extra heading characters and unescaped string values. |
| TriviaStart | Gets or sets the position of the first character trivia is encountered and not yet assigned to a syntax node. Trivia: only used when BlockProcessor.TrackTrivia is enabled, otherwise 0. |
Column
BlockProcessor.csColumnBeforeIndent
BlockProcessor.csContext
BlockProcessor.csGets the parser context or null if none is available.
public MarkdownParserContext? Context { get; }Property value
CurrentBlock
BlockProcessor.csCurrentChar
BlockProcessor.csCurrentContainer
BlockProcessor.csCurrentLineStartPosition
BlockProcessor.csDocument
BlockProcessor.csIndent
BlockProcessor.csIsBlankLine
BlockProcessor.csGets a value indicating whether the line is blank (valid only after BlockProcessor.ParseIndent has been called).
public bool IsBlankLine { get; }Property value
IsCodeIndent
BlockProcessor.csIsLazy
BlockProcessor.csLastBlock
BlockProcessor.csLineIndex
BlockProcessor.csLinesBefore
BlockProcessor.csGets or sets the stack of empty lines not yet assigned to any Block. An entry may contain an empty StringSlice. In that case the StringSlice.NewLine is relevant. Otherwise, the StringSlice entry will contain trivia.
public List<StringSlice>? LinesBefore { get; set; }Property value
NewBlocks
BlockProcessor.csGets the new blocks to push. A BlockParser is required to push new blocks that it creates to this property.
Property value
NextContinue
BlockProcessor.csParsers
BlockProcessor.csGets the list of BlockParsers configured with this parser state.
public BlockParserList Parsers { get; }Property value
SkipFirstUnwindSpace
BlockProcessor.csStart
BlockProcessor.csStartBeforeIndent
BlockProcessor.csTrackTrivia
BlockProcessor.csTriviaStart
BlockProcessor.csGets or sets the position of the first character trivia is encountered and not yet assigned to a syntax node. Trivia: only used when BlockProcessor.TrackTrivia is enabled, otherwise 0.
public int TriviaStart { get; set; }Property value
Methods
| Name | Description |
|---|---|
| Close(Block) | Force closing the specified block. |
| CreateChild() | Performs the create child operation. |
| Discard(Block) | Discards the specified block from the stack, remove from its parent. |
| GetCurrentContainerOpened() | Get the current Container that is currently opened |
| GoToCodeIndent(int) | Moves to the position to the code indent (BlockProcessor.ColumnBeforeIndent + 4 spaces). |
| GoToColumn(int) | Moves to the position to the specified column position, taking into account spaces in tabs. |
| IsOpen(Block) | Checks whether the specified block is currently part of the open block stack. |
| NextChar() | Returns the next character in the line being processed. Update BlockProcessor.Start and BlockProcessor.Column. |
| NextColumn() | Returns the next character in the line taking into space taken by tabs. Update BlockProcessor.Start and BlockProcessor.Column. |
| Open(Block) | Opens the specified block. |
| ParseIndent() | Parses the indentation from the current position in the line, updating BlockProcessor.StartBeforeIndent, BlockProcessor.ColumnBeforeIndent, BlockProcessor.Start and BlockProcessor.Column accordingly taking into account space taken by tabs. |
| PeekChar(int) | Peeks a character at the specified offset from the current position in the line. |
| ProcessLine(StringSlice) | Processes a new line. |
| ProcessLinePart(StringSlice, int) | Processes part of a line. |
| ReleaseChild() | Performs the release child operation. |
| RestartIndent() | Restarts the indent from the current position. |
| TakeLinesBefore() | Takes the current stack of BlockProcessor.LinesBefore to assign it to a Block. Afterwards, BlockProcessor.LinesBefore is set to null. |
| TryDiscard(Block) | Tries to discard the specified block from the open stack and remove it from its parent. |
| UnwindAllIndents() | Unwind any previous indent from the current character back to the first space. |
| UseTrivia(int) | Returns trivia that has not yet been assigned to any node and advances the position of trivia to the ending position. |
Close(Block)
BlockProcessor.csCreateChild()
BlockProcessor.csDiscard(Block)
BlockProcessor.csGetCurrentContainerOpened()
BlockProcessor.csGet the current Container that is currently opened
public ContainerBlock GetCurrentContainerOpened()Returns
ContainerBlock The current Container that is currently opened
GoToCodeIndent(int)
BlockProcessor.csMoves to the position to the code indent (BlockProcessor.ColumnBeforeIndent + 4 spaces).
Parameters
columnOffsetint- The column offset to apply to this indent.
GoToColumn(int)
BlockProcessor.csIsOpen(Block)
BlockProcessor.csNextChar()
BlockProcessor.csReturns the next character in the line being processed. Update BlockProcessor.Start and BlockProcessor.Column.
public char NextChar()Returns
char The next character or `\0` if end of line is reached
NextColumn()
BlockProcessor.csReturns the next character in the line taking into space taken by tabs. Update BlockProcessor.Start and BlockProcessor.Column.
public void NextColumn()Open(Block)
BlockProcessor.csOpens the specified block.
Parameters
blockBlock- The block.
Exceptions
ArgumentNullExceptionArgumentException- The block must be opened
ParseIndent()
BlockProcessor.csParses the indentation from the current position in the line, updating BlockProcessor.StartBeforeIndent, BlockProcessor.ColumnBeforeIndent, BlockProcessor.Start and BlockProcessor.Column accordingly taking into account space taken by tabs.
public void ParseIndent()PeekChar(int)
BlockProcessor.csProcessLine(StringSlice)
BlockProcessor.csProcesses a new line.
public void ProcessLine(StringSlice newLine)Parameters
newLineStringSlice- The new line.
ProcessLinePart(StringSlice, int)
BlockProcessor.csProcesses part of a line.
public void ProcessLinePart(StringSlice line, int column)Parameters
lineStringSlice- The line.
columnint- The column.
ReleaseChild()
BlockProcessor.csPerforms the release child operation.
public void ReleaseChild()RestartIndent()
BlockProcessor.csRestarts the indent from the current position.
public void RestartIndent()TakeLinesBefore()
BlockProcessor.csTakes the current stack of BlockProcessor.LinesBefore to assign it to a Block. Afterwards, BlockProcessor.LinesBefore is set to null.
public List<StringSlice>? TakeLinesBefore()Returns
List<StringSlice>? The pending list of lines before the current block, or null if none.
TryDiscard(Block)
BlockProcessor.csTries to discard the specified block from the open stack and remove it from its parent.
Parameters
blockBlock- The block to discard.
Returns
bool true if the block was discarded; otherwise false.
Exceptions
ArgumentNullException- Thrown when
blockis null.
UnwindAllIndents()
BlockProcessor.csUnwind any previous indent from the current character back to the first space.
public void UnwindAllIndents()UseTrivia(int)
BlockProcessor.csReturns trivia that has not yet been assigned to any node and advances the position of trivia to the ending position.
public StringSlice UseTrivia(int end)Fields
| Name | Description |
|---|---|
| Line | The current line being processed. |
Line
The current line being processed.
public StringSlice Line