InlineDirective class

A host-defined inline region the Markdown parser must not look inside.

InlinePattern is the tool for host syntax that is still text — @mention, #channel, :emoji:. It runs over the plain-text runs a parse produced, which means the parse has already happened: a payload holding **, a backtick, ~~ or […](…) is consumed as Markdown before the pattern ever sees it, and the match silently fails. That is fine for a mention and useless for a JSON payload.

A directive is the other case: a delimited region whose contents are not Markdown and must survive intact. It is lifted out of the source before parsing and put back at render time, so nothing inside it can be interpreted, truncated, or split across nodes.

GptMarkdown(
  reply,
  inlineDirectives: [
    InlineDirective(
      open: '\u{E200}widget\u{E202}',
      close: '\u{E201}',
      builder: (context, payload, style) =>
          WidgetSpan(child: MyWidget.fromJson(payload)),
    ),
  ],
)

Delimiters should be characters a model does not emit by accident — Private Use Area code points are the usual choice, substituted by the server on the way out so the model itself never types them.

An unterminated directive stays literal text until its closer arrives, which is what a streaming reply needs: a payload that is still arriving must not render half-built.

Constructors

InlineDirective({required String open, required String close, required InlineDirectiveBuilder builder})
Creates a directive.
const

Properties

builder → InlineDirectiveBuilder
Builds the span for each complete occurrence.
final
close → String
The closing delimiter.
final
hashCode → int
The hash code for this object.
no setterinherited
open → String
The opening delimiter.
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