highlight method

HighlightResult highlight(
  1. String code, {
  2. required String language,
  3. HighlightContinuation? continuation,
})

Highlights a source chunk, optionally resuming an earlier checkpoint.

See HighlightContinuation for boundary limitations. A checkpoint from a different engine, language, or replaced language definition is rejected.

Implementation

HighlightResult highlight(
  String code, {
  required String language,
  HighlightContinuation? continuation,
}) {
  if (continuation != null &&
      (!identical(continuation._owner, this) ||
          !identical(continuation._language, getLanguage(language)))) {
    throw ArgumentError('Continuation belongs to another engine or language');
  }
  final result = _highlight(language, code, true, continuation);
  result.code = code;
  return result;
}