llm_markdown 0.4.0
llm_markdown: ^0.4.0 copied to clipboard
Markdown widget for streaming LLM chat replies. Parses only new text, closes half-typed syntax, highlights code and follows the scroll.
0.4.0 #
- Following the end of a reply (
autoScrollController) no longer stops half way on iOS and macOS. It was lost whenever the reply got a little shorter for one frame, for example when a half-typed image was hidden or a formula's source became the drawn formula. - The end is also followed when a picture loads late and makes the reply taller without any new text.
- Labels on Mermaid flowchart edges sit in a gap of the line, not on top of it.
- A tap anywhere on a drawn SVG opens it, also on a see-through part.
- Nothing about the look is fixed any more:
- New parts of
StreamingMarkdownStyle:highlightColor,spoilerColor,citationDecoration,citationTextStyle,kbdDecoration,thinkingStyle,imageBarrierColor,bullets,tableCellPaddinganddiagramStyle(MarkdownDiagramStyle: node, line, note and pie colors). thinkingBuilderandcursorBuilderreplace the thinking section and the cursor with your own widgets;elementBuilders['li']draws list items.MarkdownSelectionAreatakesmenuColor,menuTextStyle,menuBorderRadius,handleColor, or a wholemenuBuilder.labels: MarkdownLabels(...)replaces every built-in word ("Copy", "Show code", alert titles, ...), on a widget or for the whole app withStreamingMarkdownTheme(labels: ...).
- New parts of
- The example app shows the 0.3.0 features, and the demo GIF is new.
0.3.0 #
- Screen readers skip text that is still arriving and announce the reply
when it is done (
announceWhenDone). - Paragraphs, lists, quotes and tables take their direction from their first
letter (
detectTextDirection); code always reads left to right. - Code highlighting runs in the background and only builds the grammars it needs, so the first code block no longer stalls a frame.
- A benchmark in
example/lib/benchmark.dart. - Unsafe links (
javascript:,file:, ...) show as text anddata:images aren't loaded (allowedLinkSchemes,allowedImageSchemes). markdownToPlainText,controller.plainTextand aCopyReplyButton.tapToSkip, aplaceholdersuch asMarkdownShimmerbefore the first token,errorBuilderwithcontroller.completeWithError, andonComplete/onTextChanged.- "Reduce motion" turns off the reveal, fade and blinking.
controller.pause(),resume(),skipAnimation()andreplay().- Reveal presets:
Smoothing.gentle(),.fast(),.typewriter()and.wordByWord()(RevealUnit.word). - Cursor styles (
StreamingCursorStyle: block, bar, underline, dots),fadeBottomEdgeandupdateInterval. controller.addOpenAIStream(bytes)andaddAnthropicStream(bytes)read the raw SSE response body, reasoning included;serverSentEvents()for other APIs.- GitHub alerts (
> [!NOTE]...),<details>sections, citation chips for[1](onCitationTap),==highlight==,||spoiler||,:emoji:, and a few HTML tags (<sub> <sup> <kbd> <mark> <u> <br>). - Footnote references scroll to their note.
- Without a
mathBuilder, math shows as readable Unicode (x²,α). MarkdownSyntaxturns extensions on or off, e.g.dollarMath: falseorautolinks: false, and adds autolink schemes.codeBlocks: CodeBlockOptions(...): line numbers, wrapped lines, collapsing long blocks behind "Show all N lines", highlighting while a block streams, a custom copy button and extra header buttons such as "Run".CodeThemeswith 13 ready-made highlighting themes, andStreamingMarkdownStyle.fromColors(monospace: ...)for your own code font.- Headings get GitHub style ids, so
[Setup](#setup)links scroll to them;headings: MarkdownHeadings()collects them for a table of contents and scrolls to one withscrollTo(id). searchQuerymarks matches for find-in-chat.- Tapping an image opens it full screen with pinch-to-zoom (
zoomImages), or callsonImageTap. maxLineswithfadeOverflowfor previews.sliver: truemakes the widget a sliver that builds blocks lazily, for very long replies in aCustomScrollView.JumpToLatestshows a "new messages" button while the user has scrolled away from the end.- Your own syntaxes:
MarkdownSyntax(blockSyntaxes: ..., inlineSyntaxes: ...)frompackage:markdown, andelementBuildersto draw any element your way, built-in ones included. StreamingMarkdownThemegives every widget below it a style;StreamingMarkdownStyle.lerpfor animated theme changes or a MaterialThemeExtension.- Style presets:
StreamingMarkdownStyle.compact,.spaciousand.terminal. StreamingMarkdownStyle.blockPaddingpads blocks by tag.- A link definition ending in a backslash (
[a]: /b\) no longer crashes themarkdownpackage; any other parser error shows the text as it is. - Every CommonMark and GitHub spec example is checked to stream exactly like a one-shot parse; golden images guard the look.
- Mermaid flowcharts, sequence diagrams and pie charts are drawn, natively,
once their code block is finished (
diagrams,MermaidDiagram). - SVG images are drawn (with
flutter_svg), anddata:images when that scheme is allowed. A broken or missing SVG shows its alt text. - Code is set in JetBrains Mono, which now comes with the package
(
StreamingMarkdownStyle.codeFont). MarkdownSelectionAreamakes replies selectable with a menu of your own actions, without a design library.- The parser moved to the pure Dart package
llm_markdown_parser, for servers and CLIs.package:llm_markdown/parser.dartre-exports it. - Fixes:
[1][2]next to each other are both citation chips.a==b && c==danda||b||care no longer a highlight or a spoiler, andUS$5 ... 5$is no longer math.- A half-typed
</sub>,> [!NOTE],[^1]or[text][ref]no longer shows stray characters while streaming. - An empty
<think></think>no longer shows an empty thinking section. - Math without a
mathBuilderreads better: nested fractions,\left(,\{,\%,\mathbb{R},\vec{v},\sqrt[3]{x};\frac{1}{2}is now1/2. - Plain text keeps
[1]for citations and footnotes, and the title of a<details>section. - A model stream survives a line that isn't JSON (a keep-alive, or an event cut off by a dropped connection) and a broken UTF-8 byte.
- A custom-scheme autolink no longer swallows the full stop after it.
0.2.0 #
- LaTeX math (
$...$,\(...\),$$...$$,\[...\]) with amathBuilderto draw it. Formulas still streaming show their source. - Thinking section for
<think>...</think>replies andStreamingMarkdownController.appendThinking. - Newest characters fade in (
Smoothing.adaptive(fadeLength: ...)).
0.1.0 #
- Initial release.
