Code
MarkdownUI – Render Markdown text in SwiftUI

MarkdownUI is a Swift package for rendering Markdown in SwiftUI, fully compliant with the CommonMark Spec.
Supported Platforms
You can use MarkdownUI in the following platforms:
- macOS 11.0+
- iOS 14.0+
- tvOS 14.0+
Usage
You can create a Markdown
view by providing a Markdown-formatted string.
Markdown("You can try **CommonMark** [here](https://spec.commonmark.org/dingus/).")
If you have already parsed a Markdown-formatted string into a CommonMark document, you can initialize a Markdown
view with it.
let document = try! Document(
markdown: "You can try **CommonMark** [here](https://spec.commonmark.org/dingus/)."
)
var body: some View {
Markdown(document)
}
Alternatively, you can use an embedded DSL to describe the content of a Markdown view.
Markdown {
Heading(level: 2) {
"Markdown lists"
}
OrderedList {
"One"
"Two"
"Three"
}
BulletList {
"Start a line with a star"
"Profit!"
}
}
MarkdownUI installation
You can add MarkdownUI to an Xcode project by adding it as a package dependency.
- From the File menu, select Add Packages…
- Enter
https://github.com/gonzalezreal/MarkdownUI
into the Search or Enter Package URL search field - Link MarkdownUI to your application target
