Skip to content

PicoMLX/PicoMarkdownView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PicoMarkdownView

SwiftUI component for rendering streaming Markdown and KaTeX in chat-style apps on iOS 18+ and macOS 15+.

Installation

Add the package in your project’s Package.swift:

.package(url: "https://github.com/ronaldmannak/PicoMarkdownView.git", branch: "main")

Then add PicoMarkdownView to the target dependencies that require it.

Usage

import PicoMarkdownView

@StateObject private var stream = PicoMarkdownStream()

var body: some View {
    PicoMarkdownView(stream: stream)
}

func appendChunk(_ markdown: String) {
    Task { await stream.append(markdown: markdown) }
}

PicoMarkdownStream performs incremental parsing. Feed it new Markdown as it arrives (for example from an LLM streaming response). The view maintains continuous selection and reuses layout via a shared NSTextStorage / TextKit 2 host under the hood.

Configuration

let config = PicoMarkdownViewConfiguration(
    backgroundColor: .clear,
    contentInsets: EdgeInsets(top: 12, leading: 16, bottom: 12, trailing: 16),
    isSelectable: true,
    isScrollEnabled: false
)

PicoMarkdownView(stream: stream, configuration: config)

Resetting Content

Task {
    await stream.reset(markdown: "")
}

Benchmarking

Run the bundled tests to exercise streaming and table rendering:

swift test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages