highlighting 0.9.0%2B11.8.0
SDKdartflutter
Platformandroidioswindowslinuxmacosweb
Syntax highlighting for Dart with lots of languages and themes support.
highlighting
Code syntax highlighting library for over 190 languages.
If you are looking for the Flutter widget, see flutter_highlighting.
This package is a port of HighlightJS project into Dart. It is periodically updated from the original JavaScript version with an automated script.
Usage
import 'package:highlighting/highlighting.dart';
import 'package:highlighting/languages/dart.dart';
void main() {
final source = '''main() {
print('Highlighting by Akvelon.');
}
''';
highlight.registerLanguage(dart);
final highlighted = highlight.parse(source, languageId: dart.id);
final html = highlighted.toHtml();
print(html); // HTML string
}
Versions and Migration
The package uses its own version numbering in addition to that of HighlightJS.
For example, the version 0.9.0+11.8.0 means that it is:
- Version
0.9.0of the Dart package itself, and it contains breaking changes over the version0.8.x. - Ported from HighlightJS version
11.8.0.
This allows the pub tool to automatically guard you against breaking changes.
Migration guides:
Maintainer's Guide
- Maintainer's Guide on how the automatic porting works.
- How we Ported HighlightJS to Dart on Medium.