Repository navigation
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.firstTextBaselinealignment for.decimal,.upperRoman,.lowerRoman, and.dashmarkers—eliminatingPreferenceKey/@Statewidth convergence passes (2.1×–3.3× faster,Δ 0.0 ptjump). - Single-pass task lists & flattened nested bulleted lists:
CompactTaskListView(2.0×–2.2× faster) andCompactNestedBulletedListView(2.0×–2.6× faster) lay out task checklists and multi-level nested bullet trees in a singleBulletedListLayoutwith per-variantBulletProbeMetricsCacheprobes (3.5× fewer layout calls during nested streaming). - Single-pass
.automatic&.adaptivetables (AutomaticTableLayout): Replaces SwiftUIGrid+ per-cellGeometryReader/TableCellBoundsPreferencefor built-in.basic,.gitHub, and.docC.automatictables (2.0×–2.2× faster with pixel-for-pixel parity), enables measurement caching + built-in compact cells on.markdownTableLayout(.adaptive(...))(1.8× faster), and cachesTableBoundsBox.disjointGroups. Theme.gitHubDirectTextStyle+ native decorations: Suppresses redundant per-runAttributedStringbackground fills matching the rootMarkdownbackground (rootTextBackgroundColor, cleared insideBlockquoteView), unlockingDirectTextStyleforTheme.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) toEquatable, replaces binary-bitmaskStaticViewBatchgroups 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 inBlockSpacedStackLayout/ParagraphStackLayout(keyed on full style fingerprint includingdynamicTypeSize,legibilityWeight, andlineLimit). - Integer-enum
MarkdownParser: Dispatches directly oncmark_node_get_typeintegers and caches GFM syntax extensions once inCachedSyntaxExtensions(~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.