highlighter 0.1.0 copy "highlighter: ^0.1.0" to clipboard
highlighter: ^0.1.0 copied to clipboard

outdated

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

highlighter #

pub

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
}

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
}

References #

License #

MIT

6
likes
0
points
8.61k
downloads

Publisher

verified publishermagnificsoftware.com

Weekly Downloads

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

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection

More

Packages that depend on highlighter