API Reference
RegexHighlighter
A highlighter built from regular-expression rules, tried in order at each position (the first rule that matches wins). Use it to add a language without writing a lexer: Highlighters.Register(new RegexHighlighter("ini").Rule(@"^\s*;.*$", HighlightRole.Comment).Rule(...), "ini"). Matching has a time limit (default 250 ms per text); text after a timeout stays plain.
Inheritance
- Object
- RegexHighlighter
Usage
Explore 2 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 2
- Method RegexHighlighter.Rule
- Method RegexHighlighter.Words
Constructors
public RegexHighlighter(String name, Boolean ignoreCase = false) #Creates an empty highlighter.
Parameters
- name System.String
- The language name.
- ignoreCase System.Boolean = false
- Whether the rules ignore case.
Methods
public RegexHighlighter Rule(String pattern, HighlightRole role) #RegexHighlighterAdds a rule. Patterns run in multiline mode (^ and $ match at line breaks); avoid nested quantifiers.
Parameters
- pattern System.String
- The pattern.
- role ConsoleMonster.Highlighting.HighlightRole
- The role of what it matches.
Returns
This highlighter.
public IReadOnlyList<HighlightToken> Tokenize(String text) #IReadOnlyList<HighlightToken>Tokenizes text.
Parameters
- text System.String
- The text (any line endings).
Returns
The tokens, in order and not overlapping.
public RegexHighlighter Words(HighlightRole role, params String[] words) #RegexHighlighterAdds a keyword rule: whole words from a list.
Parameters
- role ConsoleMonster.Highlighting.HighlightRole
- The role.
- words System.String[]
- The words.
Returns
This highlighter.
Inherited Methods
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?