This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

TreeSitterCodeBlockPreprocessor Pennington.TreeSitter.Preprocessing

Preprocesses code blocks with a :symbol modifier (e.g. python:symbol) by extracting the referenced source via tree-sitter and rendering it with the shared highlighting service. A :symbol-diff variant emits a unified diff between two referenced fragments.

Properties

Priority int
Priority — higher runs first.

Constructors

TreeSitterCodeBlockPreprocessor

#
public TreeSitterCodeBlockPreprocessor(ISourceFragmentService fragmentService, HighlightingService highlightingService, IHttpContextAccessor httpContextAccessor)

Creates the preprocessor wired to the fragment service, shared highlighting service, and per-request diagnostics accessor.

Parameters

fragmentService ISourceFragmentService
highlightingService HighlightingService
httpContextAccessor IHttpContextAccessor

Methods

TryProcess

#
public CodeBlockPreprocessResult TryProcess(string code, string languageId)

Attempts to preprocess a code block. Returns a result if handled, or null to pass through.

Parameters

code string
languageId string

Returns

CodeBlockPreprocessResult

Pennington.TreeSitter.Preprocessing.TreeSitterCodeBlockPreprocessor

namespace Pennington.TreeSitter.Preprocessing;

/// Preprocesses code blocks with a :symbol modifier (e.g. python:symbol) by extracting the referenced source via tree-sitter and rendering it with the shared highlighting service. A :symbol-diff variant emits a unified diff between two referenced fragments.
public class TreeSitterCodeBlockPreprocessor
{
    /// Priority — higher runs first.
    
public int Priority { get; }
/// Creates the preprocessor wired to the fragment service, shared highlighting service, and per-request diagnostics accessor.
public TreeSitterCodeBlockPreprocessor(ISourceFragmentService fragmentService, HighlightingService highlightingService, IHttpContextAccessor httpContextAccessor)
; /// Attempts to preprocess a code block. Returns a result if handled, or null to pass through.
public CodeBlockPreprocessResult TryProcess(string code, string languageId)
; }