gpt_markdown library

Classes

AlertBuildDetails
What the alert builder is told about one alert.
AlertStyle
How alerts are drawn — quotes that open with a marker such as [!NOTE]:
ATagMd
Link text component
AutolinkMd
Bare URLs, www. hosts, email addresses and <...> autolinks.
BlockLatexBuildDetails
What BlockLatexBuilder is told about one block formula.
BlockMd
Block component of the legacy regex pipeline.
BlockQuote
Block quote component
BlockQuoteStyle
How a blockquote is drawn.
BlockWidgetSpan
A placeholder holding a block construct rather than an inline one.
BoldMd
Bold text component
CheckBoxMd
Checkbox component
CheckboxStyle
How a task-list checkbox or radio button is drawn.
CodeBlockMd
Fenced code block component of the legacy regex pipeline.
CodeBlockStyle
How a fenced code block is drawn.
CodeTextSpan
A TextSpan carrying inline code, tagged so the paragraph can find it and paint a chip behind it.
CustomTableColumnWidth
A custom table column width.
CustomTableField
CustomTableRow
FencedBlockSyntax
A convenient opaque container such as :::warning ... :::. Its body is raw text, including blank lines. An unfinished block consumes the remaining input with MdCustomBlock.closed false. It does not nest the same fence.
GptMarkdown
This widget create a full markdown widget as a column view.
GptMarkdownBlockEntrance
Plays animation once, the first time this widget is built, then never again.
GptMarkdownConfig
A configuration class for the GPT Markdown component.
GptMarkdownStyleSheet
Per-component appearance, in one object.
GptMarkdownTheme
Wrap a Widget with GptMarkdownTheme to provide GptMarkdownThemeData in your intiar app.
GptMarkdownThemeData
Theme defined for GptMarkdown widget
HeadingStyle
How a # heading is drawn.
HighlightedText
Inline code component of the legacy regex pipeline.
HrLine
Horizontal line component
HrStyle
How a horizontal rule is drawn.
HTag
Heading component
ImageMd
Image component
ImageStyle
How an image is drawn.
IndentMd
Indent component
InlineBuildDetails
What an inline builder is told about the construct it is rendering.
InlineCodeRun
A resolved inline-code run: a range of the paragraph's plain text, and the style its chip is drawn with.
InlineCodeStyle
How inline code is drawn.
InlineDirective
A host-defined inline region the Markdown parser must not look inside.
InlineDirectiveMd
A masked InlineDirective, put back as the host's span.
InlineLatexBuildDetails
What InlineLatexBuilder is told about one inline formula.
InlineMd
Inline component of the legacy regex pipeline.
InlinePattern
A consumer-defined inline syntax, matched and rendered alongside the built-in Markdown components.
InlinePatternMd
Adapts an InlinePattern to the MarkdownComponent pipeline.
InlineTapLeafRecognizer
The recognizer this package arms a tappable leaf with.
InlineTapRun
A resolved tap target: a range of the paragraph's plain text, and what to run when it is hit.
ItalicMd
Italic text component
LatexMath
Inline LaTeX component of the legacy regex pipeline.
LatexMathMultiLine
Block LaTeX component of the legacy regex pipeline.
LatexStyle
How rendered maths is drawn.
LatexTapDetails
What GptMarkdownConfig.onLatexTap is told about a tap on a formula.
LinkBuildDetails
What the link builder is told about one [label](url) or autolink.
LinkStyle
How a link is drawn.
LinkTextSpan
A TappableTextSpan the package recognises as a link.
ListStyle
How ordered and unordered list items are drawn.
MarkdownBlockComponent
Registers a syntax and its renderer on the modern cached pipeline.
MarkdownBlockMatch
A successful match consumes endLine exclusively. Parsers must be pure, deterministic, and accept incomplete input. A match may inspect only its consumed lines; otherwise independently cached blocks would be unsafe.
MarkdownBlockRegistry
Compiled first-character dispatch shared by segmentation and parsing. Invalid consumption is rejected rather than looping or dropping input.
MarkdownBlockSyntax
A locally parsable custom block. Register a matching renderer with MarkdownBlockComponent on GptMarkdown.blockComponents.
MarkdownComponent
Markdown components
MarkdownDefinitions
The link and footnote definitions of one document.
MarkdownSegmentCache
Retains settled segment strings between appends. Only the previous tail and appended source are split again. Edits or CR normalization fall back to a full split. Callers still compare source prefixes; this is not O(1).
MarkdownTextScaling
Shared text-scaling contract for Markdown widgets and custom renderers.
MdAlert
The alert a MdBlockQuote carries. Not an MdNode: it rides on the quote, so the node hierarchy — and every exhaustive switch over it — is unchanged.
MdBlockLatex
MdBlockQuote
MdBold
MdCheckbox
MdCodeBlock
MdCustomBlock
An extension's parsed payload. body remains raw unless the extension explicitly parses it; data should be immutable and independent of Flutter.
MdDocument
Root of a parsed document.
MdFootnote
One footnote definition, [^label]: text.
MdFootnoteDefinitions
A run of consecutive footnote definitions, rendered where they were written — in a model's reply, that is the end.
MdFootnoteReference
A footnote reference such as [^1] or [^note], resolved against the document's footnote definitions. An unresolved [^x] stays text.
MdHeading
MdHorizontalRule
MdImage
MdInlineCode
Backtick span (code), rendered as highlighted inline code.
MdInlineLatex
MdItalic
MdLineBreak
MdLinkDefinition
Where a link reference definition points.
MdListItem
One item of an ordered/unordered list. children holds the item's inline content followed by any nested block nodes (e.g. a nested list).
MdNode
A node in the Markdown tree.
MdOrderedList
MdParagraph
MdRadio
MdSourceTag
A citation marker such as [1].
MdStrike
MdTable
MdTableCell
One cell of a table row; holds inline content.
MdTableRow
One row of a table.
MdText
MdUnderline
MdUnorderedList
MdWidget
It creates a markdown widget closed to each other.
NewLines
Blank-line separator of the legacy regex pipeline.
OrderedList
Ordered list component
Plusparse
Public entry point for the plusparse Markdown parser.
PlusparseRenderer
Renders a plusparse MdDocument AST into the same InlineSpan tree the regex pipeline (MarkdownComponent.generate) produces — same custom widgets (CodeField, UnorderedListView, LinkButton, CustomCb, …), same theme handling, same config builder hooks. Parsing is a single pass over the text instead of recursive combined-regex scanning, which is what makes re-rendering streaming LLM output cheap.
RadioButtonMd
Radio Button component
RevealableSpan
A widget span that lets the reveal reach the text inside it.
RevealEngine
Counters for a character-by-character reveal.
SliverGptMarkdown
Viewport-lazy Markdown for long documents, placed in CustomScrollView.slivers.
SourceTag
source text component
SourceTagBuildDetails
What the source-tag builder is told about one [1] citation chip.
SourceTagStyle
How a [1] citation chip is drawn.
StreamingMarkdown
Reveals text progressively, rebuilding only the part that can still change.
StrikeMd
Strikethrough text component of the legacy regex pipeline.
TableMd
Table component
TableStyle
How a table is drawn.
TappableTextSpan
A TextSpan that answers a tap, without carrying a GestureRecognizer.
UnderLineMd
<u> underline component of the legacy regex pipeline.
UnOrderedList
Unordered list component

