CodeBlockRenderer Class

An HTML renderer for a CodeBlock and FencedCodeBlock.

public class CodeBlockRenderer : HtmlObjectRenderer<CodeBlock>
Inheritance
HtmlObjectRenderer<CodeBlock> CodeBlockRenderer

Constructors

NameDescription
CodeBlockRenderer()Initializes a new instance of the CodeBlockRenderer class.

CodeBlockRenderer()

CodeBlockRenderer.cs

Initializes a new instance of the CodeBlockRenderer class.

public CodeBlockRenderer()

Properties

NameDescription
BlockMappingGets a map of custom block mapping to render as custom blocks instead of pre/code blocks. For example defining {"mermaid", "pre"} will render a block with info `mermaid` as a `pre` block but without the code HTML element.
BlocksAsDivGets a map of fenced code block infos that should be rendered as div blocks instead of pre/code blocks.
OutputAttributesOnPreGets or sets the output attributes on pre.

Gets a map of custom block mapping to render as custom blocks instead of pre/code blocks. For example defining {"mermaid", "pre"} will render a block with info `mermaid` as a `pre` block but without the code HTML element.

public Dictionary<string, string> BlockMapping { get; }

Gets a map of fenced code block infos that should be rendered as div blocks instead of pre/code blocks.

public HashSet<string> BlocksAsDiv { get; }

Property value

HashSet<string>

OutputAttributesOnPre

CodeBlockRenderer.cs

Gets or sets the output attributes on pre.

public bool OutputAttributesOnPre { get; set; }

Property value

bool

Methods

NameDescription
Write(HtmlRenderer, CodeBlock)Writes the object to the specified renderer.

Write(HtmlRenderer, CodeBlock)

CodeBlockRenderer.cs

Writes the object to the specified renderer.

protected override void Write(HtmlRenderer renderer, CodeBlock obj)

Parameters

renderer HtmlRenderer
obj CodeBlock