Skip to content

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

License

Notifications You must be signed in to change notification settings

dart-community/opal

Repository files navigation

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)

About

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

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages