ReplitCodeLanguage class

A language the code block can highlight: an id, lookup aliases, and an ordered rule table.

The built-ins cover the fences an assistant most often emits — Dart, JSON, JavaScript/TypeScript, Python, shell, YAML, HTML, CSS and SQL. Hosts extend the set:

ReplitCodeLanguage.register(
  const ReplitCodeLanguage(
    id: 'lisp',
    rules: [ReplitSyntaxRule(ReplitSyntaxToken.comment, r';[^\n]*')],
  ),
);

Rules earlier in the table take precedence, so comments and strings come first.

Annotations

Constructors

ReplitCodeLanguage({required String id, List<String> aliases = const [], required List<ReplitSyntaxRule> rules, bool caseSensitive = true})
const

Properties

aliases → List<String>
Other names find resolves, e.g. 'py' for 'python'.
final
caseSensitive → bool
False compiles the whole table case-insensitively — for languages like SQL whose keywords come in either case (Dart regexes have no inline (?i)).
final
hashCode → int
The hash code for this object.
no setterinherited
id → String
Canonical name, lowercase by convention — what a fence info string usually carries.
final
rules → List<ReplitSyntaxRule>
Ordered by precedence.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

find(String? id) → ReplitCodeLanguage?
The language for id — or an alias, case-insensitively — and null when unknown: the caller renders plain, never an error.
register(ReplitCodeLanguage language) → void
Makes language resolvable through find, replacing any earlier registration of the same id or alias.

Constants

bash → const ReplitCodeLanguage
css → const ReplitCodeLanguage
dart → const ReplitCodeLanguage
html → const ReplitCodeLanguage
javascript → const ReplitCodeLanguage
One C-family table serves both: TypeScript is close enough to JavaScript at highlighting depth that separate tables would only drift.
json → const ReplitCodeLanguage
plain → const ReplitCodeLanguage
No rules: source renders in plain ink. The explicit registration lets 'text' fences resolve rather than fall through as unknown (the rendering is the same either way).
python → const ReplitCodeLanguage
sql → const ReplitCodeLanguage
yaml → const ReplitCodeLanguage