Enums

GptMarkdownAnimation
How newly arrived text appears.
GptMarkdownBlockAnimation
How a block plays its entrance once it is complete enough to render.
MarkdownAlertType
The kind of an alert, from the marker on the first line of a quote:
MarkdownScope
The nesting context a MarkdownComponent is being rendered in.
MdAlign
Column alignment for tables (from the :---: separator row).
TableOverflow
What a table does when it is wider than the space it is given.

Mixins

InlineCodeDecoration
Paints a rounded chip behind every inline-code run, once per line fragment.
InlineTapTargets
Resolves taps on InlineTapRuns at the paragraph rather than at the span.

Constants

inlineDirectiveMaskPattern → const String
Matches one masked directive, for the regex pipeline's component.
kGptMarkdownFontPackage → const String
The package that ships kGptMarkdownMonoFontFamily.
kGptMarkdownMonoFontFamily → const String
The monospace family bundled with this package, also used by code blocks.
markupDelimiterHold → const int
Longest run of text the reveal will wait on for a delimiter that is unambiguously markup.
proseDelimiterHold → const int
Longest run of text the reveal will wait on for a delimiter that also occurs in ordinary prose.

Functions

alertSpan(BuildContext context, GptMarkdownConfig config, {required MarkdownAlertType type, required Widget buildContent(GptMarkdownConfig conf), required Widget buildQuoteContent(GptMarkdownConfig conf)}) → InlineSpan
An alert, honouring GptMarkdownConfig.alertBuilder and AlertStyle.
applyReveal({required List<InlineSpan> spans, required int revealed, required GptMarkdownAnimation effect, required double progressFor(int index), required Color defaultColor, int window = 64}) → List<InlineSpan>
Rebuilds spans showing only the first revealed characters, with the ones still arriving styled by effect.
autolinkSpans(BuildContext context, String text, GptMarkdownConfig config) → List<InlineSpan>
Autolinks one run of plain text, without running a regex over it.
baselineWidgetSpan(Widget child) → WidgetSpan
Wraps child in a WidgetSpan that sits on the surrounding text baseline.
blockGap(BuildContext context, GptMarkdownConfig config) → double
The vertical space between two top-level blocks.
blockQuoteSpan(BuildContext context, GptMarkdownConfig config, {required Widget buildContent(GptMarkdownConfig conf)}) → InlineSpan
A block quote, honouring GptMarkdownConfig.blockQuoteBuilder and BlockQuoteStyle.
buildLinkSpan(BuildContext context, GptMarkdownConfig config, {required String url, required String label, bool parseLabel = true, List<InlineSpan> buildLabelSpans(GptMarkdownConfig conf)?}) → InlineSpan
Builds the span for a link, shared by ATagMd and AutolinkMd.
checkboxWidget(BuildContext context, GptMarkdownConfig config, {required bool checked, required Widget label}) → Widget
A task-list checkbox with label beside it, honouring GptMarkdownConfig.checkboxBuilder, CheckboxStyle and GptMarkdownConfig.onCheckboxChanged.
codeBlockWidget(BuildContext context, GptMarkdownConfig config, {required String name, required String code, required bool closed}) → Widget
A fenced code block, honouring GptMarkdownConfig.codeBuilder, CodeBlockStyle and GptMarkdownConfig.onCodeCopy.
collectInlineCodeRuns(InlineSpan root) → List<InlineCodeRun>
Every CodeTextSpan in root, as plain-text ranges.
collectInlineTapRuns(InlineSpan root) → List<InlineTapRun>
Every TappableTextSpan in root, as plain-text ranges.
countRevealCharacters(List<InlineSpan> spans) → int
Total characters in spans, counting a placeholder as one.
decodeInlineDirectiveMask(String masked, int directiveCount) → ({int index, String payload})?
Reads a masked directive back into its index and payload.
defaultQuoteWidget(BuildContext context, Widget content, BlockQuoteStyle style, TextDirection direction) → Widget
The default block quote: a bar, optional padding, background and margin.
defaultSourceTagSpan(SourceTagBuildDetails details) → InlineSpan
The stock [1] chip: a filled circle with the number scaled to fit.
expandInlineDirectives(BuildContext context, String text, List<InlineDirective> directives, TextStyle style, List<InlineSpan> rest(String text)) → List<InlineSpan>
Expands the sentinels in text back into directive spans.
expandInlinePatterns(BuildContext context, String text, List<InlinePattern> patterns, GptMarkdownConfig config, List<InlineSpan> rest(String text)) → List<InlineSpan>
Expands masked pattern matches back into their builders' spans.
headingWidget(BuildContext context, GptMarkdownConfig config, {required int level, required List<InlineSpan> buildChildren(GptMarkdownConfig conf)}) → Widget
A heading of level, honouring GptMarkdownConfig.headingBuilder and HeadingStyle.
hrWidget(BuildContext context, GptMarkdownConfig config) → Widget
Rendering shared by the two parsers.
imageSpan(BuildContext context, GptMarkdownConfig config, {required String url, double? width, double? height}) → InlineSpan
An image, honouring GptMarkdownConfig.imageBuilder, ImageStyle and GptMarkdownConfig.onImageTap.
inlineCodeSpan(BuildContext context, String code, GptMarkdownConfig config) → InlineSpan
Builds the span for one run of inline `code`.
inlineSafeLength(String source, {bool holdMathDollars = false}) → int
How much of source can be shown without its styling changing later.
latexWidget(BuildContext context, GptMarkdownConfig config, {required String tex, required bool inline}) → Widget
Rendered maths, honouring GptMarkdownConfig.blockLatexBuilder, the deprecated GptMarkdownConfig.latexBuilder, GptMarkdownConfig.latexWorkaround and LatexStyle.
maskInlineDirectives(String source, List<InlineDirective> directives, {MarkdownBlockRegistry? blockRegistry}) → String
Replaces every complete directives occurrence in source with an inert sentinel carrying its payload.
maskInlinePatterns(String source, List<InlinePattern> patterns, {MarkdownBlockRegistry? blockRegistry}) → String
Replaces every patterns match in source with an inert sentinel.
orderedListItem(BuildContext context, GptMarkdownConfig config, String no, Widget child) → Widget
One numbered-list item, honouring GptMarkdownConfig.orderedListBuilder and ListStyle. no is the number without its trailing dot.
paragraphBreakSpan(BuildContext context, GptMarkdownConfig config) → InlineSpan
The break between two blocks in a text-rendered document: one empty line.
radioWidget(BuildContext context, GptMarkdownConfig config, {required bool selected, required Widget label}) → Widget
A radio option with label beside it, honouring GptMarkdownConfig.radioOptionBuilder and CheckboxStyle.
resolvedStyleSheet(BuildContext context, GptMarkdownConfig config) → GptMarkdownStyleSheet
The style sheet in force: the widget's, merged over the theme's, field by field, with anything still unset resolved to the package default.
revealStyleFor(GptMarkdownAnimation effect, double progress, Color color) → TextStyle?
The style an in-flight character is drawn with.
scaledWidgetSpan({required Widget child, required GptMarkdownConfig config, PlaceholderAlignment alignment = PlaceholderAlignment.baseline, TextBaseline? baseline = TextBaseline.alphabetic}) → WidgetSpan
A WidgetSpan for an inline widget.
settledSplitOffset(String source) → int
The offset of the last blank line that is safe to split at, or 0 when the whole document has to stay together.
sourceTagSpan(BuildContext context, String id, GptMarkdownConfig config, {String? url}) → InlineSpan
A citation tag such as [1], honouring GptMarkdownConfig.inlineSourceTagBuilder, SourceTagStyle and GptMarkdownConfig.onSourceTagTap.
splitStreamSegments(String src, {MarkdownBlockRegistry? blockRegistry}) → List<String>
unorderedListItem(BuildContext context, GptMarkdownConfig config, Widget child) → Widget
One bullet-list item, honouring GptMarkdownConfig.unOrderedListBuilder and ListStyle.

