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
Priorityint- 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
fragmentServiceISourceFragmentServicehighlightingServiceHighlightingServicehttpContextAccessorIHttpContextAccessor
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
codestringlanguageIdstring
Returns
CodeBlockPreprocessResultPennington.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)
;
}