Last updated:
0 purchases
highlighter
highlighter #
Dart Syntax highlighting library.
If you are looking for Flutter widget, see flutter_highlighter.
Usage #
import 'package:highlighter/highlighter.dart' show highlight;
main() {
var source = '''main() {
print("Hello, World!");
}
''';
var result = highlight.parse(source, language: 'dart');
var html = result.toHtml();
print(html); // HTML string
}
copied to clipboard
Notice that all available languages are registered in the way above. For those desiring more control over what exactly they need, import highlight_core.dart instead and register languages manually:
import 'package:highlighter/highlight_core.dart' show highlight;
import 'package:highlighter/languages/dart.dart';
main() {
var source = '''main() {
print("Hello, World!");
}
''';
highlight.registerLanguage('dart', dart);
var result = highlight.parse(source, language: 'dart');
var html = result.toHtml();
print(html); // HTML string
}
copied to clipboard
References #
All available languages
License #
MIT
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.