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
highlightersIEnumerable<ICodeHighlighter>
Methods
HasHighlighter
#public bool HasHighlighter(string language);Returns true if any registered highlighter (not the fallback) supports this language.
Parameters
languagestring
Returns
boolHighlight
#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.
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);
}