Skip to content
ConsoleMonster
Class

Highlighters

ConsoleMonster.Highlighting

Namespace
ConsoleMonster.Highlighting
Assembly
ConsoleMonster
Modifiers
static

The highlighter registry: the built-in languages (json, xml, yaml, powershell, csharp, sql, ini, csv, diff, log, markdown), the smart value highlighter for plain text, lookup by name, alias or file extension, and detection from a path and a light look at the content. Register your own languages with Highlighters.Register.

Inheritance

  • object
  • Highlighters

Methods

public static ITextHighlighter? Detect(string? text, string? path = null) #

The highlighter for a text: by the path's extension, then by a look at the content; null for plain text.

Parameters

text string? required
The text.
path string? = null optional
The file it came from, or null.

Returns

ITextHighlighter? The highlighter, or null.
public static ITextHighlighter? ForPath(string? path) #

The highlighter for a file by its extension, or null.

Parameters

path string? required
The path or file name.

Returns

ITextHighlighter? The highlighter, or null.
public static ITextHighlighter? Get(string? name) #

A highlighter by name or alias ("json", "ps1", "c#", "smart"), or null.

Parameters

name string? required
The name.

Returns

ITextHighlighter? The highlighter, or null.
public static void Register(ITextHighlighter highlighter, params string[] extensions) #

Registers a highlighter under its name and file extensions (replacing earlier registrations).

Parameters

highlighter ConsoleMonster.Highlighting.ITextHighlighter required
The highlighter.
extensions string[] required
File extensions without the dot.

Properties

public static ITextHighlighter Smart { get; } #

The smart value highlighter for plain text (numbers, booleans, GUIDs, IP addresses, URLs, paths, dates, DNs, quoted strings).

public static IReadOnlyList<string> Names { get; } #

The registered language names.