opal 0.1.1 copy "opal: ^0.1.1" to clipboard
opal: ^0.1.1 copied to clipboard

Tokenization and syntax highlighting support for various programming languages and data formats.

Dart package with basic support for tokenization and syntax highlighting of various programming languages and data formats.

This package is currently experimental, untested, and expected to change heavily.

Installation #

To use package:opal and access its language tokenization support, first add it as a dependency in your pubspec.yaml file:

dart pub add opal

Usage #

The package contains one library:

  • package:opal/opal.dart

Tokenize code from a known language #

To tokenize text with a known language that has built-in support, access the language from BuiltInLanguages:

import 'dart:convert';

import 'package:opal/opal.dart';

void main() {
  final dart = BuiltInLanguages.dart;
  final tokens = dart.tokenize(
    const LineSplitter().convert('''
void main() {
  print('hi!');
}
'''),
  );

  print(tokens);
}

Supported languages #

Currently the following languages are supported with the specified default and alternative IDs:

  • Dart (dart)
  • Groovy (groovy, gradle)
  • HTML (html)
  • Java (java)
  • JavaScript (javascript, js)
  • JSON (json)
  • Kotlin (kotlin, kt)
  • Markdown (markdown, md)
  • Objective-C (objective-c, objectivec, obj-c, objc)
  • Swift (swift)
  • Text (text, plaintext, none, txt)
  • XML (xml, xhtml)
  • YAML (yaml, yml)
1
likes
160
points
2.23k
downloads

Publisher

verified publisherdartcommunity.dev

Weekly Downloads

Tokenization and syntax highlighting support for various programming languages and data formats.

Repository (GitHub)
View/report issues

Topics

#highlight #tokenization #syntax-highlighting

Documentation

API reference

License

MIT (license)

Dependencies

meta

More

Packages that depend on opal