Highlight class
Main syntax highlighter class for code highlighting with customizable styles.
The Highlight class provides methods to register programming languages, parse source code with syntax highlighting, and generate HTML or styled output. It supports multiple languages and automatic language detection.
Example usage:
final highlight = Highlight();
highlight.registerLanguage(Languages.dart, dart);
final result = highlight.highlight('void main() {}', language: Languages.dart);
final html = result.nodes?.map((node) => node.toHtml()).join();
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parse(
{required String source, required Languages? language, bool autoDetection = false}) → Result -
Parse
sourceand returns a highlightResultwhich contains relevance and tree nodes. -
registerLanguage(
Languages name, Mode languageMode) → void - Registers a single programming language with its highlighting rules.
-
registerLanguages(
Map< Languages, Mode> languages) → void - Registers multiple programming languages at once.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited