This site provides a machine-readable index at /llms.txt.

Skip to main content Skip to navigation

CodeBlockRenderingService Pennington.Markdown.Extensions

Shared rendering pipeline for fenced code blocks. Runs registered ICodeBlockPreprocessors first, falls back to HighlightingService on the base language, applies CodeTransformer, and wraps the result via CodeBlockHtmlBuilder. Used by both the Markdig renderer and the <CodeBlock> Razor component so markdown fences and Razor usages produce identical HTML.

Constructors

.ctor

#
public CodeBlockRenderingService(
    HighlightingService highlightingService,
    IEnumerable<ICodeBlockPreprocessor>? preprocessors = null);

Creates the service with a highlighting dispatcher and the registered preprocessors (ordered by descending priority at construction).

Parameters

highlightingService HighlightingService
preprocessors IEnumerable<ICodeBlockPreprocessor>? (optional)

Methods

Render

#
public string Render(
    string code,
    string languageId,
    CodeHighlightRenderOptions? options = null,
    bool isInTabGroup = false);

Renders code with language tag languageId through the full pipeline.

Parameters

code string
languageId string
options CodeHighlightRenderOptions? (optional)
isInTabGroup bool (optional)

Returns

string

Pennington.Markdown.Extensions.CodeBlockRenderingService

namespace Pennington.Markdown.Extensions;

/// Shared rendering pipeline for fenced code blocks. Runs registered ICodeBlockPreprocessors first, falls back to HighlightingService on the base language, applies CodeTransformer, and wraps the result via CodeBlockHtmlBuilder. Used by both the Markdig renderer and the <CodeBlock> Razor component so markdown fences and Razor usages produce identical HTML.
public class CodeBlockRenderingService
{
    /// Creates the service with a highlighting dispatcher and the registered preprocessors (ordered by descending priority at construction).
    
public CodeBlockRenderingService(
    HighlightingService highlightingService,
    IEnumerable<ICodeBlockPreprocessor>? preprocessors = null);
/// Renders code with language tag languageId through the full pipeline.
public string Render(
    string code,
    string languageId,
    CodeHighlightRenderOptions? options = null,
    bool isInTabGroup = false);
}