llm_markdown_renderer 1.0.1
llm_markdown_renderer: ^1.0.1 copied to clipboard
Renders Markdown streamed token by token from an LLM without jank. Incremental parsing, stable partial code fences, tables and lists, syntax highlighting.
1.0.1 #
- Remove the static analysis warnings under Flutter 3.50, which deprecates
package:flutter/material.dartin favour ofpackage:material_ui. The package keeps usingflutter/material.dartfor now, because moving tomaterial_uiwould give it aThemeDatathat apps onflutter/material.dartcannot pass in. It will move once apps have migrated, in a major release.
1.0.0 #
The first stable release. From here on the package follows semantic versioning: the API exported from llm_markdown_renderer.dart and parser.dart only changes incompatibly in a major release, and new Block or Inline subclasses also wait for a major release. See "Versioning" in the README.
New:
- Smooth typing.
MarkdownStreamController(pace: TypingPace(...))shows bursty streams at a steady speed, never more thanmaxDelaybehind what has arrived.StreamingMarkdown.fromStreamtakes apacetoo. MarkdownStreamController.flush()shows all waiting text at once (for a "Stop" button), andpendingLengthsays how much is waiting. With a pace,complete()finishes the document once the waiting text has been shown.
Breaking changes (made now so the stable API can grow without more of them):
- Builders get the node and the surrounding text style.
MarkdownImageBuilder,MarkdownMathBuilderandMarkdownCitationBuildernow take(context, node, style): theInlineImage,InlineMathorInlineCitation(which can gain fields without breaking your code) and theTextStylearound it, which a widget inside text does not inherit. Inline math in a heading can now match the heading's size, and an image builder can readimage.title. Migrate:imageBuilder: (context, url, alt) => …→(context, image, style) => …withimage.url,image.alt.mathBuilder: (context, tex, display) => …→(context, math, style) => …withmath.tex,math.display; passstyleto your typesetter. For aMathBlockyou getInlineMath(block.tex, display: true).citationBuilder: (context, labels) => …→(context, citation, style) => …withcitation.labels.
MarkdownThemeis now afinal class; build variants withcopyWithinstead of subclassing.
Fixes:
StreamingMarkdown.fromStreamstops listening after a stream error, so data the stream emits afterwards no longer throws aStateError.
Example:
- The example app paces its replies, flushes them when you tap "Stop", and passes the text style to its math typesetter.
0.3.0 #
LaTeX math, thinking sections and citations, the syntax models emit most that plain Markdown does not cover.
New:
- LaTeX math.
$…$and\(…\)inline,$$…$$for display math, and$$or\[blocks on their own lines, asInlineMathandMathBlocknodes. Typeset it with the newmathBuilder(MarkdownMathBuilder) and the package of your choice, for exampleflutter_math_fork; without one the TeX source is shown in the code style. The builder is only called once the closing delimiter has arrived, so it never sees half-written TeX. Prices and shell variables ($5 and $10,$HOME) stay text, also while streaming. - Thinking sections.
<think>…</think>(and<thinking>) at the start of a reply, as reasoning models emit it, becomes aThinkingBlock, shown as a collapsible section: open while the model thinks, folded to "Thoughts" once the section closes.</think>inside code does not close it. Customize it withthinkingBuilder. Its content is parsed incrementally, so long reasoning stays cheap per token. - Citations.
[1],[1, 2]and[^note]becomeInlineCitations. They look like the original text unless you passonTapCitation(tappable labels) orcitationBuilder(your own widget). codeBlockBuildermay returnnullto keep the default view, so an app can take over only some languages (for examplemermaid).- New parser options
math,citationsandthinking, all on by default.
Behavior changes (pre-1.0):
- With math on,
$x$,$$x$$and\(x\), and$$or\[blocks on their own lines, no longer render as literal text. Use\$for a literal dollar sign, or setMarkdownParserOptions(math: false). - The new
BlockandInlinesubclasses mean an exhaustiveswitchover those sealed types needs new cases:MathBlock,ThinkingBlock,InlineMathandInlineCitation. MarkdownCodeBlockBuildernow returnsWidget?. Existing builders keep working, but code that calls a stored builder must handlenull.
Docs and example:
- Correct the claim that the parser can be used from plain Dart. It imports nothing from Flutter, but the package depends on the Flutter SDK.
- The example app typesets math with
flutter_math_forkand shows a reply with a thinking section and citations.
0.2.2 #
Replace the chat topic with ai, and give the web demo a real title and description.
0.2.1 #
Add homepage, refresh the demo GIF, and fix the demo's frame-time readout and sample text.
0.2.0 #
Tagged but not published to pub.dev; these changes shipped in 0.2.1.
Breaking (pre-1.0): the public API is smaller.
LineBuffer,parseInlinesandisSafeLinkUrlare no longer exported; they were implementation details. UseIncrementalMarkdownParserandStreamingMarkdowninstead.
Improvements:
- Right-to-left text: paragraphs, headings and table cells take the direction of their first strong character (Arabic, Hebrew), list markers and block-quote bars mirror in right-to-left contexts, and code stays left-to-right.
- Accessibility: headings are semantic headers and lists expose list/list-item roles.
- Reading
MarkdownStreamController.documentno longer copies the block list twice (about 2x faster for very large documents). - Add
benchmark/append_cost.dart, golden tests, accessibility, RTL and text-scale tests,doc/integrations.md(Firebase AI, OpenAI-compatible and Anthropic streaming), CI, GitHub Pages demo and contribution docs. - Stricter lints (
strict-casts,strict-inference,strict-raw-typesand more).
0.1.1 #
- Fix table columns being sized slightly too narrow, which made cell text wrap mid-word (for example
Highlightin/g). It showed up whenMarkdownTheme.fromThemewas built from aThemeDatacreated outsideMaterialApp. Column widths now come from Flutter's own layout and still never shrink while a table streams in. - Add a demo GIF to the pub.dev screenshots.
0.1.0 #
Initial release.
- Incremental, chunk-boundary-independent Markdown parser (
IncrementalMarkdownParser), usable without Flutter. StreamingMarkdownwidget with controller (MarkdownStreamController.append),Stream<String>and static constructors.- Stable rendering of unclosed code fences, tables, lists, emphasis and links while streaming.
- Syntax-highlighted code blocks with copy button; pure-Dart incremental highlighter for 18 languages and a pluggable
CodeHighlighterinterface. MarkdownTheme/SyntaxThemestyling viaThemeExtension.- Example chat app simulating a streaming LLM.
