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 (unless a preprocessor opts out with SkipChrome). Used by both the Markdig renderer and the <CodeBlock> Razor component so markdown fences and Razor usages produce identical HTML.
Constructors
CodeBlockRenderingService
#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
highlightingServiceHighlightingServicepreprocessorsIEnumerable<ICodeBlockPreprocessor>
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
codestringlanguageIdstringoptionsCodeHighlightRenderOptionsisInTabGroupbool
Returns
stringPennington.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 (unless a preprocessor opts out with SkipChrome). 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)
;
}