Block Class
Base class for a block structure. Either a LeafBlock or a ContainerBlock.
public abstract class Block : MarkdownObject, IBlock, IMarkdownObjectSee also
- Inheritance
MarkdownObjectBlock- Implements
Constructors
| Name | Description |
|---|---|
| Block(BlockParser?) | Initializes a new instance of the Block class. |
Block(BlockParser?)
Block.csInitializes a new instance of the Block class.
protected Block(BlockParser? parser)Parameters
parserBlockParser?- The parser used to create this block.
Properties
| Name | Description |
|---|---|
| IsBreakable | Gets or sets a value indicating whether this block is breakable. Default is true. |
| IsOpen | Gets or sets a value indicating whether this instance is still open. |
| LinesAfter | Gets or sets the empty lines occurring after this block. Trivia: only parsed when MarkdownPipeline.TrackTrivia is enabled, otherwise null. |
| LinesBefore | Gets or sets the empty lines occurring before this block. Trivia: only parsed when MarkdownPipeline.TrackTrivia is enabled, otherwise null. |
| NewLine | The last newline of this block. Trivia: only parsed when MarkdownPipeline.TrackTrivia is enabled |
| Parent | Gets the parent of this container. May be null. |
| Parser | Gets the parser associated to this instance. |
| RemoveAfterProcessInlines | Gets or sets a value indicating whether this block must be removed from its container after inlines have been processed. |
| TriviaAfter | Gets or sets trivia occurring after this block. Trivia: only parsed when MarkdownPipeline.TrackTrivia is enabled, otherwise StringSlice.Empty. |
| TriviaBefore | Gets or sets the trivia right before this block. Trivia: only parsed when MarkdownPipeline.TrackTrivia is enabled, otherwise StringSlice.Empty. |
IsBreakable
Block.csIsOpen
Block.csLinesAfter
Block.csGets or sets the empty lines occurring after this block. Trivia: only parsed when MarkdownPipeline.TrackTrivia is enabled, otherwise null.
public List<StringSlice>? LinesAfter { get; set; }Property value
LinesBefore
Block.csGets or sets the empty lines occurring before this block. Trivia: only parsed when MarkdownPipeline.TrackTrivia is enabled, otherwise null.
public List<StringSlice>? LinesBefore { get; set; }Property value
NewLine
Block.csThe last newline of this block. Trivia: only parsed when MarkdownPipeline.TrackTrivia is enabled
public NewLine NewLine { get; set; }Property value
Parent
Block.csParser
Block.csRemoveAfterProcessInlines
Block.csTriviaAfter
Block.csGets or sets trivia occurring after this block. Trivia: only parsed when MarkdownPipeline.TrackTrivia is enabled, otherwise StringSlice.Empty.
public StringSlice TriviaAfter { get; set; }Property value
TriviaBefore
Block.csGets or sets the trivia right before this block. Trivia: only parsed when MarkdownPipeline.TrackTrivia is enabled, otherwise StringSlice.Empty.
public StringSlice TriviaBefore { get; set; }Property value
Methods
| Name | Description |
|---|---|
| Remove() | Removes this block from its parent container. |
| ReplaceBy(Block, bool) | Replaces this block with replacement in its parent container. |
| UpdateSpanEnd(int) | Performs the update span end operation. |
| UpdateSpanToInclude(SourceSpan) | Updates this block span and all parent container spans to include the specified span. |
Remove()
Block.csRemoves this block from its parent container.
public void Remove()ReplaceBy(Block, bool)
Block.csReplaces this block with replacement in its parent container.
Parameters
replacementBlock- The replacement block.
moveChildrenbooltrueto transfer children when both this block andreplacementare containers.
Exceptions
ArgumentNullException- Thrown if
replacementis null. ArgumentException- Thrown if
replacementis already attached to a parent container. InvalidOperationException- Thrown if this block has no parent container.
Remarks
This method does not recompute spans or trivia. Callers are responsible for updating those values if a transform requires exact source information after replacement.
UpdateSpanEnd(int)
Block.csUpdateSpanToInclude(SourceSpan)
Block.csUpdates this block span and all parent container spans to include the specified span.
public void UpdateSpanToInclude(SourceSpan span)Parameters
spanSourceSpan- The span to include.
Events
| Name | Description |
|---|---|
| ProcessInlinesBegin | Occurs when the process of inlines begin. |
| ProcessInlinesEnd | Occurs when the process of inlines ends for this instance. |
ProcessInlinesBegin
Block.csOccurs when the process of inlines begin.
public event ProcessInlineDelegate? ProcessInlinesBeginProcessInlinesEnd
Block.csOccurs when the process of inlines ends for this instance.
public event ProcessInlineDelegate? ProcessInlinesEnd