RegionRule class final
A region that starts at begin and ends at end, with its own rules active in between.
Regions nest: strings containing interpolations, comments containing nested comments, and so on. The end pattern is tried before rules at the same position.
A region can hand its content to another language: set embed to a
grammar (for example CSS inside an HTML <style> element), or set
embedCapture to a capture group of begin whose text names the
language (for example the info string of a Markdown code fence). Named
languages are looked up in the Highlighter's registry; when none is
found, rules apply instead. The end of an embedding region closes it
from any depth: a code fence ends even inside an unterminated string of
the embedded language, just as </script> ends a script in a browser.
Set endReferencesBegin when the end depends on what the begin matched,
such as a heredoc delimiter: \1–\9 in end then stand for the text
of those capture groups of begin.
Constructors
-
RegionRule({required String begin, required String end, String? scope, String? beginScope, String? endScope, Map<
int, String> beginCaptures = const {}, Map<int, String> endCaptures = const {}, List<Rule> rules = const [], Grammar? embed, int? embedCapture, bool endReferencesBegin = false}) -
Creates a region rule.
const
Properties
- begin → String
-
Pattern that opens the region.
final
-
beginCaptures
→ Map<
int, String> -
Scopes for capture groups inside begin.
final
- beginScope → String?
-
Extra scope for the opening delimiter, nested inside scope.
final
- embed → Grammar?
-
Language used for the region's content instead of rules.
final
- embedCapture → int?
-
Capture group of begin naming the language for the content.
final
- end → String
-
Pattern that closes the region.
final
-
endCaptures
→ Map<
int, String> -
Scopes for capture groups inside end.
final
- endReferencesBegin → bool
-
Whether
\1–\9in end refer to capture groups of begin.final - endScope → String?
-
Extra scope for the closing delimiter, nested inside scope.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
rules
→ List<
Rule> -
Rules active inside the region.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scope → String?
-
Scope for the whole region, including both delimiters.
final
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