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

Skip to main content Skip to navigation

HighlightingService Pennington.Highlighting

Dispatches code highlighting to the highest-priority ICodeHighlighter that supports the requested language. Falls back to PlainTextHighlighter.

Constructors

.ctor

#
public HighlightingService(IEnumerable<ICodeHighlighter> highlighters);

Initializes the service with the registered highlighters, ordered by descending Priority.

Parameters

highlighters IEnumerable<ICodeHighlighter>

Methods

HasHighlighter

#
public bool HasHighlighter(string language);

Returns true if any registered highlighter (not the fallback) supports this language.

Parameters

language string

Returns

bool

Highlight

#
public string Highlight(string code, string language);

Highlight code using the best available highlighter for the language. Returns the highlighted HTML string.

Parameters

code string
language string

Returns

string

Pennington.Highlighting.HighlightingService

namespace Pennington.Highlighting;

/// Dispatches code highlighting to the highest-priority ICodeHighlighter that supports the requested language. Falls back to PlainTextHighlighter.
public class HighlightingService
{
    /// Initializes the service with the registered highlighters, ordered by descending Priority.
    
public HighlightingService(IEnumerable<ICodeHighlighter> highlighters);
/// Returns true if any registered highlighter (not the fallback) supports this language.
public bool HasHighlighter(string language);
/// Highlight code using the best available highlighter for the language. Returns the highlighted HTML string.
public string Highlight(string code, string language);
}