Typedefs

AlertBuilder = Widget Function(BuildContext context, AlertBuildDetails details)
Builds the widget for an alert — a quote opening with a marker such as [!NOTE]. See AlertBuildDetails for what it is given.
BlockLatexBuilder = Widget Function(BlockLatexBuildDetails details)
Builds the widget for one block formula — \[…\], or $$…$$ with GptMarkdown.useDollarSignsForLatex.
BlockQuoteBuilder = Widget Function(BuildContext context, Widget content, BlockQuoteStyle style)
Builds the widget for a blockquote.
CheckboxBuilder = Widget Function(BuildContext context, bool checked, Widget content, CheckboxStyle style)
Builds the widget for a task-list checkbox and its label.
CodeBlockBuilder = Widget Function(BuildContext context, String name, String code, bool closed)
A builder function for the code block.
HeadingBuilder = Widget Function(BuildContext context, int level, Widget content, HeadingStyle style)
Builds the widget for a # heading.
HighlightBuilder = Widget Function(BuildContext context, String text, TextStyle style)
A builder function for the highlight.
HrBuilder = Widget Function(BuildContext context, HrStyle style)
Builds the widget for a horizontal rule.
ImageBuilder = Widget Function(BuildContext context, String imageUrl, double? width, double? height)
A builder function for the image.
InlineCodeBuilder = InlineSpan Function(BuildContext context, String code, TextStyle style, InlineCodeStyle codeStyle)
Builds the span for one run of inline `code`.
InlineDirectiveBuilder = InlineSpan Function(BuildContext context, String payload, TextStyle style)
Builds the span for one InlineDirective occurrence.
InlineLatexBuilder = InlineSpan Function(InlineLatexBuildDetails details)
Builds the span for one inline formula — \(…\), or $…$ with GptMarkdown.useDollarSignsForLatex.
InlineLinkBuilder = InlineSpan Function(LinkBuildDetails details)
Builds the span for one [label](url) link or autolink.
InlinePatternBuilder = InlineSpan Function(BuildContext context, RegExpMatch match, TextStyle style)
Builds the span for a single InlinePattern match.
InlineSourceTagBuilder = InlineSpan Function(SourceTagBuildDetails details)
Builds the span for one [1] citation chip.
LatexBuilder = Widget Function(BuildContext context, String tex, TextStyle textStyle, bool inline)
A builder function for the LaTeX.
LinkBuilder = Widget Function(BuildContext context, InlineSpan text, String url, TextStyle style)
A builder function for the link.
MarkdownBlockBuilder = Widget Function(BuildContext context, MdCustomBlock node, GptMarkdownConfig config)
Builds one custom block. Blocks are atomic during character reveal; use blockAnimation for an entrance. The renderer receives the parsed payload, so theme changes do not need to run the syntax parser again.
OrderedListBuilder = Widget Function(BuildContext context, String no, Widget child, GptMarkdownConfig config)
A builder function for the ordered list.
RadioOptionBuilder = Widget Function(BuildContext context, bool checked, Widget content, CheckboxStyle style)
Builds the widget for a radio option and its label.
SourceTagBuilder = Widget Function(BuildContext context, String text, TextStyle style)
A builder function for the source tag.
SpanTransform = List<InlineSpan> Function(List<InlineSpan> spans)
Transforms a run of spans — the reveal, handed to a RevealableSpan so it can be applied to content the span builds for itself.
StreamingMarkdownBuilder = Widget Function(BuildContext context, String text)
Builds the Markdown for a slice of the source.
TableBuilder = Widget Function(BuildContext context, List<CustomTableRow> tableRows, TextStyle textStyle, GptMarkdownConfig config)
A builder function for the table.
UnOrderedListBuilder = Widget Function(BuildContext context, Widget child, GptMarkdownConfig config)
A builder function for the unordered list.