HighlightingService
Pennington.Highlighting
Dispatches code highlighting to the highest-priority ICodeHighlighter that supports the requested language. Falls back to Plain
Constructors
HighlightingService
#public HighlightingService(IEnumerable<ICodeHighlighter> highlighters)
Initializes the service with the registered highlighters, ordered by descending Priority.
Parameters
highlightersIEnumerable<ICodeHighlighter>
HighlightingService
#public HighlightingService(IEnumerable<ICodeHighlighter> highlighters, IHttpContextAccessor httpContextAccessor)
Initializes the service with the registered highlighters and an optional HTTP context accessor used to surface unknown-language Info diagnostics to the per-request DiagnosticContext.
Parameters
highlightersIEnumerable<ICodeHighlighter>httpContextAccessorIHttpContextAccessor
Methods
Highlight
#public string Highlight(string code, string language)
Highlight code using the best available highlighter for the language. Returns the highlighted HTML string.
Parameters
codestringlanguagestring
Returns
stringPennington.Highlighting.HighlightingService
namespace Pennington.Highlighting;
/// Dispatches code highlighting to the highest-priority ICodeHighlighter that supports the requested language. Falls back to PlainTextHighlighter and emits an Info diagnostic once per unknown language per instance.
public class HighlightingService
{
/// Highlight code using the best available highlighter for the language. Returns the highlighted HTML string.
public string Highlight(string code, string language)
;
/// Initializes the service with the registered highlighters, ordered by descending Priority.
public HighlightingService(IEnumerable<ICodeHighlighter> highlighters)
;
/// Initializes the service with the registered highlighters and an optional HTTP context accessor used to surface unknown-language Info diagnostics to the per-request DiagnosticContext.
public HighlightingService(IEnumerable<ICodeHighlighter> highlighters, IHttpContextAccessor httpContextAccessor)
;
}