highlight 0.6.0
highlight: ^0.6.0

Dart native js
Flutter Android iOS web

Syntax highlighting for Dart with lots of languages and themes support.

highlight #

pub

Dart Syntax highlighting library.

If you are looking for Flutter widget, see flutter_highlight.

Usage #

import 'package:highlight/highlight.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
}

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:highlight/highlight_core.dart' show highlight;
import 'package:highlight/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
}

References #

License #

MIT

8
likes
90
pub points
90%
popularity

Syntax highlighting for Dart with lots of languages and themes support.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

pd4d10@gmail.com

License

MIT (LICENSE)

More

Packages that depend on highlight