MarkdownCodeBlockSyntax Class

A fenced code block (between ``` or ~~~) or an indented code block.

public sealed class MarkdownCodeBlockSyntax : MarkdownBlockSyntax
Inheritance
MarkdownBlockSyntax MarkdownCodeBlockSyntax

Properties

NameDescription
ClosingFenceTokenGets the closing fence, or the default token when there is none.
CodeGets the code: its lines without the indentation of the block and the markers of its containers, each one ended by \n.
InfoGets the info string, without its escapes and entities, or null when there is none.
InfoTokenGets the info string after the opening fence, or the default token when there is none.
IsFencedGets a value indicating whether the code is between fences rather than indented.
LanguageGets the first word of the info string, which names the language of the code, or null.
LineTokensGets the tokens of the lines of the code, with their line endings.
OpeningFenceTokenGets the opening fence, or the default token for an indented code block.

Gets the closing fence, or the default token when there is none.

public SyntaxToken ClosingFenceToken { get; }

Property value

SyntaxToken

Gets the code: its lines without the indentation of the block and the markers of its containers, each one ended by \n.

public string Code { get; }

Property value

string

Gets the info string, without its escapes and entities, or null when there is none.

public string? Info { get; }

Property value

string?

Gets the info string after the opening fence, or the default token when there is none.

public SyntaxToken InfoToken { get; }

Property value

SyntaxToken

Gets a value indicating whether the code is between fences rather than indented.

public bool IsFenced { get; }

Property value

bool

Gets the first word of the info string, which names the language of the code, or null.

public string? Language { get; }

Property value

string?

Gets the tokens of the lines of the code, with their line endings.

public ImmutableArray<SyntaxToken> LineTokens { get; }

Gets the opening fence, or the default token for an indented code block.

public SyntaxToken OpeningFenceToken { get; }

Property value

SyntaxToken

Methods

NameDescription
Accept(MarkdownSyntaxVisitor)
Accept<TResult>(MarkdownSyntaxVisitor<TResult>)
GetPlainText()
WithInfo(string?)Returns this fenced code block with the info string info, or itself when it has this info string.

Accept overloads

Accept(MarkdownSyntaxVisitor)

MarkdownCodeBlockSyntax.cs
public override void Accept(MarkdownSyntaxVisitor visitor)
Parameters
visitor MarkdownSyntaxVisitor

No documentation is available.

Accept<TResult>(MarkdownSyntaxVisitor<TResult>)

MarkdownCodeBlockSyntax.cs
public override TResult? Accept<TResult>(MarkdownSyntaxVisitor<TResult> visitor)
Type parameters
TResult
Parameters
visitor MarkdownSyntaxVisitor<TResult>
Returns

TResult?

No documentation is available.

public override string GetPlainText()

Returns

string

No documentation is available.

Returns this fenced code block with the info string info, or itself when it has this info string.

public MarkdownCodeBlockSyntax WithInfo(string? info)

Parameters

info string?
The info string, which is escaped: it is the MarkdownCodeBlockSyntax.Info of the block, without the whitespace around it. null or a blank text removes the info string.

Returns

MarkdownCodeBlockSyntax

Exceptions

ArgumentException
info contains a line ending.
InvalidOperationException
The block is an indented code block, which has no info string.

Remarks

The block is in no tree: replace this one with it, with SyntaxNodeExtensions.ReplaceNode.