Skip to content

MarkdownUI 2.6.0 — Single-Pass Lists, Automatic Tables & O(1) Live Streaming

Latest

Choose a tag to compare

@peter-maude-new peter-maude-new released this 24 Nov 12:28

What's New in 2.6.0

Pass 8 extends ripulio/swift-markdown-ui's single-pass layout engine to every remaining Markdown construct and makes live LLM/AI streaming scale in O(1) per token with 100% pixel and height parity against upstream 2.4.1 (and automatic fallback for any custom .markdownBlockStyle(...) closure).

Performance Highlights

  • Single-pass numbered lists (NumberedListLayout + CompactNumberedListView): Computes maximum marker width synchronously on pass 1 with .firstTextBaseline alignment for .decimal, .upperRoman, .lowerRoman, and .dash markers—eliminating PreferenceKey / @State width convergence passes (2.1×–3.3× faster, Δ 0.0 pt jump).
  • Single-pass task lists & flattened nested bulleted lists: CompactTaskListView (2.0×–2.2× faster) and CompactNestedBulletedListView (2.0×–2.6× faster) lay out task checklists and multi-level nested bullet trees in a single BulletedListLayout with per-variant BulletProbeMetricsCache probes (3.5× fewer layout calls during nested streaming).
  • Single-pass .automatic & .adaptive tables (AutomaticTableLayout): Replaces SwiftUI Grid + per-cell GeometryReader / TableCellBoundsPreference for built-in .basic, .gitHub, and .docC .automatic tables (2.0×–2.2× faster with pixel-for-pixel parity), enables measurement caching + built-in compact cells on .markdownTableLayout(.adaptive(...)) (1.8× faster), and caches TableBoundsBox.disjointGroups.
  • Theme.gitHub DirectTextStyle + native decorations: Suppresses redundant per-run AttributedString background fills matching the root Markdown background (rootTextBackgroundColor, cleared inside BlockquoteView), unlocking DirectTextStyle for Theme.gitHub (1.7×–2.1× faster prose), and adds native .strikethrough(.single) and .underline(.single) rendering.
  • O(1) live streaming & prefix-stable StaticViewBatch: Conforms block views (DirectProseBlockView, compact lists, CodeBlockView, TableView) to Equatable, replaces binary-bitmask StaticViewBatch groups with prefix-stable 8-slot buckets so appending blocks across power-of-two counts never destroys earlier stateful blocks, and retains measured prefix sizes for stateless blocks in BlockSpacedStackLayout / ParagraphStackLayout (keyed on full style fingerprint including dynamicTypeSize, legibilityWeight, and lineLimit).
  • Integer-enum MarkdownParser: Dispatches directly on cmark_node_get_type integers and caches GFM syntax extensions once in CachedSyntaxExtensions (~23% faster parsing).

Measured Gains (2.5.1 → 2.6.0, macOS Release, 400pt, median of 5)

Workload (400pt width) 2.5.1 2.6.0 Speedup
Numbered List (16 items) (.chat / .basic) 23.7 ms / 22.6 ms 7.1 ms / 7.0 ms 3.3×
Nested Bullets (4×4) (.chat / .basic) 13.1 ms / 13.3 ms 5.3 ms / 5.1 ms 2.5×–2.6×
Task List (12 items) (.chat / .gitHub) 9.9 ms / 12.2 ms 5.0 ms / 5.6 ms 2.0×–2.2×
Wrapping 15×4 Table (.gitHub / .basic) 27.8 ms / 26.5 ms 14.1 ms / 11.9 ms 2.0×–2.2×
Static .adaptive(...) 15×4 Table 24.2 ms 13.4 ms 1.8×
Prose Plain/Bold (8p) (.gitHub) 7.9 ms 3.8 ms 2.1×
Long Mixed Reply (5.9 KB) (.chat / .gitHub / .basic) 48.4 / 74.9 / 62.7 ms 25.3 / 32.6 / 23.0 ms 1.9×–2.7×
80-Step Streaming — Mixed Reply (5.9 KB) (total / p95) 402.5 ms / 12.5 ms 202.5 ms / 3.5 ms 2.0× total · 3.5× p95
80-Step Streaming — 16 Code/Link Paragraphs (total / p95) 188.3 ms / 4.6 ms 61.7 ms / 1.3 ms 3.1× total · 3.6× p95
MarkdownContent Parse (5.9 KB) 0.186 ms 0.142 ms 1.3×

Upgrade

dependencies: [
  .package(url: "https://github.com/ripulio/swift-markdown-ui", from: "2.6.0")
]

Full details in CHANGELOG.md and ARCHITECTURE.md.